In my game, you are trying to draw a straight line as close to a real object as you can. This object can only be "found" by tilting your device to move around a ball which then can collide with this object. I need help with making the part that senses if your line is close to the actual object (wall). I have created the function for this, I just don't know how and where to call it. It uses three parameters, (guess number, actual number, value returned true if your line is close) and this is what is causing my trouble. My code is below:(I don't know how to make it look like code)
local function wiggleroom(a,b,c)
for i = 1,50 do
if a > b then
a = a - 1
elseif a < b then
a = a + 1
elseif a == b then
c = "correct"
end
return c
end
end
The three variables I need to call this function on are all in different places in my code.
Thank you! My complete code so far is attached.
Credit to ar2sawseen for his post on appcodingeasy about using the accelerometer. I used it to help make this code.
Comments
Additionally, if you are using Box2d bodies, you could use AABB querying directly, without your own function:
http://docs.giderosmobile.com/reference/physics/b2World/queryAABB#b2.World:queryAABB
but if your function works, it's also ok
Likes: Zizanyman