Hi all, I'm trying to build an arcade game where the player sprite is moved around the screen in a circle using the crank, collecting items and avoiding sprites.
I have very little programming knowledge and some kind folks on here shared some code that got the player moving with the crank, which I'll share here:
In 'Player' script:
on draw do
// Draw a crank dot
if event.ra!=0 then
a = event.aa
a /= 180
a *= 3.14159
emit "sin"
emit "cos"
x = sin
x *= 54
x += 90
x += 2
y = cos
y *= 54
y += 58
y += 2
end
fill "black" at x,y,1,1
end
on crank do
x /= 8
x = floor x
y /= 8
y = floor y
goto x,y
end
In 'Game' script:
on sin do
aNorm = a
while aNorm>=3.141592 do
aNorm -= 6.283184
end
n = 0
modifier = 1
sin = 0
while n<6 do
// modifier * aNorm^(2n+1)
// -------------------
// (2n+1)!
pow = n
pow *= 2
pow += 1
// numerator
num = modifier
p = pow
while p>0 do
num *= aNorm
p--
end
// denominator
f = pow
den = 1
while f>0 do
den *= f
f--
end
if den==0 then
den = 1
end
// log "{modifier} * {num}"
// log "------------------"
// log "{den}"
// Add to result
num /= den
sin += num
// Set up next loop
modifier *= -1
n += 1
end
end
on cos do
oldA = a
oldSin = sin
a += 1.57079
call "sin"
cos = sin
cos *= -1 // Trig is y up, pulp is y down
a = oldA
sin = oldSin
end
This works quite nicely to get the player moving around in a circle with the crank. The trouble is the player now no longer collects items or collides with sprites. I'm guessing that drawing the crank dot and having the player follow it means the Player isn't existing in the room the same way it normally would.
Is there anything I can add or change to this to make the player be able to interact with objects as normal? Or is there a better way to move the player around with the crank?
Thank you very much for any help.