Love2D setting the tile x and y - lua

I have a player tile and I want to set the x and the y for the player as a variable, but I can't seem to get it to work.
I tried putting a few numbers behind the function drawq but it just stretched it.
Links to full code (The important one is newgame.lua, I just put the other 2 together with it):
Line 49 - 53
http://xedus.nl/test_builds/maploader.lua
Line 57 - 64
http://xedus.nl/test_builds/main.lua
Line 38 - 46 http://xedus.nl/test_builds/newgame.lua
PS: Sorry, I couldn't put the code in this post, but SO keep nagging me about using the CTRL+K, while I did.

In line 44 you have...
love.graphics.drawq(playertile, Quads[number2], x2, y2)
...(Quads). Shouldn't it be...
love.graphics.drawq(playertile, QuadsP[number2], x2, y2)
...(QuadsP) instead?
Just guessing.

Related

Ferrum mouse.up doesn't work for click & drag method

I'm writing a test which runs over Cuprite::Ferrum, where I need to click, drag and drop an element below another element on the page. Which works fine while I am doing it manually, but when i try to put it in a test, it almost work, but not quite.
I was unable to find he drag and drop API for Ferrum or Cuprite, so I created something like:
def click_and_drag(draggable, droppable, offset_x, offset_y)
x1, y1 = draggable.native.node.find_position
x2, y2 = droppable.native.node.find_position
mouse = page.driver.browser.mouse
mouse.move(x: x1, y: y1)
mouse.down
mouse.move(x: x2 + offset_x, y: y2 + offset_y)
mouse.up
end
Pretty simple and works fine until it get to the mouse.up part. The element that needs to be picked up is found by the draggable = page.find(element), and it needs to be dropped below the droppable = page.find(element).
Everything is going great until the method gets to the mouse.up part, where the dragged element should be dropped and put in it's new place, but it just goes back to it starting position.
I am referring to the Ferrum doc https://www.rubydoc.info/gems/ferrum/0.5/Ferrum/Mouse but cant seam to find the answer.
So, the method works and all is well, the problem was with offset_x and offset_y, if you somehow find this and want to use it, keep it in mid, and keep them small!

Lua Ti-Nspire fillArc() not working as expected

I have this code:
platform.window:invalidate()
function on.paint(gc)
gc:setColorRGB(0,0,0)
for i=1,8,1 do
gc:fillArc(230,(i*30)-40,30,30,45,360-(i*60))
end
end
if you look at the first iteration, where i=1, the circle should be drawn from 45° - 300° counter-clockwise. This isn't what happens. The circle is drawn from what looks like 45° to 345°, which obviously is undesirable.
Some other odd occurrences happen when drawing other circles, which makes them seem flipped, or mirrored or something like that when drawn. This oddity can be replicated by inputting different values into the 2 last arguments of fillArc(). 90 and 270 draws from 90 to 360. 180 and 270 draws from 180 to 90. Why is this occurring?
https://imgur.com/a/Miww8
I don't have a device to test this on, but from what you are describing it looks like the "end angle" argument is taken to be relative to the "start angle", so 90 and 270 will be drawn from 90 to 90+270. This would not be my reading of the documentation -- "The arc is drawn beginning at startAngle degrees and ending at endAngle." -- but it can probably be interpreted either way.

Correct icon sizes for launch screen

Following from njuri's response below, I have added a new image asset and placed within it three images: 200 x1, 400 x2, and 600 x3 (please see image below):
Launch Screen in Xcode for Swift
Is this correct? I wasn't sure if you meant 200 x1, 400 x2 and 600 x3 or 200 x1, x2, x3; 400 x1, x2, x3; 600 x1, x2, x3 (in other words 3 images or 9 images).
Also, I have the 'Universal' box checked. Is that correct?
Thanks.
When working with asset catalogs select the placeholder for the asset you will be using and the inspector on the far right bottom will tell you what the expected size. Repeat this for every image you intend to use to find out the size you need.

How to get updated positions in Lua

I have 2 classes, In one class, I have code for position of object1 changing with time and in class2, I have code for object2 changing with time, the positions are changing continuously at different rates. Now, I want to figure out if the two objects collide, but how do I get their positions that are changing at difference of less tahn a second, is their any shortcut or efficient method to do that?
Here is how object1 and object 2 are changing their positions:
object 1:
self:setRotation( self:getRotation() + math.random(5,7) )
object2:
x = 215 + math.cos(angle)*195
y = 130 + math.sin(angle)*115
Both of these are part of 2 different classes. I need to use them in a third lua file where I am checking for the collisions, so how can I get x and y value of both of these as soon as it changes and pass them to a new function to check for collisions
I have 2 classes, In one class, I have code for position of object1 changing with time and in class2, I have code for object2 changing with time, the positions are changing continuously at different rates. Now, I want to figure out if the two objects collide, but how do I get their positions that are changing at difference of less tahn a second, is their any shortcut or efficient method to do that?
Here is how object1 and object 2 are changing their positions:
object 1:
self:setRotation( self:getRotation() + math.random(5,7) )
object2:
x = 215 + math.cos(angle)*195
y = 130 + math.sin(angle)*115
Both of these are part of 2 different classes. I need to use them in a third lua file where I am checking for the collisions, so how can I get x and y value of both of these as soon as it changes and pass them to a new function to check for collisions
Here is how I tried to use Collision detection using TNT
--> let's say I group all my 3 clock hands, these are rotated around an anchor point so x and y remain the same, but they have some width extending,
--> My player is moving in an ellipsis and it's position is changing with time(only when the player jumps, it's not on floor)
Requirement--> what I really want is whenever the player touches any of the clock hands, youLoose method(not given in the code) shall be called, now to achieve this, here is what I did:
and the collision can be anywhere across the length of any of the clock hands,(so basically this part is what I am not getting)
I checked collision as soon as x and y of player changed,here is the code:
attaching the image as well
x = 215 + math.cos(angle)*195
y = 130 + math.sin(angle)*115
for i = 1, groupA:getNumChildren() do
local sprite2 = groupA:getChildAt(i)
local oBoxToObox = tntCollision.oBoxToObox
if i == 1 then
a = 97
b = 11
elseif i == 2 then
a = 206
b = 64
else
a = 120
b = 10
end
local pointToObox = tntCollision.pointToObox
tntCollision.setCollisionAnchorPoint(0, 0)
if oBoxToObox(x,y, 36, 40, cute.anim[self.frame]: getRotation(),sprite2:getX(), sprite2:getY(), a ,b, sprite2:getRotation()) then
youLoose()
end
end
If the objects have volume you need to test if their boundaries cross, quite complicated, and you should use either Box2d or TNT Collision. Both integrated to Gideros (although TNT is a separate download). TNT Collision is only collision, no physics, so likely to be faster but not necessarily so, you would have to compare.
Otherwise (no volume, ie just point collisions), you can just test the x coordinate of each object; if almost identical, then check the y coord; if almost identical you have a collision, otherwise you don't.

How Do I Invert The Y Axis Motion Of This?

I'm making a little game for iPhone that involves whistling. The phone hears the frequency of your whistle, and sets the position of a sprite on the screen accordingly. Here is the code:
if frequency > 1000 then
soundbar.y = (frequency-1020)/10+30
end
This makes the bar move between 30 and higher on the y axis, with the highest whistling register being at about y 400, which is fine.
There is only one problem. The higher you whistle, the further down the bar goes. Is there any way I can edit my formula, so that the bar starts at 208, and as the pitch increases, the bar rises?
Thanks :) This has had me stumped for a while!
208 - ((frequency-1020)/10+30)
which simplifies to...
178 - ((frequency-1020)/10)
or even...
280 - (frequency/10)

Resources