Group App Instructions: Add floor and ceiling

  1. In game.lua, create theFloor and theCeiling using the image “floor.png”
    1. For Corona SDK, the grid looks like this: (0,0) is at the top left corner, increasing x goes rightwards and increasing y goes downward. The x positions for both variables should be at 0. What should the y variables be? Use display.contentHeight * a number
    2. Add a physics body that is static
    3. Add them to the screen group.
  2. In the functions scene:show and scene:hide, add and remove collision event listeners that use the function onCollision as listeners.
  3. Check your app. You should not be able to extent beyond the top and bottom of the app screen.

Group App Instructions–June 29 2016

  1. Add the speed attribute for all items (see sandwich item).
  2. Create the function moveDynamic with the same parameters and if/else as moveStatic.
    1. in the if section, set the x position to twice the display’s content width
    2. set the y position to some random number between 0 and the display’s content height (Hint: look up corona sdk api. Then look at the math library. Which function do you use to choose a random number?)
    3. set the speed to some random number between 2 and 6
    4. set the amplitude (amp) to a random number between 20 and 100
    5. set the angle to a random number between 1 and 360
    6. in the else section, set the self.x to be the speed subtracted from the x
    7. set the self.angle to be the angle plus 0.1
    8. finally have this line: self.y = self.amp * math.sin(self.angle) + self.initY
  3. Add the amp, angle, and initY attributes to the sandwich, pizza, and both donuts (but not to the hole).
    1. set the initY to be y
    2. set all other values to be the same as was coded in the moveDynamic function
  4. Go to the function scene:show. Change the pizza, sandwich and both donuts to moveDynamic.
  5. At this point, test your app.
  6. Now we are creating the points. in the function scene:create,
    1. set points = 0
    2. In the corona sdk api, look at the timer library. Which function do we use to start the timer?
    3. It is the performWithDelay function. We will want to increment in 100 milliseconds (the first parameter), use the function pointsUpdate as the listener (second parameter), and we want the timer to run forever (third parameter with 0 passed in).
    4. Make the scoreTimer = timer.performWithDelay(100, pointsUpdate, 0)
    5. underneath the scoreTimer, create score = display.newText(“0”, display.contentWidth * 0.9, display.contentHeight * 0.9, native.systemFontBold, 40)
    6. set the fill color of the score (setFillColor using colon, not period) to (0, 100, 0). Do you know what RGB coloring is? It is red-green-blue coloring. Based on this knowledge what color will the score text be?
    7. insert the score into the screengroup
    8. Above the moveStatic function, create a function called pointsUpdate. It takes no parameters.
    9. In pointsUpdate, set points to be points+1. On the following line add this: score.text = string.format(“%d”, points)
    10. Test your app. The score should appear in the bottom right corner of your screen.
  7. Now we will format the start, instructions and replay pages a little further. Download the pictures I sent and put them in your project folder.
  8. Let’s first set up the start and instructions pages.
    1. In start.lua, change all the “button” variables to be called “startButton”
    2. Create instrButton just like how you created startButton. The image to be used is instrbutton.png. Change the y position of the startButton to be 0.3 of the content height. Change the y positions of the instrButton to be 0.8 of the content height.
    3. Add and remove touch event listeners for the instrButton. The listener function should be “goToInstructions”
    4. Create the function goToInstructions EXACTLY like the beginGame function; however, the composer should go to the scene “instructions”
    5. Open instructions.lua. Create a menuButton with the image “troll.png”, and x and y positions halfway across the page. Add it to the screen group
    6. In the function scene:show in the else if section, add a touch event listener to the menuButton with the listener function as “goToStart”. Remove the event listener in the function scene:hide’s if section.
    7. Create the goToStart function EXACTLY like the beginGame function in the start.lua file, but instead the composer should go to the scene “start”
  9. Test your app. The troll face may not be visible, but still click on the center to make sure that you will go back to the main menu page.
  10. Now we will set up the restart page.
    1. Create restartButton just like how you created instrButton (see start.lua for example).
    2. Add and remove touch event listeners for the restartButton in the proper places (see previous instructions 8.6). The listener function should be goToGame
    3. Create the goToGame function EXACTLY like the beginGame function in the start.lua file.
    4. Test your app so that it still runs. You will not be able to reach the restart page just yet.
    5. There is a known error in the restart.lua file. In the toMenu function, “goToScene” should say “gotoScene”. This was my fault, so if you have a question about it, ask me.