Talking about Platform game game, Actionscript 2, Flash and Game development.
For all jumping fanatics out there, I developed the jumping routine.
You can jump hitting SPACE
, hope you like it.
From next post, I’ll start explaining how I developed this script and obviously I will add a lot of tile types.
Now I need some decent pixel art to give the game a polished look.
And don’t forget I am about to translate it into AS3…
tile_size = 20;
ground_acceleration = 1;
ground_friction = 0.8;
air_acceleration = 0.5;
air_friction = 0.7;
ice_acceleration = 0.15;
ice_friction = 0.95;
treadmill_speed = 2;
max_speed = 3;
xspeed = 0;
yspeed = 0;
falling = false;
gravity = 0.5;
jump_speed = 6;
level = new Array();
level[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
level[1] = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
level[2] = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
level[3] = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
level[4] = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 1, 1, 4, 4, 4, 4, 1, 1];
player = [2, 1];
function create_level(l) {
_root.createEmptyMovieClip("level_container",1);
level_height = l.length;
level_width = l[0].length;
for (y=0; ymax_speed) {
xspeed = max_speed;
}
if (xspeed0) {
if ((level[bottom][right] != 0) or (level[bottom][left] != 0)) {
y_pos = bottom*tile_size-9;
yspeed = 0;
falling = false;
jumping = false;
}
}
// collision to the top
if (yspeed<0) {
if ((level[top][right] != 0) or (level[top][left] != 0)) {
y_pos = bottom*tile_size+1+8;
yspeed = 0;
falling = false;
jumping = false;
}
}
x_pos += xspeed;
get_edges();
// collision to the left
if (xspeed<0) {
if ((level[top][left] != 0) or (level[bottom][left] != 0)) {
x_pos = (left+1)*tile_size+6;
xspeed = 0;
}
}
// collision to the right
if (xspeed>0) {
if ((level[top][right] != 0) or (level[bottom][right] != 0)) {
x_pos = right*tile_size-6;
xspeed = 0;
}
}
}
function get_edges() {
// right edge
right = Math.floor((x_pos+5)/tile_size);
// left edge
left = Math.floor((x_pos-6)/tile_size);
// bottom edge
bottom = Math.floor((y_pos+8)/tile_size);
// top edge
top = Math.floor((y_pos-9)/tile_size);
}
Download the source code and enjoy.
Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.