PDA

View Full Version : Help making tutorial.


Headshotz
11-15-2005, 09:47 AM
Hello,

I know alot of beginners want to know how to make pong. I wrote
a full remake from scratch and I just need someone to turn it into
a tutorial. Thanks to vengeance from sfdt for finsing the deathbug.


//**********
//CODE BY: Headshotz
//TUTORIAL WRITTEN BY: Yourusername
//THANKS TO: Vengeance from for finding that bug
//SUBJECT: Classic game
//NAME: Pong!
//**********
//++++++++++
//STAGE 1 - DRAW EVERYTHING WITH ACTIONSCRIPT
//++++++++++
//Start by drawing and filling the background
createEmptyMovieClip("background1", 0);
background1.beginFill(0x000000, 100);
background1.lineTo(0, 0);
background1.lineTo(550, 0);
background1.lineTo(550, 400);
background1.lineTo(0, 400);
background1.lineTo(0, 0);
//Now time for the left paddle
createEmptyMovieClip("Left", 1);
Left.beginFill(0xFFFFFF, 100);
Left.lineTo(0, 0);
Left.lineTo(11, 0);
Left.lineTo(11, 34);
Left.lineTo(0, 34);
Left.lineTo(0, 0);
//Now we align it
Left._x = 40;
Left._y = (200-34);
//Now the Right paddle
createEmptyMovieClip("Right", 2);
Right.beginFill(0xFFFFFF, 100);
Right.lineTo(0, 0);
Right.lineTo(11, 0);
Right.lineTo(11, 34);
Right.lineTo(0, 34);
Right.lineTo(0, 0);
//Now we align it to the right
Right._x = 499;
Right._y = (200-34);
//Now we have our paddles drawn and aligned we can move onto the ball
createEmptyMovieClip("Ball", 3);
Ball.beginFill(0xFFFFFF, 100);
Ball.lineTo(0, 0);
Ball.lineTo(11, 0);
Ball.lineTo(11, 11);
Ball.lineTo(0, 11);
Ball.lineTo(0, 0);
//Ok, now we position it
Ball._x = (275);
Ball._y = (200);
//Things might look a bit out of alignment but they fix up when we start the game code!
//Finish stage 1
//++++++++++
//SATGE 2 -- MAKING THE GAME
//++++++++++
//Set the 'reset' function
function reset() {
Ball._x = 275;
Ball._y = 200;
xspeed = 0;
yspeed = 0;
extraspeed = 0;
notmoving = true;
}
reset();
//Begins the game when you click the mouse
onMouseDown = function () {
if (notmoving == true) {
notmoving = false;
xspeed = -2;
yspeed = -2;
extraspeed = 2;
}
};
//Sets function for ball
function playball() {
this._x += xspeed;
this._y += yspeed;
if (this.hitTest(Left)) {
xspeed = 2+extraspeed;
extraspeed += .333;
}
if (this.hitTest(Right)) {
xspeed = -2-extraspeed;
extraspeed += .333;
}
if (this._y>393.5) {
yspeed = -2-extraspeed;
}
if (this._y<6.5) {
yspeed = 2+extraspeed;
}
if (this._x<0) {
reset();
}
if (this._x>550) {
reset();
}
}
//Sets fuction for player (Right)
function playpong() {
this._y += (_ymouse-this._y-(this._height/2))*0.3;
}
//Sets function for AI (Left)
function challenge() {
this._y += (Ball._y+(Ball._height/2)-this._y-(this._height/2))*0.22;
}
//Finish Stage 2
//++++++++++
//STAGE 3 -- EXECUTING EVERYTHING
//++++++++++
Ball.onEnterFrame = playball;
Left.onEnterFrame = playpong;
Right.onEnterFrame = challenge;
//Finish Stage 3
//Finish Code

Headshotz
11-21-2005, 07:20 AM
Well it is in the tutorial forum, I dont think many people have seen it.
I think it would be helpful fot a lot of people. If you are interested feel
free to leave a reply then make it. I already have the full code there.

Cota
11-21-2005, 07:22 AM
What are you talking about.....make sense man...you've about Ruben too long.

Headshotz
11-21-2005, 07:25 AM
Strange, it says 0 views 1 reply, so you replied without viewing it?:confused:

Sorry I just come across alot of people wanting to make pong, so I wrote a
code, but I would like someone to make it into a tutorial.

http://www.actionscript.org/forums/showthread.php3?t=89111

Cota
11-21-2005, 07:27 AM
You aren't comfortable writting it? Basically, the goal is to create a flash based pong game, then you just through the steps of writting the code and give brief explanations of why you're coding it that way.

CyanBlue
11-21-2005, 03:10 PM
Hey, Headshotz... :)

Nobody is rushing you or anything... Why not spend some time to remember what your strategy was before you build the game and write a tutorial??? We can proofread what you have but it's your material, so you've got to do it... ;)

Cota
11-22-2005, 02:25 AM
Yeah....I have a good proof reader....;)

Headshotz
12-15-2005, 12:19 AM
Alright, sorry for the crosspost :o , I will write a tut.

G3M3NI
12-17-2005, 09:35 PM
I wouldve thought pong would be less code.

Headshotz
12-18-2005, 09:04 AM
What? How low do you wanna go, thats not much code.

G3M3NI
12-19-2005, 09:36 AM
no im notused to actionscript2 where its all in one frame together im kinda used to it being spread throuh movie cips like actionscript original

Headshotz
12-19-2005, 09:55 AM
Oh, well start learning because AS1 will be as well known as Flash 2 actionscript pretty soon :p