function setup()
sx = 0
sy = 400
cx = 10
cy = 0
end
function draw()
rect(sx,sy,60)
rect(WIDTH-150,150,100,50)
end
function touched(t)
if t.state==BEGAN then
if t.x>WIDTH-150 and t.x<WIDTH-50 and t.y>150 and t.y<200 then
sx=sx+cx
sy=sy+cy
end
end
if t.state==MOVING then
if t.x>WIDTH-150 and t.x<WIDTH-50 and t.y>150 and t.y<200 then
sx=sx+cx
sy=sy+cy
end
end
end
So I made this code, just for testing, although for some reason t.state==MOVING is extremely buggy and it adds squares behind the one in front. I am attempting to make it only move 1 square. It also does more of a teleport then move. Think of a. 2D game where you control a low effort car. Smooth, and doesn’t randomly spawn in cars behind it. This is what I am trying to do.