![]() ![]() Challenge: when reversing the ||sprites:Ball||‘s ||sprites:vx||, multiply the current ||sprites:vx|| by -1.1 instead of -1.After a ||loops:pause|| of 200 ms, ||sprites:set otherSprite ghost off||.Next, reverse the ||sprites:Ball||‘s ||sprites:vx|| by setting it to the current ||sprites:vx|| multiplied by -1.In the ||sprites:overlap|| event, first ||sprites:set otherSprite ghost on||.Create an ||sprites:on overlap|| event between a ||sprites:Player|| and a ||sprites:Ball||, so that ||variables:sprite|| corresponds to the ||sprites:Player||.In the ||loops:on start||, use ||info:set player one score|| and ||info:set player two score|| to start both players off with a score of 0.Add one to player one’s score with ||info:change score by||.Otherwise, ||logic:if|| the ||variables:currentBall||‘s ||sprites:x|| position is greater than ||scene:screen width||, then.Assign ||variables:currentBall|| to a new ||sprites:sprite of kind Ball||.Add one to player two’s score with ||info:change player two score by||.||sprites:destroy|| the ||variables:currentBall||.||logic:if|| the ||variables:currentBall||‘s ||sprites:x|| position is less than 0, then.else if then|| block inside of the ||game:on game update|| event set ||variables:currentBall||‘s ||sprites:y|| position to ||scene:screen height||.In the second condition, check if ||variables:currentBall||‘s ||sprites:y|| position is greater than or equal to ||scene:screen height||.set ||variables:currentBall||‘s ||sprites:vy|| to it’s current ||sprites:vy|| multiplied by -1.set ||variables:currentBall||‘s ||sprites:y|| position to 0.In the first condition, check if ||variables:currentBall||‘s ||sprites:y|| position is less than or equal to 0.Assign the variable ||variables:currentBall|| to ||sprites:sprite of kind Ball|| in ||loops:on start||, to create a ball when the game starts.Give the ball a random ||sprites:vy|| between -75 and 75.Give the ball a ||sprites:vx|| of either -75 or 75, with a ||math:50 % chance|| of each (use an ||logic:if then.In the ||sprites:on created sprite of kind|| event, use ||sprites:set sprite image to|| to give the sprite an image of a ball.Get the ||sprites:on created sprite of kind|| event, and change ||sprites:Player|| to ||sprites:Ball||.Notice how both player’s scores are shown in the corners of the screen, along with the player numberĬ(player2, 0, 100).Identify where on the screen the player can move.Identify what is being done to set up the players on the left and right side of the screen.For each of the following tasks, you will build on the code introduced in example 2 to create your final game. In the rest of this lesson, we will implement a simple version of The Paddle Game using ||controller:multiplayer||. The Paddle Game was one of the first 2 dimensional games ever released, in which two players can play against one another trying to hit a ball past the opponent. The Paddle Game is a game based off of table tennis (Ping Pong). With this task complete, you can now play games with two players in it: these players can currently only move around the screen, but you can implement any other behavior you want. Change ||variables:mySprite|| to ||variables:player2|| Get a ||controller:player 2 move mySprite with buttons||.Draw a different smiley face for the image, and change the variable name to ||variables:player2|| Get another ||variables:set mySprite to||.The button mappings depend on the controller, and some gamepads may not work.Īdditionally, multiple gamepads can be used to allow for more than the two players a keyboard supports, allowing for three or more players in a single game.Ĭontroller.moveSprite(player1) Student Task #1: Loading Player Two Many gamepads (for example, an Xbox One controller) can be used to control the game as well. ![]()
0 Comments
Leave a Reply. |