home *** CD-ROM | disk | FTP | other *** search
- function createArea()
- {
- _root.createEmptyMovieClip("area",0);
- with(_root.area)
- {
- }
- }
- function textBoxes(new_score_p, new_score_e)
- {
- _root.createTextField("player_score",1,20,10,20,40);
- _root.createTextField("enemy_score",2,w - 40,10,20,40);
- score_style = new TextFormat();
- score_style.font = "Verdana";
- score_style.size = 20;
- score_style.bold = true;
- score_style.color = 16777215;
- score_style.align = "center";
- player_score.selectable = false;
- player_score.text = new_score_p;
- player_score.setTextFormat(score_style);
- enemy_score.text = new_score_e;
- enemy_score.selectable = false;
- enemy_score.setTextFormat(score_style);
- }
- function createPlayer(instancename, depth)
- {
- _root.createEmptyMovieClip(instancename,depth);
- with(_root[instancename])
- {
- moveTo(0,0);
- beginFill(16777215,100);
- lineStyle(0,16777215,0);
- lineTo(10,0);
- lineTo(10,50);
- lineTo(0,50);
- lineTo(0,0);
- }
- }
- function createBall()
- {
- _root.createEmptyMovieClip("ball",5);
- with(_root.ball)
- {
- moveTo(0,0);
- lineStyle(0,16777215,0);
- beginFill(16777215,100);
- curveTo(0,-5,5,-5);
- curveTo(10,-5,10,0);
- curveTo(10,5,5,5);
- curveTo(0,5,0,0);
- }
- }
- function int_stuff()
- {
- _root.ball._x = w / 2 - 5;
- _root.ball._y = h / 2 - 5;
- _root.enemy._x = w - 20;
- _root.enemy._y = h / 2 - 30;
- }
- function click_2_play(message)
- {
- _root.createTextField("click2play",10,0,20,w,200);
- with(_root.click2play)
- {
- text = message;
- selectable = false;
- setTextFormat(score_style);
- }
- }
- function createBigButton()
- {
- _root.createEmptyMovieClip("big_button",20);
- with(_root.big_button)
- {
- beginFill(0,0);
- moveTo(0,0);
- lineTo(w,0);
- lineTo(w,h);
- lineTo(0,h);
- lineTo(0,0);
- }
- }
- function controlPlayer()
- {
- if(playing)
- {
- _root.player._x = 20;
- _root.player._y = _root._ymouse - 25;
- }
- }
- function moveBall()
- {
- if(playing)
- {
- _root.ball._y += ball_y;
- if(_root.ball._y <= 0 || _root.ball._y + 10 >= h)
- {
- ball_y *= -1;
- }
- _root.ball._x += ball_speed;
- if(_root.ball.hitTest(_root.enemy) || _root.ball.hitTest(_root.player))
- {
- if(ball_speed < max_speed && ball_speed > - max_speed)
- {
- ball_speed *= -1.5;
- }
- else
- {
- ball_speed *= -1;
- }
- }
- if(_root.ball.hitTest(_root.enemy))
- {
- ball_y = (_root.ball._y - (_root.enemy._y + 25)) * 0.2;
- }
- if(_root.ball.hitTest(_root.player))
- {
- ball_y = (_root.ball._y - (_root.player._y + 25)) * 0.2;
- }
- if(_root.ball._x + 10 <= 0)
- {
- enemy_score_one += 1;
- click_2_play("Enemy scored! Click to continue.");
- textBoxes(player_score_one,enemy_score_one);
- playing = false;
- _root.ball._x = w / 2 - 5;
- _root.ball._y = h / 2 - 5;
- ball_y = 0;
- ball_speed = 1.2;
- }
- if(_root.ball._x > w)
- {
- player_score_one += 1;
- click_2_play("You scored! Click to continue.");
- textBoxes(player_score_one,enemy_score_one);
- playing = false;
- _root.ball._x = w / 2 - 5;
- _root.ball._y = h / 2 - 5;
- _root.ball_speed = -1.2;
- ball_y = 0;
- }
- }
- }
- function enemyMove()
- {
- if(playing)
- {
- stupidity = 7;
- if(_root.ball._x + 10 >= w / 2)
- {
- _root.enemy._y += (_root.ball._y - (_root.enemy._y + 25)) / stupidity;
- }
- }
- }
- Mouse.hide();
- w = Stage.width;
- h = Stage.height;
- ball_speed = -1.2;
- ball_y = 0;
- fps = 120;
- interval = Math.round(1000 / fps);
- max_speed = 4;
- enemy_score_one = 0;
- player_score_one = 0;
- new_score_p = 0;
- new_score_e = 0;
- _root.onLoad = createArea();
- createBall();
- textBoxes(player_score_one,enemy_score_one);
- createPlayer("player",3);
- createPlayer("enemy",4);
- int_stuff();
- click_2_play("Click Anywhere To Play");
- createBigButton();
- _root.big_button.onPress = function()
- {
- playing = true;
- click_2_play("");
- };
- setInterval(moveBall,interval);
- setInterval(controlPlayer,interval);
- setInterval(enemyMove,interval);
-