Welcome to my game programming page!
The first assignment in week three was to program a game of Pong in Scratch. Scratch simplifies programming in the language Logo. Users can drag and drop blocks or commands in Scratch to make sprites move and make a simple game.
Start - Space Bar
Flag - Reset
Up - Up Arrow
Down - Down Arrow
Up - W
Down - S
The programming that went into the game:
This is the controls for the pong paddles. You have to have two sets of code, one for either paddle, but the code for both of them are exactly the same.
This is the code for the pong ball, or in this case, the weird sprite that Scratch gave me. You can see the bounce and score code under the "When Space Clicked" block. Under the smaller two blocks are the reset codes and the
Pong was a good first game to try to make in Scratch because it got me used to the program and showed me that it really is not as easy as it seems to make a simple game of pong. Learning to make pong also taught me how to move things using the arrow keys and that came into use in every single other Scratch creation I made.
Here is another simple game that I made in scratch.
Start - Space Bar
Stop - R
Move - Arrow Keys
Multiplayer meshing is when one computer connects to another through a host IP address.
In this case I connected to another computer and their computer was the host of the multiplayer BYOB session. The game that we created was a simple shooter game in which the objective is to reach 100 hits on your opponent. When one player reached 100, the background would switch to "P1 Wins!" or "P2 Wins!"
This is what the game looks like:
Unfortunately I cannot embed the game into my webpage because of the limitations of BYOB.
The coding for meshing a game is harder than making a single player game or even a multiplayer on a singe computer because you have to use broadcasts and share your updated sprites constantly. Broadcasting works by basically sending a message to all of your sprites or even a single one, and then programming your sprite to receive that signal and perform an action such as shooting or moving. Broadcasting can be tricky though because you need to make sure the other person's sprites are not programmed to receive the same signal. Here is the code for my shark character. The code for Peter's Nicholas Cage rabbit is same except for the signals being recieved:
These are just the moving controls using the arrow keys. This is located on the shared Sprite
This is the code for the bullet. You can see the broadcasting going on. With code located in the stage, when the space bar is pressed "P2 Fire" is broadcasted and when the bullet recieves that message it shoots out of the shark. If it does not make contact, the player's score is not increased. When it makes contact with the other player it increases P2's score (a variable) by one point. The score counters are located at the top of the screen in the first mesh picture.
Learning how to multiplayer mesh was a fun experience because it taught me how to join two separate computers together and allow two people to play the same game together on different screens. Plus I got to work with a friend and that is always fun.