Create a Flash game like Cirplosion
Do you remember Cirplosion?
It was quite successful some time ago, and now it’s time to create a game like it.
In this tutorial we’ll design the main engine. When you are going to design a game, or to write whatever script, try to explain yourself what you are about to do.
Let me try to explain with simple words what the does the script do:
* There are some blue orbs running everywhere with a linear motion
* You control a red orb moving it with the mouse
* If you click and hold mouse button, your orb start growing
* While growing, you can’t touch stage border or other orbs, or you will return small
* When you release mouse button you are ready to explode
* Pressing again mouse button will make you explode and kill all orbs you are touching
* Orbs close to explosion will move faster from now on
That’s about 75% of the original game… of course you will need to polish it and add new features.
You have only two objects: player and enemy. It’s up to you to guess their role in the game
Here it is the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | Mouse.hide();
// the rate you circle grows when you keep mouse button pressed
// the higher the value, the fastest the growth
grow_rate = 2;
// number of enemies on stage
enemies = 15;
// enemy speed...
enemy_speed = 3;
// this is the speed to add to enemy's speed when he comes close to an explosion...
speed_add = 3;
// ... how close? addspeed_range determines it.
addspeed_range = 50;
// enemy creation
for (x=1; x<=enemies; x++) {
enemy = _root.attachMovie("enemy", "enemy_"+_x, _root.getNextHighestDepth(), {_x:Math.random()*450+25, _y:Math.random()*450+25});
// angle of movement... 6.28318531 = 2*Math.PI (just faster)
enemy.angle = Math.random()*6.28318531;
// the enemy starts with no additional speed
enemy.addspeed = 0;
enemy.onEnterFrame = function() {
// updating enemy position
this._x += (enemy_speed+this.addspeed)*Math.cos(this.angle);
this._y += (enemy_speed+this.addspeed)*Math.sin(this.angle);
// checking if the enemy left the stage in order to make them appear on the other side
if (this._x>500) {
this._x -= 500;
}
if (this._y>500) {
this._y -= 500;
}
if (this._x<0) {
this._x += 500;
}
if (this._y<0) {
this._y += 500;
}
// calculating the distance between the enemy and the player
x_dist = this._x-player._x;
y_dist = this._y-player._y;
distance = x_dist*x_dist+y_dist*y_dist;
// if the enemy is touching the player...
if (distance<(this._width/2+player._width/2)*(this._width/2+player._width/2)) {
// if the player is growing then reset the player
// later he will lose a life
if (can_grow) {
reset_player();
}
// if the player is exploding, then remove the enemy
if (explode) {
this.removeMovieClip();
}
}
else {// if the enemy is not touching the player but it's close enough to receive speed from the explosion...
if (distance<(this._width/2+player._width/2+addspeed_range)*(this._width/2+player._width/2+addspeed_range) and explode) {
// inverting enemy direction
// later it will be adjusted according to angle between the player and the enemy
this.angle -= 3.14159265;
// adding extra speed
this.addspeed = speed_add;
}
}
};
}
// attaching the player on stage
_root.attachMovie("player","player",_root.getNextHighestDepth());
_root.onEnterFrame = function() {
// updating player position
player._x = _xmouse;
player._y = _ymouse;
// if the player is growing...
if (can_grow) {
// scale up the player
player._width += grow_rate;
player._height += grow_rate;
// if the player touches the edges of the scene then reset it
if (player._x-player._width/2<0) {
reset_player();
}
if (player._x+player._width/2>500) {
reset_player();
}
if (player._y-player._width/2<0) {
reset_player();
}
if (player._y+player._width/2>500) {
reset_player();
}
}
// if the player explodes, then reset it
if (explode) {
reset_player();
}
};
// when the player presses the mouse...
_root.onMouseDown = function() {
// if the player has not grown, then make it grow
if (!has_grown) {
can_grow = true;
}
else {// if the player has already grown, make it explode
explode = true;
}
};
// when the player releases the mouse...
_root.onMouseUp = function() {
// if he was growing...
if (can_grow) {
// the player has grown, now it's ready to explode
has_grown = true;
can_grow = false;
player._alpha = 50;
}
};
// simple function to reset player stats
function reset_player() {
player._alpha = 100;
player._width = 10;
player._height = 10;
explode = false;
has_grown = false;
can_grow = false;
} |
And this is the result… play this quick Cirplosion version!
Now it’s time to add some new features and polish the game.
How will you do it? Download the source code, send me an example and get featured in the blog!
They can be easily customized to meet the unique requirements of your project.
7 Responses to “Create a Flash game like Cirplosion”
Leave a Reply
Trackbacks
-
Flash Tutorials | AS3, AS2 Flash game tutorials roundup part 2 | Lemlinh.com on
August 24th, 2008 12:00 am
[...] Read more [...]
-
Create a Flash game like Cirplosion - AS3 version : Emanuele Feronato on
August 28th, 2008 12:17 am
[...] days ago I published Create a Flash game like Cirplosion using AS2, now it’s time to do it using [...]
- Create incredible particle effects with Partigen 2
- PixelBlitz AS3 game framework
- Being a geek in Venezuela
- Box2D tutorial for the absolute beginners – revamped
- Triqui’s Picks #16
- Are you ready for this?
- Box2DFlash 2.1a released – what changed
- Get detailed statistics about your Flash game with SWFStats
- Games that Challenge the World Come2Play contest – $8,000 in prizes
- Triqui’s Picks #15
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 1
- Create a Flash Racing Game Tutorial
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash draw game like Line Rider or others - part 1
- Create a flash artillery game - step 1
- Triqui MochiAds Arcade plugin for WordPress official page
- Flash game creation tutorial – part 5.2 (4.87/5)
- Create a flash artillery game – step 1 (4.78/5)
- Create a Flash Racing Game Tutorial (4.76/5)
- Create a survival horror game in Flash tutorial – part 1 (4.73/5)
- Flash game creation tutorial – part 3 (4.73/5)
- Creation of a Flash arcade site using WordPress – step 2 (4.73/5)
- Flash game creation tutorial – part 2 (4.70/5)
- Create a flash artillery game – step 2 (4.70/5)
- Flash game creation tutorial – part 1 (4.69/5)
- Create a flash draw game like Line Rider or others – part 1 (4.69/5)


(10 votes, average: 4.80 out of 5)



Cool always wanted to make a game like this
great idea.
I am going to make the levels and i will submit it :)
Looking good. My first major game is nearly completed too !
it’s kind of like filler, in how it expands and the ball collisions.