Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Use function to sense if something is near a point. — Gideros Forum

Use function to sense if something is near a point.

ZizanymanZizanyman Member
edited November 2014 in General questions
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.
zip
zip
Box2D_accelerometer.zip
13K

Comments

Sign In or Register to comment.