stop()
onEnterFrame=function(){ //when we enter this frame we are going to run this function
if (key.isDown(key.Up)){ //move pacman up
pacman._rotation=270 //rotate pacman 270 degrees
pacman._y-=5 //speed in which pacman moves
}
else if (key.isDown(key.Down)){ //move pacman down
pacman._rotation=90 //rotate pacman 90 degrees
pacman._y+=5 //speed in which pacman moves
}
else if (key.isDown(key.Left)){ //move pacman left
pacman._rotation=180 //rotate pacman 180 degrees
pacman._x-=5 //speed in which pacman moves
}
else if (key.isDown(key.Right)){ //move pacman right
pacman._rotation=0 //rotate pacman 0 degrees
pacman._x+=5 //speed in which pacman moves
}
if (score>=1390){
gotoAndStop(2)
}
}
///////// inside the little balls
onEnterFrame=function(){
if(this.hitTest(_root.pacman)){
_root.score+=100
unloadMovie(this)
}
}
code for pacman
////////
xvel=5
yvel=random(10)-5
onEnterFrame=function(){ //when we enter this frame we are going to run this function
//keys for moving paddles up and down
if (key.isDown(65)) {
paddle1._y-=10
}
if (key.isDown(68)) {
paddle1._y+=10
}
if (key.isDown(74)) {
paddle2._y-=10
}
if (key.isDown(76)) {
paddle2._y+=10
}
if (ball._y<0){
yvel*=-1
}
if (ball._y>400){
yvel*=-1
}
ball._x+=xvel
ball._y+=yvel
//when ball passes paddle then ball resets and adds to appropiate score
if (ball._x<0){
score2+=1
ball._x=275
ball._y=200
xvel*=-1
yvel=random(10)-5
}
if (ball._x>550){
score1+=1
ball._x=275
ball._y=200
xvel*=-1
yvel=random(10)-5
}
//ball bounces of paddle after hit
if (ball.hitTest(paddle1)){
xvel=5
yvel=(ball._y-paddle1._y)/5
}
if (ball.hitTest(paddle2)){
xvel=-5
yvel=(ball._y-paddle2._y)/5
}
}
pong
//////
stop()
onEnterFrame = function () {
X = _root._xmouse-10;
Y = _root._ymouse-10;
ball._x = ball._x+(X-ball._x)/10;
ball._y = ball._y+(Y-ball._y)/10;
};
//// inside the wall
onEnterFrame = function(){
if (this.hitTest(_root.ball)) {
_root.gotoAndStop(2);
}
/////inside the last wall
stop();
onEnterFrame = function () {
if (this.hitTest(_root.ball)) {
_root.gotoAndStop(3);
}
};
}
//////
a kind of pacman
///////////
onEnterFrame = function () {
tim += 1;
second._rotation = tim;
minute._rotation = tim/60;
hour._rotation = tim/720;
};
//// making a clok
onEnterFrame = function () {
onMouseMove = function () { x = _root._xmouse;y = _root._ymouse;updateAfterEvent();};
onMouseDown = function () { a = "You pressed the left mouse button";};
onMouseUp = function () { a = "You released your left mouse button";};
};
//////cordinates of the mouse
e = 100;
score=0 //the score will start with 0
onEnterFrame = function () {
if (key.isDown(key.Left)) { //making the ship rotate to the left
ship._rotation -= 3; //each time it rotates 3 degrees
}
if (key.isDown(key.Right)) { //making the ship rotate to the right
ship._rotation += 3; //each time it rotates 3 degrees
}
if (key.isDown(key.Up)) {
xvel += Math.sin(ship._rotation*Math.PI/180)*.1; //modifying the x component using a sine function
yvel -= Math.cos(ship._rotation*Math.PI/180)*.1; //modifying the y component using a cosine function
ship.thrust._alpha = 100; //when up is pressed make the fire appear
} else {
ship.thrust._alpha = 0;
}
ship._x += xvel;
ship._y += yvel;
if (ship._x>550) {
ship._x = 0;
}
if (ship._x<0) {
ship._x = 550;
}
if (ship._y>400) {
ship._y = 0;
}
if (ship._y<0) {
ship._y = 400;
}
c += 1;
if (key.isDown(key.SPACE)) {
if (c>10) {
c = 0;
attachMovie("bullet", "bullet"+b, b++);
_root["bullet"+b]._x = ship._x+Math.sin(ship._rotation*Math.PI/180)*70;
_root["bullet"+b]._y = ship._y+Math.cos(ship._rotation*Math.PI/180)*-70;
_root["bullet"+b].xvel = Math.sin(ship._rotation*Math.PI/180)*10;
_root["bullet"+b].yvel = Math.cos(ship._rotation*Math.PI/180)*-10;
if (b>10) {
b = 0;
}
}
}
d += 1;
if (d>90) {
side = random(2);
if (side == 0) {
d = 0;
attachMovie("Last", "Last"+e, e++);
_root["Last"+e]._x = random(550);
}
if (side == 1) {
d = 0;
attachMovie("Last", "Last"+e, e++);
_root["Last"+e]._y = random(400);
}
}
if (e>150) { //the number of asteroids in the screen is 50
e = 100;
}
};
////////inside asteroid
xvel=(random(20)-10)/4 //can have 20 different speeds, 10 minutes in each direction
yvel=(random(20)-10)/4
onEnterFrame=function(){
for(x=0; x<10; x++){
if(this.hitTest(_root["bullet"+x])){
_root.score+=100
unloadMovie(_root["bullet"+x])
for(r=0; r<2; r++){
_root.attachMovie("mast", "mast"+_root.e, _root.e++)
_root["mast"+_root.e]._x=this._x
_root["mast"+_root.e]._y=this._y
}
unloadMovie(this)
}
}
this._x += xvel //moving the asteroid
this._y += yvel
if (this._x>550) {
onEnterFrame=function(){ //when we enter this frame we are going to run this function
if (key.isDown(key.Up)){ //move pacman up
pacman._rotation=270 //rotate pacman 270 degrees
pacman._y-=5 //speed in which pacman moves
}
else if (key.isDown(key.Down)){ //move pacman down
pacman._rotation=90 //rotate pacman 90 degrees
pacman._y+=5 //speed in which pacman moves
}
else if (key.isDown(key.Left)){ //move pacman left
pacman._rotation=180 //rotate pacman 180 degrees
pacman._x-=5 //speed in which pacman moves
}
else if (key.isDown(key.Right)){ //move pacman right
pacman._rotation=0 //rotate pacman 0 degrees
pacman._x+=5 //speed in which pacman moves
}
if (score>=1390){
gotoAndStop(2)
}
}
///////// inside the little balls
onEnterFrame=function(){
if(this.hitTest(_root.pacman)){
_root.score+=100
unloadMovie(this)
}
}
code for pacman
////////
xvel=5
yvel=random(10)-5
onEnterFrame=function(){ //when we enter this frame we are going to run this function
//keys for moving paddles up and down
if (key.isDown(65)) {
paddle1._y-=10
}
if (key.isDown(68)) {
paddle1._y+=10
}
if (key.isDown(74)) {
paddle2._y-=10
}
if (key.isDown(76)) {
paddle2._y+=10
}
if (ball._y<0){
yvel*=-1
}
if (ball._y>400){
yvel*=-1
}
ball._x+=xvel
ball._y+=yvel
//when ball passes paddle then ball resets and adds to appropiate score
if (ball._x<0){
score2+=1
ball._x=275
ball._y=200
xvel*=-1
yvel=random(10)-5
}
if (ball._x>550){
score1+=1
ball._x=275
ball._y=200
xvel*=-1
yvel=random(10)-5
}
//ball bounces of paddle after hit
if (ball.hitTest(paddle1)){
xvel=5
yvel=(ball._y-paddle1._y)/5
}
if (ball.hitTest(paddle2)){
xvel=-5
yvel=(ball._y-paddle2._y)/5
}
}
pong
//////
stop()
onEnterFrame = function () {
X = _root._xmouse-10;
Y = _root._ymouse-10;
ball._x = ball._x+(X-ball._x)/10;
ball._y = ball._y+(Y-ball._y)/10;
};
//// inside the wall
onEnterFrame = function(){
if (this.hitTest(_root.ball)) {
_root.gotoAndStop(2);
}
/////inside the last wall
stop();
onEnterFrame = function () {
if (this.hitTest(_root.ball)) {
_root.gotoAndStop(3);
}
};
}
//////
a kind of pacman
///////////
onEnterFrame = function () {
tim += 1;
second._rotation = tim;
minute._rotation = tim/60;
hour._rotation = tim/720;
};
//// making a clok
onEnterFrame = function () {
onMouseMove = function () { x = _root._xmouse;y = _root._ymouse;updateAfterEvent();};
onMouseDown = function () { a = "You pressed the left mouse button";};
onMouseUp = function () { a = "You released your left mouse button";};
};
//////cordinates of the mouse
e = 100;
score=0 //the score will start with 0
onEnterFrame = function () {
if (key.isDown(key.Left)) { //making the ship rotate to the left
ship._rotation -= 3; //each time it rotates 3 degrees
}
if (key.isDown(key.Right)) { //making the ship rotate to the right
ship._rotation += 3; //each time it rotates 3 degrees
}
if (key.isDown(key.Up)) {
xvel += Math.sin(ship._rotation*Math.PI/180)*.1; //modifying the x component using a sine function
yvel -= Math.cos(ship._rotation*Math.PI/180)*.1; //modifying the y component using a cosine function
ship.thrust._alpha = 100; //when up is pressed make the fire appear
} else {
ship.thrust._alpha = 0;
}
ship._x += xvel;
ship._y += yvel;
if (ship._x>550) {
ship._x = 0;
}
if (ship._x<0) {
ship._x = 550;
}
if (ship._y>400) {
ship._y = 0;
}
if (ship._y<0) {
ship._y = 400;
}
c += 1;
if (key.isDown(key.SPACE)) {
if (c>10) {
c = 0;
attachMovie("bullet", "bullet"+b, b++);
_root["bullet"+b]._x = ship._x+Math.sin(ship._rotation*Math.PI/180)*70;
_root["bullet"+b]._y = ship._y+Math.cos(ship._rotation*Math.PI/180)*-70;
_root["bullet"+b].xvel = Math.sin(ship._rotation*Math.PI/180)*10;
_root["bullet"+b].yvel = Math.cos(ship._rotation*Math.PI/180)*-10;
if (b>10) {
b = 0;
}
}
}
d += 1;
if (d>90) {
side = random(2);
if (side == 0) {
d = 0;
attachMovie("Last", "Last"+e, e++);
_root["Last"+e]._x = random(550);
}
if (side == 1) {
d = 0;
attachMovie("Last", "Last"+e, e++);
_root["Last"+e]._y = random(400);
}
}
if (e>150) { //the number of asteroids in the screen is 50
e = 100;
}
};
////////inside asteroid
xvel=(random(20)-10)/4 //can have 20 different speeds, 10 minutes in each direction
yvel=(random(20)-10)/4
onEnterFrame=function(){
for(x=0; x<10; x++){
if(this.hitTest(_root["bullet"+x])){
_root.score+=100
unloadMovie(_root["bullet"+x])
for(r=0; r<2; r++){
_root.attachMovie("mast", "mast"+_root.e, _root.e++)
_root["mast"+_root.e]._x=this._x
_root["mast"+_root.e]._y=this._y
}
unloadMovie(this)
}
}
this._x += xvel //moving the asteroid
this._y += yvel
if (this._x>550) {