home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Puzzle
/
blockix.swf
/
scripts
/
frame_1
/
DoAction.as
Wrap
Text File
|
2008-09-26
|
20KB
|
583 lines
function start_game()
{
if(actual_level == 0)
{
nr_of_foes = 2;
}
move_direction = -1;
next_move_direction = -1;
z = 0;
while(z < nr_of_foes)
{
toremove = _root[3023 + z];
toremove.removeMovieClip();
z++;
}
game_running = true;
map.clear();
fixed_map.clear();
z = 0;
while(z < 51)
{
map[z] = new Array(51);
fixed_map[z] = new Array(51);
z++;
}
dx = 0;
while(dx < 51)
{
dy = 0;
while(dy < 51)
{
map[dx][dy] = 0;
fixed_map[dx][dy] = 0;
dy++;
}
dx++;
}
plox = 51;
ploy = 51;
tx = 0;
while(tx < 12)
{
ty = 0;
while(ty < 12)
{
if(level_map[actual_level % max_level][tx][ty] == 2)
{
level_map[actual_level % max_level][tx][ty] = 1;
}
if(level_map[actual_level % max_level][tx][ty] == 1)
{
z = 0;
while(z < 5)
{
map[1 + tx * 4 + z][1 + ty * 4] = 3;
map[1 + tx * 4 + z][1 + ty * 4 + 4] = 3;
map[1 + tx * 4][1 + ty * 4 + z] = 3;
map[1 + tx * 4 + 4][1 + ty * 4 + z] = 3;
z++;
}
}
ty++;
}
tx++;
}
ehix = 0;
ehiy = 0;
total_blocks_to_go = 0;
dx = 1;
while(dx < 50)
{
dy = 1;
while(dy < 50)
{
if(map[dx][dy] != 0)
{
total_blocks_to_go++;
if(dx < plox)
{
plox = dx;
}
if(dy < ploy)
{
ploy = dy;
}
if(dx > ehix)
{
ehix = dx;
}
if(dy > ehiy)
{
ehiy = dy;
}
a = 0;
if(map[dx][dy - 1] != 0)
{
a += 1;
}
if(map[dx + 1][dy] != 0)
{
a += 2;
}
if(map[dx][dy + 1] != 0)
{
a += 4;
}
if(map[dx - 1][dy] != 0)
{
a += 8;
}
switch(a)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
map[dx][dy] = 7;
break;
case 4:
break;
case 5:
map[dx][dy] = 2;
break;
case 6:
map[dx][dy] = 4;
break;
case 7:
map[dx][dy] = 9;
break;
case 8:
break;
case 9:
map[dx][dy] = 6;
break;
case 10:
map[dx][dy] = 1;
break;
case 11:
map[dx][dy] = 8;
break;
case 12:
map[dx][dy] = 5;
break;
case 13:
map[dx][dy] = 11;
break;
case 14:
map[dx][dy] = 10;
break;
case 15:
map[dx][dy] = 3;
}
}
dy++;
}
dx++;
}
enemy_directions = new Array();
ego._x = -5 + plox * 10;
ego._y = -5 + ploy * 10;
ehix = -5 + ehix * 10;
ehiy = -5 + ehiy * 10;
z = 0;
while(z < nr_of_foes)
{
enemy_directions[z] = random(4);
z++;
}
dx = 0;
while(dx < 50)
{
dy = 0;
while(dy < 50)
{
show_map(dx,dy);
dy++;
}
dx++;
}
z = 0;
while(z < nr_of_foes)
{
_root.attachMovie("enemy",3023 + z,_root.getNextHighestDepth(),{_x:ehix,_y:ehiy});
z++;
}
}
function show_map(dx, dy)
{
todel = _root[dx + dy * 50];
todel.removeMovieClip();
switch(map[dx][dy])
{
case 1:
_root.attachMovie("hz_line",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 2:
_root.attachMovie("vt_line",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 3:
_root.attachMovie("intersection",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 4:
_root.attachMovie("lo_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 5:
_root.attachMovie("ro_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 6:
_root.attachMovie("ru_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 7:
_root.attachMovie("lu_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 8:
_root.attachMovie("t_top",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 9:
_root.attachMovie("t_right",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 10:
_root.attachMovie("t_down",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 11:
_root.attachMovie("t_left",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 17:
_root.attachMovie("hz_double_line",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 18:
_root.attachMovie("vt_double_line",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 19:
_root.attachMovie("double_intersection",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 20:
_root.attachMovie("lo_double_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 21:
_root.attachMovie("ro_double_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 22:
_root.attachMovie("ru_double_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 23:
_root.attachMovie("lu_double_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 24:
_root.attachMovie("t_double_top",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 25:
_root.attachMovie("t_double_right",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 26:
_root.attachMovie("t_double_down",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
break;
case 27:
_root.attachMovie("t_double_left",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
}
}
map = new Array(51);
score = 0;
fixed_map = new Array(51);
action_timer = 5;
game_running = false;
total_blocks_to_go = 0;
actual_level = 0;
max_level = 12;
move_direction = -1;
ehix = 0;
ehiy = 0;
lives = 3;
nr_of_foes = 3;
next_move_direction = -1;
step = 4;
muted = false;
is_pause = false;
level_map = [[[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,0,1,1,0,1,0,0,0],[0,0,0,0,1,1,1,1,0,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,0,1,1,1,1,0,0,0,0],[0,0,0,1,0,1,1,0,1,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,1,1,1,0,0,0],[0,0,0,1,1,1,1,1,1,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,1,1,1,1,1,1,0,0,0],[0,0,0,1,1,1,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,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,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[0,0,0,1,0,1,0,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,1,1,1,1,1,1,1,1,0,0],[0,0,1,1,1,1,1,1,1,1,0,0],[0,0,1,1,0,0,0,0,1,1,0,0],[0,0,1,1,0,0,0,0,1,1,0,0],[0,0,1,1,0,0,0,0,1,1,0,0],[0,0,1,1,0,0,0,0,1,1,0,0],[0,0,1,1,1,1,1,1,1,1,0,0],[0,0,1,1,1,1,1,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,0,0,0,0]]];
_root.kongregateServices.connect();
swush_sound = new Sound();
swush_sound.attachSound("swush.wav");
palim_sound = new Sound();
palim_sound.attachSound("palim.wav");
palim_sound.start(0,1);
krck_sound = new Sound();
krck_sound.attachSound("krck.wav");
keyListener = new Object();
keyListener.onKeyDown = function()
{
var _loc1_ = Key.getCode();
switch(_loc1_)
{
case 77:
case 109:
muted = !muted;
break;
case 115:
case 83:
lives = 3;
start_game();
break;
case 113:
case 80:
if(is_pause == false && game_running)
{
is_pause = true;
game_running = false;
}
else if(is_pause)
{
is_pause = false;
game_running = true;
}
}
if(game_running == true)
{
switch(_loc1_)
{
case 39:
next_move_direction = 1;
if(move_direction == 3)
{
move_direction = 1;
}
break;
case 40:
next_move_direction = 2;
if(move_direction == 0)
{
move_direction = 2;
}
break;
case 37:
next_move_direction = 3;
if(move_direction == 1)
{
move_direction = 3;
}
break;
case 38:
next_move_direction = 0;
if(move_direction == 2)
{
move_direction = 0;
}
}
}
};
Key.addListener(keyListener);
this.onEnterFrame = function()
{
if(game_running)
{
step--;
if(step == 0)
{
z = 0;
while(z < nr_of_foes)
{
actual_enemy = _root[3023 + z];
ox = (actual_enemy._x + 5) / 10;
oy = (actual_enemy._y + 5) / 10;
step = 3;
if(map[ox][oy] != 1 && map[ox][oy] != 2 && random(4) == 0)
{
enemy_directions[z] = random(4);
}
switch(enemy_directions[z])
{
case 0:
if(map[ox][oy - 1] != 0)
{
oy -= 1;
}
else
{
enemy_directions[z] = random(4);
}
break;
case 1:
if(map[ox + 1][oy] != 0)
{
ox += 1;
}
else
{
enemy_directions[z] = random(4);
}
break;
case 2:
if(map[ox][oy + 1] != 0)
{
oy += 1;
}
else
{
enemy_directions[z] = random(4);
}
break;
case 3:
if(map[ox - 1][oy] != 0)
{
ox -= 1;
}
else
{
enemy_directions[z] = random(4);
}
}
if(map[ox][oy] > 16 && fixed_map[ox][oy] == 0)
{
total_blocks_to_go++;
map[ox][oy] -= 16;
}
show_map(ox,oy);
actual_enemy._x = -5 + ox * 10;
actual_enemy._y = -5 + oy * 10;
z++;
}
}
}
if(game_running)
{
moved = false;
ox = (ego._x + 5) / 10;
oy = (ego._y + 5) / 10;
if(map[ox][oy] != 1 && map[ox][oy] != 2 && map[ox][oy] != 17 && map[ox][oy] != 18)
{
move_direction = next_move_direction;
}
switch(move_direction)
{
case 1:
if(map[ox + 1][oy] != 0)
{
ego._x += 10;
moved = true;
}
break;
case 2:
if(map[ox][oy + 1] != 0)
{
ego._y += 10;
moved = true;
}
break;
case 3:
if(map[ox - 1][oy] != 0)
{
ego._x -= 10;
moved = true;
}
break;
case 0:
if(map[ox][oy - 1] != 0)
{
ego._y -= 10;
moved = true;
}
}
if(moved)
{
if(map[ox][oy] < 16)
{
map[ox][oy] += 16;
total_blocks_to_go--;
}
show_map(ox,oy);
tx = 0;
while(tx < 12)
{
ty = 0;
while(ty < 12)
{
if(level_map[actual_level % max_level][tx][ty] == 1)
{
a = 0;
z = 0;
while(z < 5)
{
if(map[1 + tx * 4 + z][1 + ty * 4] > 16)
{
a++;
}
if(map[1 + tx * 4 + z][1 + ty * 4 + 4] > 16)
{
a++;
}
if(map[1 + tx * 4][1 + ty * 4 + z] > 16)
{
a++;
}
if(map[1 + tx * 4 + 4][1 + ty * 4 + z] > 16)
{
a++;
}
z++;
}
if(a == 20)
{
level_map[actual_level % max_level][tx][ty] = 2;
score += actual_level + 1;
z = 0;
while(z < 5)
{
fixed_map[1 + tx * 4 + z][1 + ty * 4] = 1;
fixed_map[1 + tx * 4 + z][1 + ty * 4 + 4] = 1;
fixed_map[1 + tx * 4][1 + ty * 4 + z] = 1;
fixed_map[1 + tx * 4 + 4][1 + ty * 4 + z] = 1;
z++;
}
if(!muted)
{
swush_sound.start(0,1);
}
dx = 1;
while(dx < 4)
{
dy = 1;
while(dy < 4)
{
_root.attachMovie("fixed_tile_bg",1 + tx * 4 + dx + (1 + dy + ty * 4) * 50,_root.getNextHighestDepth(),{_x:-5 + (1 + dx + tx * 4) * 10,_y:-5 + (1 + dy + ty * 4) * 10});
dy++;
}
dx++;
}
}
}
ty++;
}
tx++;
}
}
}
if(total_blocks_to_go == 0 && game_running)
{
actual_level++;
if(actual_level % max_level == 0)
{
nr_of_foes++;
}
if((actual_level & 3) == 0)
{
lives++;
}
start_game();
_root.kongregateStats.submit("maxLevel",actual_level);
_root.kongregateStats.submit("maxScore",score);
}
if(game_running)
{
ox = (ego._x + 5) / 10;
oy = (ego._y + 5) / 10;
z = 0;
while(z < nr_of_foes)
{
actual_enemy = _root[3023 + z];
ex = (actual_enemy._x + 5) / 10;
ey = (actual_enemy._y + 5) / 10;
if(ex == ox && ey == oy && game_running)
{
lives--;
if(!muted)
{
krck_sound.start(0,1);
}
if(lives == 0)
{
game_running = false;
score = 0;
}
else
{
start_game();
}
}
z++;
}
}
};