@dave1707
I’m using physics but I can’t figure out why the collision doesn’t work
function setup()
p_rect = physics.body(POLYGON,vec2(-10,10),vec2(-10,0),vec2(10,-10),vec2(10,0))
p_rect.x = 0
p_rect.y = 7
p_rect.gravityScale=0
p_rect.radius = 50
character = physics.body(CIRCLE,50)
character.x = WIDTH/2
character.y = 300
-- Start in the center of the screen
position = vec2( WIDTH/2, HEIGHT/2 )
-- Create two parameters to play with
parameter.number( "yCalibration", 0, 2.0, 0.6 )
parameter.number( "tiltStrength", 1, 40, 10 )
tab={ -- top 1=draw 0=no draw
{0,0,0,0,0,0,0,0,1,0},
{1,1,1,1,1,1,1,1,1,1}, -- bottom
}
end
function draw()
background(0, 145, 255, 255)
--fill(0, 145, 255, 255)
rect(p_rect.x,p_rect.y,WIDTH,100)
for x=1,#tab do
for y=1,#tab[1] do
if tab[x][y]==1 then
sprite("Platformer Art:Block Grass",y*70,(#tab+1-x)*70)
end
end
end
moveVec = vec2(Gravity.x, Gravity.y) + vec2( 0, yCalibration )
position = position + moveVec * tiltStrength
fill(255, 0, 0, 255)
ellipse( position.x, character.y, character.radius*2)
end
function collide(contact)
print("collide")
end