(I am new to Corona)
I am looking to create a game kind of like the game ‘Fall Down’ but with a different concept. I have my ball and my platforms. It is to get to grips on how to use Corona and its features for full games with my own ideas in the future.
display.setStatusBar(display.HiddenStatusBar) local physics = require( "physics" ) physics.start( ) local background = display.newImage( "background.png" ) background.x = display.contentCenterX background.y = display.contentCenterY local floor1L = display.newImage( "floorL.png", 70, 50 ) local floor2L = display.newImage( "floorL.png", 70, 150 ) local floor3L = display.newImage( "floorL.png", 70, 250 ) local floor4L = display.newImage( "floorL.png", 70, 350 ) local floor5L = display.newImage( "floorL.png", 70, 450 ) local floor1R = display.newImage( "floorR.png", 250, 50 ) local floor2R = display.newImage( "floorR.png", 250, 150 ) local floor3R = display.newImage( "floorR.png", 250, 250 ) local floor4R = display.newImage( "floorR.png", 250, 350 ) local floor5R = display.newImage( "floorR.png", 250, 450 ) physics.addBody( floor1L, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor2L, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor3L, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor4L, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor5L, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor1R, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor2R, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor3R, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor4R, "static", {density=1, friction=1, bounce=0} ) physics.addBody( floor5R, "static", {density=1, friction=1, bounce=0} ) local ball = display.newCircle(70, 20, 10) ball:setFillColor(192, 99, 55) physics.addBody(ball, {density=.2, friction=.3, bounce=.1, radius=10} )
What I have done it create a Left and a Right side with 5 platforms on each side . (This is what I have for my app so far) http://gyazo.com/6dc16146eec55da8b61b32312ca60d84
So there is 5 on the left and 5 on the right.
However I need it so when the ball drops down, it will create more platforms and destroy the others at the top, as well as randomly placing them along the X-axis so the gap is in different places but always has a 30 pixel gap. ( I was thinking of something to do with ‘math.random()’ but I am not sure weather to use that to randomly place the Left or Right floors on the X-axis.) Any suggestions/help? Thanks.
[EDIT] Also, will this be the part that I start to think about putting in a parallax background?