Simple Flash Game Tutorial #1
Posted: Sat Jun 05, 2010 9:03 pm
Hello and welcome to my tutorial on building a simple flash game.
In this video we write the movement script. Some code got a bit cut of sorry so its all at the bottom.
[youtube]http://www.youtube.com/watch?v=0Bh1L6Owneo[/youtube]
[youtube]http://www.youtube.com/watch?v=N3ynh6yC4gI[/youtube]
Here is the code:
Actions on frame 1:
Actions on our player movie clip:
In this video we write the movement script. Some code got a bit cut of sorry so its all at the bottom.
[youtube]http://www.youtube.com/watch?v=0Bh1L6Owneo[/youtube]
[youtube]http://www.youtube.com/watch?v=N3ynh6yC4gI[/youtube]
Here is the code:
Actions on frame 1:
Code: Select all
stop();Code: Select all
onClipEvent (load) {
power = 0.3;
yspeed = 0;
xspeed = 0;
friction = 0.97;
gravity = 0.05;
thrust = 0.6;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed += power;
}
if (Key.isDown(Key.UP)) {
yspeed -= power*thrust;
}
if (Key.isDown(Key.DOWN)) {
yspeed += power*thrust;
}
xspeed *= friction;
yspeed += gravity;
_y += yspeed;
_x += xspeed;
}