How I Made Pong, by Soham K., period 6
Posted by: Mr. Goldstein in Flash, Game Programming, Programming, WritingHow 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!
Comments Off



;
;
;
;
;
;






;
;
;
;
;
;
;
;
;
;
;
;
Entries (RSS)