Create a Flash game like Metro Siberia Underground – Part 3
Multipart tutorial: available parts 1, 2, 3, 4 ,5
In the 3rd part I’ll leave the tunnel for a future use and I will introduce some “asteroids”, some “fuel tanks” and the distance traveled so far.
I suggest to read part 1 and 2 before reading this one
It’s not a line-by-line commented tutorial, I am just sharing the source code at the moment, a full explication will come soon
* edit: full explication available
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 | import flash.filters.GlowFilter;
var ship_filter:GlowFilter = new GlowFilter(0x00ff00, 0.8, 4, 4, 2, 3, false, false);
var smoke_filter:GlowFilter = new GlowFilter(0xff0000, 0.8, 4, 4, 2, 3, false, false);
var tunnel_filter:GlowFilter = new GlowFilter(0xffff00, 0.8, 4, 4, 2, 3, false, false);
var fuel_filter:GlowFilter = new GlowFilter(0x00ffff, 0.8, 4, 4, 2, 3, false, false);
var rock_filter:GlowFilter = new GlowFilter(0xffffff, 0.8, 4, 4, 2, 3, false, false);
var score_filter:GlowFilter = new GlowFilter(0xff00ff, 0.8, 2, 4, 2, 3, false, false);
gravity = 0.1;
thrust = 0.25;
yspeed = 0;
xspeed = 5;
distance = 0;
smoke_interval = 10000;
frames_passed = 0;
tunnel_height = 150;
fuel_freq = 10;
gasoline = 500;
rock_freq = 50;
engines = false;
_root.attachMovie("ship", "ship", _root.getNextHighestDepth(), {_x:150, _y:200});
_root.createEmptyMovieClip("fuel_movie", _root.getNextHighestDepth());
_root.createEmptyMovieClip("deadly_movie", _root.getNextHighestDepth());
_root.attachMovie("score", "score", _root.getNextHighestDepth());
ship.filters = new Array(ship_filter);
score.filters = new Array(score_filter);
ship.onEnterFrame = function() {
score.sc.text = "Distance: "+distance+" - "+"Fuel: "+gasoline;
if ((gasoline>0)and(engines)) {
yspeed -= thrust;
smoke_interval -= 0.25;
gasoline -= 1;
}
if (Math.random()*1000<fuel_freq) {
fuel = fuel_movie.attachMovie("fuel", "fuel"+fuel_movie.getNextHighestDepth(), fuel_movie.getNextHighestDepth(), {_x:510, _y:Math.random()*400+50});
fuel.filters = new Array(fuel_filter);
fuel.onEnterFrame = function() {
this._x -= (xspeed*1.2);
dist_x = ship._x+28*Math.cos(angle)-this._x;
dist_y = ship._y+28*Math.sin(angle)-this._y;
dist = Math.sqrt(dist_x*dist_x+dist_y*dist_y);
if (dist<10) {
gasoline += 100;
this.removeMovieClip();
}
if (this._x<-10) {
this.removeMovieClip();
}
};
}
if (Math.random()*1000<rock_freq) {
rock = deadly_movie.attachMovie("rock", "rock"+deadly_movie.getNextHighestDepth(), deadly_movie.getNextHighestDepth(), {_x:510, _y:Math.random()*400+50, _rotation:Math.random()*360});
rock.filters = new Array(rock_filter);
rock.onEnterFrame = function() {
this._x -= xspeed;
if (this._x<-10) {
this.removeMovieClip();
}
};
}
yspeed += gravity;
this._y += yspeed;
angle = Math.atan2(yspeed, xspeed);
this._rotation = angle*180/Math.PI;
frames_passed++;
distance += xspeed;
if (frames_passed>=smoke_interval) {
sm = _root.attachMovie("smoke", "smoke"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:this._x-2, _y:this._y});
sm.filters = new Array(smoke_filter);
sm.onEnterFrame = function() {
this._x -= xspeed;
this._width += 0.2;
this._height += 0.2;
this._alpha -= 2;
if (this._alpha<=0) {
this.removeMovieClip();
}
};
frames_passed = 0;
}
if ((this._y>400) or (this._y<0) or deadly_movie.hitTest(this._x+28*Math.cos(angle), this._y+28*Math.sin(angle), true) or deadly_movie.hitTest(this._x+8*Math.cos(angle+Math.PI/2), this._y+8*Math.sin(angle+Math.PI/2), true) or deadly_movie.hitTest(this._x+8*Math.cos(angle-Math.PI/2), this._y+8*Math.sin(angle-Math.PI/2), true)) {
yspeed = 0;
this._y = 200;
gasoline = 500;
distance = 0;
deadly_movie.removeMovieClip();
fuel_movie.removeMovieClip();
_root.createEmptyMovieClip("fuel_movie", _root.getNextHighestDepth());
_root.createEmptyMovieClip("deadly_movie", _root.getNextHighestDepth());
}
};
_root.onMouseDown = function() {
engines = true;
smoke_interval = 10;
};
_root.onMouseUp = function() {
engines = false;
smoke_interval = 100000;
}; |
And this is the result. White blocks are deadly while blue circles raise your fuel.
Download the source code and tell me what do you think about it.
Multipart tutorial: available parts 1, 2, 3, 4 ,5
They can be easily customized to meet the unique requirements of your project.
11 Responses to “Create a Flash game like Metro Siberia Underground – Part 3”
Leave a Reply
Trackbacks
-
Create a Flash game like Metro Siberia Underground - Part 4 : Emanuele Feronato - italian geek and PROgrammer on
February 5th, 2008 5:14 pm
[...] this 4th part I’ll cover the code written in 3rd part. You should read parts 1 and 2 too, because I will comment only the new code. For a better [...]
-
Create a Flash game like Metro Siberia Underground - Part 5 : Emanuele Feronato - italian geek and PROgrammer on
February 13th, 2008 6:54 pm
[...] tutorial: available parts 1, 2, 3, 4 [...]
-
Create a Flash game like Metro Siberia Underground - Part 2 : Emanuele Feronato - italian geek and PROgrammer on
February 13th, 2008 6:56 pm
[...] tutorial: available parts 1, 2, 3, 4 [...]
-
Create a Flash game like Metro Siberia Underground : Emanuele Feronato - italian geek and PROgrammer on
February 13th, 2008 6:57 pm
[...] tutorial: available parts 1, 2, 3, 4 [...]
- 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)





Awesome. I was trying to do it but wasn’t getting it to work. Keep up the great work!
Cool.
I got to about 14k distance before I ran out of fuel and couldn’t grab any more. =\
doode!
I’ve been trying to submit my game to you like it recommends in the support this blog section but i cant find how. anyway, if you didnt see a comment i made earlier, I’ve used these tutorials to make this game here
http://galacticflashgames.com/games/bumblebee.php
and would love to get some feedback on it. I actually did it before part 3 came out, and i sort of invented my own ‘fuel’ system, but in the case of this game, pollen is your fuel
the distancemeter <3
No offense Emanuele. Most of your tutorials have helped me immensly. But this one doesnt seem to meet the par. It is more suited for those of more expeience with flash. What about us? The noobs. What happened to the step by step instructions that helped me out so much on other tutorials. I am sorry if that seemed a bit harsh….I have been working on this game with no avail for several weaks.
15k. i beat you all!!! MWHAHAHAHAHA
5/5. but can you make a shooter tutorial, where you have to shoot something and then it reappears somewhere else. ty anyway.