Hi,
I reinstalled codea and am trying for the 3rd time to learn it. Am working on a breakout game ATM but my collision detection is not working.
Am looking for a little pointer in the right direction, pls don’t rewrite the while code for me as that makes me feel bad.
Please try this and see why it’s failed, thank you.
-- Break
-- Use this function to perform your initial setup
displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)
function setup()
xpos=512
ballx=512
bally=450
end
function draw()
-- define screen space and add collision detection
strokeWidth(5)
background(40,40,50)
line(0,0,0,768) -- draw left wall
line(0,768,1024,768) -- draw top wall
line(1024,0,1024,768) -- draw right wall
physics.body(EDGE,vec2(0,0),vec2(0,768))
physics.body(EDGE,vec2(0,768),vec2(1024,768))
physics.body(EDGE,vec2(1024,0),vec2(1024,768))
-- add 'bat' sprite and setup touch movement
sprite("Planet Cute:Plain Block",xpos,100,150,55)
-- set bat screen limits and collision
xpos=CurrentTouch.x
if xpos<=77 then xpos=78
end
if xpos>=946 then xpos=945
end
physics.body(POLYGON,vec2(xpos,100),vec2(xpos+54,154))
-- add ball and move towards bat
sprite("Tyrian Remastered:Explosion Ball",ballx,bally)
physics.body(CIRCLE ,100)
bally=bally-2
end