Flash prototype of a game like Balloon Invasion
One of the latest successful games released last week was Balloon Invasion.
It’s a mix between an artillery and a defense game, with a World War II theme.
I made a little prototype of the game, that will be explained another day. It’s nothing so interesting, just a mix between Create a flash artillery game and Managing multiple collision detection with Flash tutorials.
That’s the good point when you write a lot of code: the more you write, the more you can recycle.
The main difference however is the firing system: enemies don’t get hurt by bullets but mby explosions bullets make when they come to the spot you fired on… just like “real” artillery
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 | Mouse.hide();
attachMovie("crosshair","crosshair",1);
attachMovie("tank","tank",2,{_x:450, _y:350});
fire_array = new Array();
fire_delay = 30;
just_fired = 0;
crosshair.onEnterFrame = function() {
this._x = _xmouse;
this._y = _ymouse;
};
tank.onEnterFrame = function() {
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y)*-1;
angle = Math.atan(mousey/mousex)/(Math.PI/180);
if (mousex<0) {
angle += 180;
}
if (mousex>=0 && mousey<0) {
angle += 360;
}
if (angle>160) {
angle = 160;
}
if (angle<20) {
angle = 20;
}
firepower = Math.sqrt(mousex*mousex+mousey*mousey);
if (firepower>200) {
firepower = 200;
}
this.cannon._rotation = angle*-1;
};
function onMouseDown() {
if (just_fired>fire_delay) {
just_fired = 0;
angle = tank.cannon._rotation;
start_ball_x = tank._x+48*Math.cos(angle*Math.PI/180);
start_ball_y = tank._y+48*Math.sin(angle*Math.PI/180);
cannonball_fired = attachMovie("cannonball", "cannonball_"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y});
cannonball_fired.dirx = Math.cos(angle*Math.PI/180)*firepower;
cannonball_fired.diry = Math.sin(angle*Math.PI/180)*firepower;
cannonball_fired.fire_coord_x = _root._xmouse;
cannonball_fired.fire_coord_y = _root._ymouse;
cannonball_fired.onEnterFrame = function() {
this._x += this.dirx/50;
this._y += this.diry/50;
dist_x = this._x-this.fire_coord_x;
dist_y = this._y-this.fire_coord_y;
dist = Math.sqrt(dist_x*dist_x+dist_y*dist_y);
if (dist<20) {
fire_array.push("explosion"+_root.getNextHighestDepth());
exp = attachMovie("explosion", "explosion"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:this._x, _y:this._y});
exp.onEnterFrame = function() {
this._width += 2;
this._height += 2;
this._alpha -= 2;
if (this._alpha<0) {
for (x in fire_array) {
if (this.name == _root[fire_array[x]].name) {
fire_array.splice(x,1);
}
}
this.removeMovieClip();
}
};
this.removeMovieClip();
}
};
}
}
_root.onEnterFrame = function() {
just_fired++;
new_enemy = Math.random()*100;
if (new_enemy<1) {
enemy = attachMovie("enemy", "enemy"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:-40, _y:Math.random()*200+50});
enemy.speed = Math.random()*2+1;
enemy.onEnterFrame = function() {
this._x += this.speed;
if (this._x>550) {
this.removeMovieClip();
}
for (x in fire_array) {
dist_x = this._x-_root[fire_array[x]]._x;
dist_y = this._y-_root[fire_array[x]]._y;
dist = Math.sqrt(dist_x*dist_x+dist_y*dist_y);
if (dist<(this._width+_root[fire_array[x]]._width)/2) {
this._alpha -= 5;
if (this._alpha<0) {
this.removeMovieClip();
}
}
}
};
}
}; |
And here’s the result:
Download the source code and start cloning the game :)
They can be easily customized to meet the unique requirements of your project.
9 Responses to “Flash prototype of a game like Balloon Invasion”
Leave a Reply
Trackbacks
-
Displaying enemiy’s energy bar in Flash games : Emanuele Feronato - italian geek and PROgrammer on
March 6th, 2008 1:52 pm
[...] time to show you how can you do this. In this example, I will start from the Flash prototype of a game like Balloon Invasion example but obviously you can apply the same concept to whatever game you [...]
- Citrus Engine released for free for learning
- My epic fail with ClickBank
- Get up to $100,000 for your next Flash game with Mochi GAME Developer Fund
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines – 17 lines version
- Sell sitelocked version of your Flash games and even .fla sources to Free Online Games
- Protect your work from ActionScript code theft with SWF Protector
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines
- Understanding Box2D’s one-way platforms, aka CLOUDS
- Triqui MochiAds Arcade plugin for WordPress upgraded to 1.2
- Box2D Flash game creation tutorial – part 2
- 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
- Triqui MochiAds Arcade plugin for WordPress official page
- 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
- Flash game creation tutorial – part 5.2 (4.88/5)
- Create a flash artillery game – step 1 (4.79/5)
- Create a Flash Racing Game Tutorial (4.76/5)
- Create a survival horror game in Flash tutorial – part 1 (4.74/5)
- Create a flash artillery game – step 2 (4.74/5)
- Creation of a Flash arcade site using WordPress – step 2 (4.73/5)
- Flash game creation tutorial – part 1 (4.71/5)
- Flash game creation tutorial – part 2 (4.71/5)
- Create a flash draw game like Line Rider or others – part 1 (4.69/5)
- Creation of a platform game with Flash – step 2 (4.68/5)







WOW! I like this….Real nice…I am so going to do it when I get back home! :D
I like it!
It reminds me of ‘Mutually assured destruction’
wow thanks man this is verry usefull for me :)
How do you actually feel about Kongregate?
Awesome =D!
hey, i was trying to think of a way to do the feature of the ball exploding where the mouse is pressed. I couldn’t do it because i am not as good as Emanuele. Thanks for being phsycic emanuele! =)
i wanted to make a space defence game where the turret was in the middle of the screen. Hey! I just had a great idea. NUCLEAR WAR! the ICBM’s will go to where the mouse clicks! thanks emanuele!!!!!!!!!!!!!!!!!!!!
I think I love you! lol!
Thank you soo much, great tutorials.