Creating walls

How do I make this roof become walls (right and left) ?

-- create a five point high wall the width of the screen position at top: local walls = display.newRect(display.contentCenterX, 0, display.contentWidth, 5) -- make it a static physics body physics.addBody( walls, "static", { friction=0.5, bounce=0.3 } )

Just do the same thing but move the others to be in the right place or provide different parameters to the newRect function.

I dont know how

  1. Download this: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/askEdStarter.zip

  2. Modify the main.lua file by adding the things you’ve tried so far.

  3. Zip it up.

  4. Post here and attach the zip file.  (click ‘More Reply Options’ button near bottom to get option for attaching files.)

Please re-read the docs on the function your having trouble with:

https://docs.coronalabs.com/api/library/display/newRect.html

Then read about these display.* fields:

Finally, don’t forget, there are plenty of examples free and paid.  Examine the marketplace for some great examples from which you can learn.

If you have read the docs and are still having trouble you may want to:

  • take some time off to train up on general programming, etc.
  • get a mentor

With no intent to be condescending, this is very fundamental stuff which you need to be able to grasp fully.  If you can’t or don’t I don’t think you’re ready for general game programming.

I’ve told others the same basic thing.  You have to walk before you can run.

I put the code I tried in update.lua

I thought this was obvious, but the intention was I should be able to simply run your example unmodified.

Your code didn’t run.  

  1. You didn’t change main.lua as instructed - Please follow directions in the future.

  2. When contents of update.lua are pasted into main.lua it also doesn’t run.

Try again.  Share a project that actually runs, even if it isn’t doing what you want it to do.

BTW, this is one of many, many ways to write your wall maker:

local function createWalls( wallWidth ) local fullw = display.actualContentWidth local fullh = display.actualContentHeight local centerX = display.contentCenterX local centerY = display.contentCenterY local leftWall = display.newRect( centerX - fullw/2 + wallWidth/2, centerY, wallWidth, fullh ) local rightWall = display.newRect( centerX + fullw/2 - wallWidth/2, centerY, wallWidth, fullh ) local topWall = display.newRect( centerX, centerY - fullh/2 + wallWidth/2, fullw - 2 \* wallWidth, wallWidth ) local bottomWall = display.newRect( centerX, centerY + fullh/2 - wallWidth/2, fullw - 2 \* wallWidth, wallWidth ) physics.addBody( leftWall, "static", {bounce = 0.0, friction = 2} ) physics.addBody( rightWall, "static", {bounce = 0.0, friction = 2} ) physics.addBody( topWall, "static", {bounce = 0.0, friction = 2} ) physics.addBody( bottomWall, "static", {bounce = 0.0, friction = 2} ) end createWalls( 40 )

When I asked you to modify my starter, I expected to get something back similar to this:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/03/walls.zip

Just do the same thing but move the others to be in the right place or provide different parameters to the newRect function.

I dont know how

  1. Download this: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/askEdStarter.zip

  2. Modify the main.lua file by adding the things you’ve tried so far.

  3. Zip it up.

  4. Post here and attach the zip file.  (click ‘More Reply Options’ button near bottom to get option for attaching files.)

Please re-read the docs on the function your having trouble with:

https://docs.coronalabs.com/api/library/display/newRect.html

Then read about these display.* fields:

Finally, don’t forget, there are plenty of examples free and paid.  Examine the marketplace for some great examples from which you can learn.

If you have read the docs and are still having trouble you may want to:

  • take some time off to train up on general programming, etc.
  • get a mentor

With no intent to be condescending, this is very fundamental stuff which you need to be able to grasp fully.  If you can’t or don’t I don’t think you’re ready for general game programming.

I’ve told others the same basic thing.  You have to walk before you can run.

I put the code I tried in update.lua

I thought this was obvious, but the intention was I should be able to simply run your example unmodified.

Your code didn’t run.  

  1. You didn’t change main.lua as instructed - Please follow directions in the future.

  2. When contents of update.lua are pasted into main.lua it also doesn’t run.

Try again.  Share a project that actually runs, even if it isn’t doing what you want it to do.

BTW, this is one of many, many ways to write your wall maker:

local function createWalls( wallWidth ) local fullw = display.actualContentWidth local fullh = display.actualContentHeight local centerX = display.contentCenterX local centerY = display.contentCenterY local leftWall = display.newRect( centerX - fullw/2 + wallWidth/2, centerY, wallWidth, fullh ) local rightWall = display.newRect( centerX + fullw/2 - wallWidth/2, centerY, wallWidth, fullh ) local topWall = display.newRect( centerX, centerY - fullh/2 + wallWidth/2, fullw - 2 \* wallWidth, wallWidth ) local bottomWall = display.newRect( centerX, centerY + fullh/2 - wallWidth/2, fullw - 2 \* wallWidth, wallWidth ) physics.addBody( leftWall, "static", {bounce = 0.0, friction = 2} ) physics.addBody( rightWall, "static", {bounce = 0.0, friction = 2} ) physics.addBody( topWall, "static", {bounce = 0.0, friction = 2} ) physics.addBody( bottomWall, "static", {bounce = 0.0, friction = 2} ) end createWalls( 40 )

When I asked you to modify my starter, I expected to get something back similar to this:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/03/walls.zip