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:
-
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 [...]
Posts
- Rick Triqui: my first PlayCrafter game
- Prototype of a Flash game like Meeblings
- Games for the game developers!
- The art of debugging
- How to embed a text file in Flash
- Create a Flash game in minutes with PlayCrafter
- Upgrade your Flash CS4 to 10.0.2
- Play Mazeroll, my latest Box2D game
- Triqui MochiAds Arcade plugin for WordPress Released!!
- The MochiAds funnel
- Flash game creation tutorial - part 1
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Create a flash draw game like Line Rider or others - part 1
- Create a Flash Racing Game Tutorial
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash artillery game - step 1
- Create a flash draw game like Line Rider or others - part 5
- Flash game creation tutorial – part 5.2




(4.9 out of 5) - Flash game creation tutorial – part 3




(4.86 out of 5) - Creation of a platform game with Flash – step 2




(4.84 out of 5) - Create a survival horror game in Flash tutorial – part 1




(4.82 out of 5) - Create a flash artillery game – step 1




(4.82 out of 5) - Create a Flash Racing Game Tutorial




(4.8 out of 5) - Create a flash artillery game – step 2




(4.75 out of 5) - New tile based platform engine – part 6 – ladders




(4.74 out of 5) - Flash game creation tutorial – part 2




(4.73 out of 5) - The experiment – one year later




(4.7 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.