We can also add a test to see if the bat hits the edge of the game screen: Scoring I’ve made my game stop at this point, but later we will change this. Select the bat sprite and modify the script to include the “If” test: We need to see if the bat hits either the top building or the bottom building. To test if the bat is touching the buildings we can use an “If” block. We need a test to see if the bat hits the building. Be sure to place the building in the starting position first! The process for moving the top building is the same, but this time we use positive numbers for the random part. Now we have a building moving across the screen at the bottom. We want this Y position to be the same number that we randomly moved, if the glide block has the same Y position at the start and end, then it will move straight.ĭrag the Y position block into the glide block: This is because we set a Y position in the glide block. If we test this out, we find that the buildings move diagonally. We used negative numbers because the bottom half of the screen on the Y direction is between 0 and -180. We can add a little bit of randomness to this. The next problem we have is that the buildings are always the same height from the bottom of the screen. We need to change this to happen all the time. If we run this we see that the building moves across the screen, but only once. I changed the X position to be -240 which is the lowest X number that our game area has. We can then use the glide block to set the position of the building that we want it to move towards: This will set the correct position on the X – Y movement blocks which we can use. I moved my building all the way to the right hand side of the screen. Drag it to where you want to start the movement. We want our building to be able to move across the screen, let’s select the bottom building sprite first. To make our bat fall we used a negative number, so to make it fly we can use a positive number: Make the building move We need the user to tell us when to make the bat fly. Giving the bat some extra boostĪt the moment our bat falls from the sky with no way to keep it in the air. We can animate the bat flying by adding in a costume change. Test this out and we will see that our bat slowly falls from the sky. I’ve moved our bat to the position I want it to start flying with. If we always want something to happen, then we should be using the forever block. Our bat should always be falling from the sky, we know that the Y axis controls the up / down movement. We will need a few sprites to get our game working: Making the Bat Fly The bird will fall from the sky unless you hit the space key to give it some extra boost. The goal of the game is to keep the bat flying and not hit the walls that close in. We are going to build a game that is very similar to something popular, we are calling it: Flap a Bat.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |