Archive for the “Game Programming” Category

How to make Pong:

The pong game was made in Flash, and it was all written in code. The code directed the program to change and move the elements according to keyboard commands.

There were 8 sets of codes in total, each telling the computer a different set of commands, and they all made the game react to the player commands in a different way. These next paragraphs will explain thoroughly the different steps which were typed up to code to command the program.

Before starting to program, I made two layers on Flash, one being “Actions”, and the other being “graphics”. In “graphics”, I created a ball using the circle tool, and decorated the inside to my taste (a bloody knife dripping over a pool of blood) and made into a movie clip symbol, naming it “ball”. I then opened Properties and gave it the instance name of “ball”. Once that was done, I created a paddle by using the various tools to make the paddle and a hand to accompany it. I then copied it and made a second, inverse paddle. I made the one on the left a movie clip and named it “player” and the one on the left I named “opp”, making it a movie clip also. I gave them the instance name of the same.

I finally made two word boxes, selecting them and giving them an instance name of playerScore for the one on the left, and oppScore for the one on the right. I then made them dynamic text in properties to make the score variable. All these symbols become used later in the programming.

Next, I started to program. I started with Pong 1, which made the ball move to the left or right (you can change how the ball moves on the x-axis by changing the numbers for the direction). I saved the program and in the Six Period Folder, and erased to start the new pong: Pong 2. Pong 2 commands the computer to move the ball in any x-axis, but now you can change the speed of the ball to anything you want, simply by changing the number which directs the x-axis. I then did the same procedure as I did for pong one: I saved it as pong 2, but I didn’t delete the pong two. I simply added on pong 3 to the bottom of pong 2.

Pong 3 tells the computer the make sure that the ball never leaves the player’s sight, even if the ball goes of stage. It does this by coding “ball.checkBoundaries = function() {“, the coding version of “make sure that you check the boundaries of the stage” It also tells the computer what to do if the ball goes to a certain wall of the stage. I then saved it as pong 3, and then put pong 4 on top of pong 2. Pong 4 gave the program the initial function, by saying “function init() {“. This tells the computer the set up for initial function for the game.

I then save it and program Pong 5. This particular code commands the computer to allow the player to move the player paddle. It does this by coding “player._y = _root._ymouse;”, which basically says “instead of moving the mouse, you move the paddle, but only up and down. This goes below Pong 4, and now the player can move the paddle up and down the intercept the ball. Pong 6 followed, and it was very long and detailed as it covered many subjects in the Pong game. It simply changes the score if the ball goes past the paddle and onto the left or right walls.
Pong 6 uses the code “oppScore++” and “ playerScore++” to increase the score. I then saved it and then programmed Pong 7, the part of the Pong code which explains what will happen if ball comes in contact with the paddle: it will bounce off. It does this by programming many different codes, one being: “ball.checkPaddles=function(){“ , the code that tell the computer to check for paddle contact. Others include: “if(ball.hitTest(opp)) {“, which is an if – then situation.

I then saved that and finally started Pong 8, the Pong code which explains the sound and the places where it is emitted. It is put in three parts, each of which covers a different section of the code. Along with that, you must take files from the desktop and put them in your library. These files are the various sounds used in the game, and they are “ball hits wall”, “ball hits paddle” and “ball goes in win zone”. You must convert them to put them in the Linkage. You can them put them in your game.

Finally, you press ctrl – enter to play your game, watch you work in action. So that’s how you make your pong game.

Chow!


Pong

Comments Comments Off

How I made Pong:

I started my pong project by making two layers. One was called “graphics” and the other was called “actions”. In the “graphics” layer, I made a ball. I was sure to hold down Shift to make it a perfect circle. Then I made converted it to a movie clip symbol. I named it “ball”, then I went into properties, and named the instance name “ball”. Then I made two bars. I made one into a movie clip and name it “player” and named the instance name “player”. I did the same to the other bar except I named it “opp”. Then I made two word boxes using the Font tool. I made both of them into Input Text. For the left box I made the variable “playerScore”. For the box on the right I named the variable “oppScore”. Now I just needed to put in the code.

Now all I had to do was out in the “pongs”. These are just different codes that make different things happen in the movie. I first went to the “actions” layer. I clicked open the “Action” tab, and click the small icon in the corner. I was then able to activate Expert Mode, which allows me to type in code.

I typed in pong 1, but then erased it, because that was the instructions.

Then I typed in pong 2, which had ball.dx = 5; ball.dy = 0; this tells the ball to move right at 5 pixels per second.

Pong 3 had things like if (ball._x >= Stage.width) { ball._x = 0; } This tells the game if the ball leaves the right side. Pong 3 also had code that tells the game when the ball leaves the top, bottom, and left side.

Next is pong 4. This pong had code like playerScore = 0; and oppScore = 0; which set the score in the two dynamic text boxes I made earlier. Pong 4 also had Mouse.hide( ); which hid the mouse in-game.

Pong 5 had codes like player._y = _root._ymouse; this is very useful. This makes the left bar(player) follow the mouse movement vertically.

Pong 6 had A LOT of code. This page handles the scoring system. If ball passes right, player scores, and text box goes up. If the ball passes right, opp scores. This also handled the ball bouncing off the top and bottom of the screen.

Next pong 7. This handled the ball bouncing off the left and right bar, using code like ball.checkPaddles = function ( ).

Last is pong 8, which is everything sound. You had to go online to find your own sounds, and upload them to your pong.

And that is how I made my pong project.

Comments Comments Off

Click on the above image to play

Comments Comments Off

Click on the above image to play

Comments Comments Off

Click on the above image to play

Comments Comments Off

Comments Comments Off

Comments Comments Off

Comments Comments Off

Comments Comments Off

Comments Comments Off