///////////////////////////////////////////////////////////////
//name:
// Hangman's escape
//
//scrpt type:
// one scrpt game
//
//autor:
// Ben Strasser alias Dr.Voodoo
//
//remarque:
// Put this scrpt in the room creation code, creation event,
// begin/end step event, step event, game start event, room
// start event or the draw event (only in one)
//
//remarque2:
// Use standard GM settings
//
//copyright:
// Ben Strasser
//
///////////////////////////////////////////////////////////////
game_end();
full_screen=1;
screen_width=monitor_width;
screen_height=monitor_height;
scale_full=100;
show_score=false;
show_cursor=false;
tun=2;
end_loop=1;
pre_seconde=current_second;
fps_counter=0;
fps_loop=1;
pre_time=current_time;
state='Main';
cursor_type='normal';
//
while(end_loop)
{
if keyboard_check(vk_escape)
{
state='Gameend';
io_clear();
io_handle()
};
if keyboard_check(vk_shift)
{
end_loop=0
};
fps_counter+=1;
if pre_seconde!=current_second
{
fps_loop=fps_counter;
fps_counter=0;
};
pre_seconde=current_second;
pre_time=current_time;
//***Main***
if state=='Main'
{
brush_color=c_black;
pen_color=c_black;
draw_rectangle(0,0,screen_width,screen_height);
font_size = screen_width/1024*80;
font_color = c_white;
font_align = fa_center;
font_style = fs_bold;
font_name = 'Comic Sans MS';
Y=5;
draw_text(screen_width/2,Y,"Hangman's escape");
Y+=string_height('M');
font_size = screen_width/1024*20;
draw_text(screen_width/2,Y,'by Ben Strasser alias Dr.Voodoo');
Y+=string_height('M');
font_size = screen_width/1024*50;
draw_text(screen_width/2,Y,'Start Game');
Y+=string_height('M');
draw_text(screen_width/2,Y,'Help');
Y+=string_height('M');
draw_text(screen_width/2,Y,'Web');
Y+=string_height('M');
draw_text(screen_width/2,Y,'Exit');
font_size=screen_width/1024*80;
Y=5+string_height('M');
font_size=screen_width/1024*20;
Y+=string_height('M');
font_size=screen_width/1024*50;
if mouse_y>Y&&mouse_y<Y+string_height('M')
{
font_color=c_red;
draw_text(screen_width/2,Y,'Start Game');
if mouse_check_button(mb_left)
{
mouse_clear(mb_left);
state='Gameini'
};
};
Y+=string_height('M');
if mouse_y>Y&&mouse_y<Y+string_height('M')
{
font_color=c_red;
draw_text(screen_width/2,Y,'Help');
if mouse_check_button(mb_left)
{
state='Help';
mouse_clear(mb_left)
};
}
Y+=string_height('M');
if mouse_y>Y&&mouse_y<Y+string_height('M')
{
font_color=c_red;
draw_text(screen_width/2,Y,'Web');
if mouse_check_button(mb_left)
{
file_open_write(temp_directory+'\URL.url');
file_write_string('[InternetShortcut]');file_writeln();
file_write_string('URL=http://de.geocities.com/ben0032003/');file_close();
execute_shell(temp_directory+'\URL.url','');
end_loop=0
};
};
Y+=string_height('M');
if mouse_y>Y&&mouse_y<Y+string_height('M')
{
font_color=c_red;
draw_text(screen_width/2,Y,'Exit');
if mouse_check_button(mb_left)
end_loop=0;
}
if mouse_check_button(mb_left)
mouse_clear(mb_left)
};
//***Gameend***
if state=='Gameend'
{
cursor_type='normal';
//scale_full=100;
screen_width=monitor_width;
screen_height=monitor_height;
state='Main';
};
//***Help***
if state=='Help'
{
brush_color=c_black;
pen_color=c_black;
draw_rectangle(0,0,screen_width,screen_height);
font_size = screen_width/1024*25;
font_color = c_white;
font_align = fa_left;
font_style = fs_bold;
font_name = 'Comic Sans MS';
draw_text_ext(20,5,"Hangman doesn't want to get hanged so he's running away. Use the left and right arrow keys to run, the up arrow key to jump, space to show or hide the fps and ESC to end the game. After some levels his escape will be discovered and people will start looking for him. You can only try to avoid them.#Hangman's escape is designed to run at a speed of 32fps#Hangman's escape
Ben Strasser 2003.#This program was written by Ben Strasser.#Gamemaker
Mark Overmars 1999-2002.#
www.gamemaker.nl",string_height('M'),screen_width-40)if mouse_check_button(mb_left)
{
state='Main'
mouse_clear(mb_left)
}
};
//***Gameini***
if state=='Gameini'
{
screen_width=640;
screen_height=480;
cursor_type='none';
show_fps=1;
clouds=0;
cols=0;
x=0;
y=1000;
hspeed=0;
vspeed=0;
faster=2;
max_speed=10;
friction=1;
gravity=0.5;
wall[0,0]=0;
door_X=0;
door_Y=0;
monsters=0;
level=1;
X=0;
Y=0;
door_X=0;
door_Y=0;
state='Game'
};
//***Game***
if state=='Game'
{
//levels data begin
if (X==door_X&&Y==door_Y)||y>480
{
X=0;
Y=0;
repeat(20*15)
{
wall[X,Y]=0;
X+=1;
if X==20
{
X=0;
Y+=1
}
};
if y<=480 level+=1;
if level==6
level=1;
if level==1
{
//---level1---
monsters=0;
x=32*4+8;
y=32*11+32-24;
hspeed=0;
vspeed=0;
faster=2;
max_speed=10;
friction=1;
gravity=0.5;
wall[0,0]=0;
wall[1,12]=1;
wall[2,12]=1;
wall[3,12]=1;
wall[4,12]=1;
wall[5,12]=1;
wall[6,12]=1;
wall[7,12]=1;
wall[8,12]=1;
wall[9,12]=1;
wall[10,12]=1;
wall[11,12]=1;
wall[12,12]=1;
wall[13,12]=1;
wall[14,12]=1;
wall[15,12]=1;
wall[16,12]=1;
wall[17,12]=1;
wall[18,12]=1;
wall[4,2]=1;
wall[5,2]=1;
wall[6,2]=1;
wall[9,4]=1;
wall[10,4]=1;
wall[11,4]=1;
wall[16,5]=1;
wall[17,5]=1;
wall[18,5]=1;
wall[10,7]=1;
wall[11,7]=1;
wall[12,7]=1;
wall[3,8]=1;
wall[4,8]=1;
wall[5,8]=1;
wall[7,10]=1;
wall[8,10]=1;
wall[9,10]=1;
door_X=5;
door_Y=1;
//---Level1---
};
if level==2
{
//---level2---
monsters=0;
x=32*18+8;
y=32*11+32-24;
hspeed=0;
vspeed=0;
faster=2;
max_speed=10;
friction=1;
gravity=0.5;
wall[1,12]=1;
wall[2,12]=1;
wall[3,12]=1;
wall[4,12]=1;
wall[5,12]=1;
wall[6,12]=1;
wall[7,12]=1;
wall[8,12]=1;
wall[9,12]=1;
wall[10,12]=1;
wall[11,12]=1;
wall[12,12]=1;
wall[13,12]=1;
wall[14,12]=1;
wall[15,12]=1;
wall[16,12]=1;
wall[17,12]=1;
wall[18,12]=1;
wall[1,9]=1;
wall[2,9]=1;
wall[3,9]=1;
wall[11,7]=1;
wall[12,7]=1;
wall[13,7]=1;
wall[16,4]=1;
wall[17,4]=1;
wall[18,4]=1;
door_X=17;
door_Y=3;
//---Level2---
};
if level==3
{
//---level3---
monsters=0;
x=32*17+8;
y=32*1+32-24;
hspeed=0;
vspeed=0;
faster=2;
max_speed=10;
friction=1;
gravity=0.5;
wall[1,2]=1;
wall[2,2]=1;
wall[3,2]=1;
wall[6,2]=1;
wall[7,2]=1;
wall[8,2]=1;
wall[11,2]=1;
wall[12,2]=1;
wall[13,2]=1;
wall[16,2]=1;
wall[17,2]=1;
wall[18,2]=1;
wall[3,5]=1;
wall[4,5]=1;
wall[5,5]=1;
wall[6,5]=1;
wall[8,5]=1;
wall[9,5]=1;
wall[10,5]=1;
wall[11,5]=1;
wall[13,5]=1;
wall[14,5]=1;
wall[15,5]=1;
wall[16,5]=1;
wall[4,11]=1;
wall[5,11]=1;
wall[6,11]=1;
wall[3,13]=1;
wall[4,13]=1;
wall[5,13]=1;
wall[6,13]=1;
wall[7,13]=1;
door_X=5;
door_Y=12;
//---Level3---
};
if level==4
{
//---level4---
monsters=5;
monster_x[1]=32*8+8;
monster_y[1]=32*11+32-24;
monster_hspeed[1]=3;
monster_actif[1]=1;
monster_x[2]=32*8+8;
monster_y[2]=32*11+32-24;
monster_hspeed[2]=-3;
monster_actif[2]=1;
monster_x[3]=32*7+8;
monster_y[3]=32*9+32-24;
monster_hspeed[3]=3;
monster_actif[3]=1;
monster_x[4]=32*11+8;
monster_y[4]=32*6+32-24;
monster_hspeed[4]=3;
monster_actif[4]=1;
monster_x[5]=32*10+8;
monster_y[5]=32*3+32-24;
monster_hspeed[5]=3;
monster_actif[5]=1;
x=32*4+8;
y=32*11+32-24;
hspeed=0;
vspeed=0;
faster=2;
max_speed=10;
friction=1;
gravity=0.5;
wall[0,0]=0;
wall[1,12]=1;
wall[2,12]=1;
wall[3,12]=1;
wall[4,12]=1;
wall[5,12]=1;
wall[6,12]=1;
wall[7,12]=1;
wall[8,12]=1;
wall[9,12]=1;
wall[10,12]=1;
wall[11,12]=1;
wall[12,12]=1;
wall[13,12]=1;
wall[14,12]=1;
wall[15,12]=1;
wall[16,12]=1;
wall[17,12]=1;
wall[18,12]=1;
wall[4,2]=1;
wall[5,2]=1;
wall[6,2]=1;
wall[9,4]=1;
wall[10,4]=1;
wall[11,4]=1;
wall[16,5]=1;
wall[17,5]=1;
wall[18,5]=1;
wall[10,7]=1;
wall[11,7]=1;
wall[12,7]=1;
wall[3,8]=1;
wall[4,8]=1;
wall[5,8]=1;
wall[7,10]=1;
wall[8,10]=1;
wall[9,10]=1;
door_X=5;
door_Y=1;
//---Level4---
};
if level==5
{
//---level5---
monsters=7;
monster_x[1]=32*5+8;
monster_y[1]=32*10+32-24;
monster_hspeed[1]=3;
monster_actif[1]=1;
monster_x[2]=32*7+8;
monster_y[2]=32*8+32-24;
monster_hspeed[2]=3;
monster_actif[2]=1;
monster_x[3]=32*9+8;
monster_y[3]=32*6+32-24;
monster_hspeed[3]=-3;
monster_actif[3]=1;
monster_x[4]=32*11+8;
monster_y[4]=32*4+32-24;
monster_hspeed[4]=3;
monster_actif[4]=1;
monster_x[5]=32*13+8;
monster_y[5]=32*2+32-24;
monster_hspeed[5]=3;
monster_actif[5]=1;
monster_x[6]=32*16+8;
monster_y[6]=32*4+32-24;
monster_hspeed[6]=3;
monster_actif[6]=1;
monster_x[7]=32*17+8;
monster_y[7]=32*6+32-24;
monster_hspeed[7]=3;
monster_actif[7]=1;
x=32*3+8;
y=32*12+32-24;
hspeed=0;
vspeed=0;
faster=2;
max_speed=10;
friction=1;
gravity=0.5;
wall[2,13]=1;
wall[3,13]=1;
wall[4,13]=1;
wall[4,11]=1;
wall[5,11]=1;
wall[6,11]=1;
wall[6,9]=1;
wall[7,9]=1;
wall[8,9]=1;
wall[8,7]=1;
wall[9,7]=1;
wall[10,7]=1;
wall[10,5]=1;
wall[11,5]=1;
wall[12,5]=1;
wall[12,3]=1;
wall[13,3]=1;
wall[14,3]=1;
wall[15,5]=1;
wall[16,5]=1;
wall[17,5]=1;
wall[16,7]=1;
wall[17,7]=1;
wall[18,7]=1;
wall[14,9]=1;
wall[15,9]=1;
wall[16,9]=1;
door_X=15;
door_Y=8;
//---Level5---
}
};
//levels data end
while(pre_time==current_time)
{
pre_time=current_time;
sleep(1);
};
brush_color=make_color(0,0,124);
pen_color=brush_color;
draw_rectangle(0,0,screen_width,screen_height);
temp=1;
repeat(clouds)
{
pen_color=c_black;
brush_color=c_white;
draw_ellipse(cloud_x[temp],cloud_y[temp],cloud_x[temp]+cloud_size[temp],cloud_y[temp]+cloud_size[temp]/2);
cloud_x[temp]+=cloud_speed[temp];
if cloud_x[temp]>screen_width
{
temp2=temp;
repeat(clouds-temp)
{
cloud_x[temp2]=cloud_x[temp2+1];
cloud_y[temp2]=cloud_y[temp2+1]
cloud_speed[temp2]=cloud_speed[temp2+1];
cloud_size[temp2]=cloud_size[temp2+1];
temp2+=1
};
clouds-=1
}
else
temp+=1
};
temp=1;
repeat(cols)
{
pen_color=c_black;
brush_color=c_green;
draw_triangle(col_x[temp],col_y[temp],col_x[temp]-(screen_height-col_y[temp]),screen_height+1,col_x[temp]+(screen_height-col_y[temp]),screen_height+1);
col_x[temp]+=col_speed[temp];
if col_x[temp]-(screen_height-col_y[temp])>screen_width
{
temp2=temp;
repeat(cols-temp)
{
col_x[temp2]=col_x[temp2+1];
col_y[temp2]=col_y[temp2+1]
col_speed[temp2]=col_speed[temp2+1];
temp2+=1
};
cols-=1
}
else
temp+=1
};
if floor(random(24*tun))==0
{
clouds+=1;
cloud_size[clouds]=floor(random(40))+10;
cloud_y[clouds]=floor(random(screen_height-cloud_size[clouds]/2))
cloud_x[clouds]=-cloud_size[clouds];
cloud_speed[clouds]=cloud_size[clouds]/8
};
if floor(random(35*tun))==0
{
cols+=1;
col_y[cols]=floor(random(screen_height/2))+screen_height/2;
col_x[cols]=-col_y[cols];
col_speed[cols]=6;
};
//blocks
X=0;
Y=0;
repeat(20*15)
{
if wall[X,Y]
{
brush_color=make_color(70,69,60);
pen_color=brush_color;
draw_rectangle(X*32,Y*32,(X+1)*32,(Y+1)*32);
if X!=0
if wall[X,Y-1]==0
{
brush_color=make_color(0,124*1.5,0);
pen_color=brush_color;
draw_rectangle(X*32,Y*32,(X+1)*32,Y*32+10);
}
};
X+=1
if X==20
{
X=0;
Y+=1
}
};
//door
brush_color=c_black;
pen_color=c_black;
X=door_X*32;
Y=door_Y*32;
draw_ellipse(X,Y,X+32,Y+32);
draw_rectangle(X,Y+16,X+32,Y+32);
//monsters
temp=1;
repeat(monsters)
{
if monster_actif[temp]==1
{
X=floor((monster_x[temp]+8)/32);
if X<0
X=0;
if X>19
X=19;
Y=floor((monster_y[temp])/32);
if Y<0
Y=0;
if Y>14
Y=14;
if wall[X,Y+1]==false
monster_hspeed[temp]=-monster_hspeed[temp];
pen_color=c_black;
draw_line(monster_x[temp],monster_y[temp]+24,monster_x[temp]+8,monster_y[temp]+16)
draw_line(monster_x[temp]+8,monster_y[temp]+16,monster_x[temp]+16,monster_y[temp]+24)
draw_line(monster_x[temp]+8,monster_y[temp]+16,monster_x[temp]+8,monster_y[temp]+8)
draw_line(monster_x[temp],monster_y[temp]+16,monster_x[temp]+8,monster_y[temp]+8)
draw_line(monster_x[temp]+8,monster_y[temp]+8,monster_x[temp]+16,monster_y[temp]+16)
brush_color=make_color(255,0,0)
draw_rectangle(monster_x[temp]+4,monster_y[temp]+8,monster_x[temp]+12,monster_y[temp]);
monster_x[temp]+=monster_hspeed[temp];
if x+8>monster_x[temp]-4&&x+8<monster_x[temp]+20&&y+8>monster_y[temp]+7&&y+8<monster_y[temp]+16
y=1000
};
temp+=1;
};
//player
pen_color=c_black;
draw_line(x,y+24,x+8,y+16)
draw_line(x+8,y+16,x+16,y+24)
draw_line(x+8,y+16,x+8,y+8)
draw_line(x,y+16,x+8,y+8)
draw_line(x+8,y+8,x+16,y+16)
brush_color=make_color(255,128,0)
draw_rectangle(x+4,y+8,x+12,y);
x+=hspeed;
y+=vspeed;
X=floor((x+8)/32);
if X<0
X=0;
if X>19
X=19;
Y=floor((y)/32);
if Y<0
Y=0;
if Y>13
Y=13;
if wall[X,Y+1]
{
if abs(hspeed)>friction
{
hspeed-=friction*sign(hspeed)
}
else
hspeed=0;
if keyboard_lastkey==vk_left
{
hspeed-=faster;
if hspeed<-max_speed
hspeed=-max_speed
};
if keyboard_lastkey==vk_right
{
hspeed+=faster
if hspeed>max_speed
hspeed=max_speed
};
vspeed=0;
y=Y*32+32-24
if keyboard_lastkey==vk_up
vspeed=-9
}
else
vspeed+=gravity;
if keyboard_key==vk_nokey
keyboard_lastkey=vk_nokey;
if keyboard_check(vk_space)
{
show_fps=!show_fps;
keyboard_clear(vk_space);
io_handle()
};
if show_fps
{
brush_color=c_white;
pen_color=c_black;
font_name='Arial';
font_size=10;
font_color=c_black;
font_align=fa_left;
draw_rectangle(0,0,string_width('fps='+string(fps_loop)+' Level='+string(level)+' Hit ESC to exit.')+10,string_height('M')+10)
draw_text(5,5,'fps='+string(fps_loop)+' Level='+string(level)+' Hit ESC to exit.')
}
};
if cursor_type=='normal'
{
brush_color=make_color(100,100,100)
pen_color=c_black;
draw_triangle(mouse_x,mouse_y,mouse_x+20,mouse_y+20,mouse_x+20,mouse_y+40)
brush_color=make_color(200,200,200);
draw_triangle(mouse_x,mouse_y,mouse_x+20,mouse_y+20,mouse_x+40,mouse_y+20)
brush_color=make_color(150,150,150);
draw_triangle(mouse_x+20,mouse_y+40,mouse_x+20,mouse_y+20,mouse_x+40,mouse_y+20);
};
screen_refresh();
};