Physics Wall Options

Hi,

I’m totally new to mobile development and to Corona SDK so I might be asking a dumb question.  My experience thus far is completing the space shooter tutorial with some of my own tweaks and actually loading and playing it on my phone.  Fun stuff!

In any event, my first game project is basically a breakout type game with a ball that bounces off three walls.  I started down the path of creating three separate walls but I’m wondering if it wouldn’t be smarter and easier to have one U shaped object.  I’m guessing there are some overhead savings doing it that way and certainly some code savings but I don’t know if that’s a wise approach or not.  Are there collision issues, potential layout challenges, etc.?  Plus I haven’t learned out to make shape conforming physics objects yet.  The space shooter tutorial used round physics objects for everything. 

So in a game like this what is the smart approach?  Any real tangible benefits one way or the other?  Any advice greatly appreciated.  I figure there is a basic principle involved here somewhere (using single objects vs multiple objects maybe?) but I can’t put my finger on it.

Thanks,

Paul

You’re better off with discrete objects for the walls.  i.e. 3 as you are doing now.

Why?

  1. Simpler to specify.

  2. What you describe is a concave shape which is not acceptable as a collision shape in Box2D (or any other 2D physics-engine really)

Having said that… you could still make a shape like this (I do believe)  with a chain style body:

https://docs.coronalabs.com/guide/physics/physicsBodies/index.html#edge-shape-chain-body

Again, I don’t think this is the way to go, but if you want to do it for fun, give it a try.  

Finally, if you want to see a completed ‘breakout’ game, you can pick up a completed game in the marketplace: 

https://marketplace.coronalabs.com/asset/breakout-game-templates

( 4 versions of the game increasing in complexity and using more advanced features as you go along. )

https://www.youtube.com/watch?v=DBahwJ2HMCU

For an example of the edge-chain in use (not your specified usage, but still interesting), go here:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/SSK2/forums_help/circlePongBounce.zip

https://www.youtube.com/watch?v=ayc2HApxOkg

Thanks for all of that info!  Quite clear on your explanation regarding the collision issue.  Seems obvious now that you’ve mentioned it, lol.  I’ll check out those items in the marketplace as well.

You’re better off with discrete objects for the walls.  i.e. 3 as you are doing now.

Why?

  1. Simpler to specify.

  2. What you describe is a concave shape which is not acceptable as a collision shape in Box2D (or any other 2D physics-engine really)

Having said that… you could still make a shape like this (I do believe)  with a chain style body:

https://docs.coronalabs.com/guide/physics/physicsBodies/index.html#edge-shape-chain-body

Again, I don’t think this is the way to go, but if you want to do it for fun, give it a try.  

Finally, if you want to see a completed ‘breakout’ game, you can pick up a completed game in the marketplace: 

https://marketplace.coronalabs.com/asset/breakout-game-templates

( 4 versions of the game increasing in complexity and using more advanced features as you go along. )

https://www.youtube.com/watch?v=DBahwJ2HMCU

For an example of the edge-chain in use (not your specified usage, but still interesting), go here:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/SSK2/forums_help/circlePongBounce.zip

https://www.youtube.com/watch?v=ayc2HApxOkg

Thanks for all of that info!  Quite clear on your explanation regarding the collision issue.  Seems obvious now that you’ve mentioned it, lol.  I’ll check out those items in the marketplace as well.