#include "sound_positioning.bgt"
sound woosh;
sound target;
sound hit;
sound punch;
sound step;
sound music;
sound hit2;
sound lose;
sound extralife;
timer targethit;
timer getextralife;
int lifes;
int targetpos;
int pos;
int points;
int misses;
int punchies;
int hits;
tts_voice v;
void main()
{
target.stop();
woosh.load("sounds/woosh.ogg");
punch.load("sounds/punch.ogg");
music.load("sounds/music.wav");
music.play_looped();
hit2.load("sounds/targethityou.wav");
lose.load("sounds/lose.wav");
extralife.load("sounds/extralife.wav");
show_game_window("Welcome to man killer! Version 1.0. Ritten by anton zabrodskijj(Sky soft). Press enter, to start. Or escape, to quit. For more information, read file readme.txt");
while(true)
{
if(key_pressed(KEY_RETURN))
{
game();
}
if(key_pressed(KEY_ESCAPE))
{
exit();
}
}
}
void game()
{
lifes=3;
hits=0;
misses=0;
punchies=0;
targetpos=random(1,19);
pos=10;
points=0;
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
show_game_window("Go!");
while(true)
{
if(key_down(KEY_HOME))
{
music    .volume = music.volume + 0.5;
wait(5);
}
if(key_down(KEY_END))
{
music.volume = music.volume-0.5;
wait(5);
}
if(key_pressed(KEY_SPACE))
{
if(pos < targetpos)
{
woosh.play();
wait(50);
misses+=1;
show_game_window("MISSED!");
punchies+=1;
if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
}
if(pos > targetpos)
{
woosh.play();
wait(50);
misses+=1;
show_game_window("MISSED!");
punchies+=1;
if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
}
if(pos == targetpos)
{
target.stop();
punch.play();
hit.stream("sounds/hit" + random(1,10) + ".wav");
hit.play();
hits+=1;
punchies+=1;
points+=punchies;
points+=hits;
points-=misses;
show_game_window("Hit!");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
}
if(key_pressed(KEY_LEFT))
{
step.stream("sounds/step" + random(1,5) + ".ogg");
step.play();
pos--;
position_sound_1d(target, pos, targetpos, 1, 1);
if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
}
if(key_pressed(KEY_RIGHT))
{
step.stream("sounds/step" + random(1,5) + ".ogg");
step.play();
pos++;
position_sound_1d(target, pos, targetpos, 1, 1);
if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
}
if(pos == 0)
{
step.stop();
pos=1;
position_sound_1d(target, pos, targetpos, 1, 1);
if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
}
if(pos == 20)
{
step.stop();
pos=19;
position_sound_1d(target, pos, targetpos, 1, 1);
if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
}
if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
if(lifes == 0)
{
target.stop();
punch.play();
hit2.play();
lose.play();
music.stop();
wait(5000);
v.speak_wait("You have died! Total punchies fired "+punchies+", hits "+hits+", misses "+misses+". Your final score "+points+"! Great!");
main();
}
if(key_pressed(KEY_ESCAPE))
{
main();
}
if(getextralife.elapsed>=180000)
{
extralife.play();
show_game_window("Extra life!");
lifes+=1;
getextralife.restart();
if(targethit.elapsed == 5000)
{
punch.play();
hit2.play();
target.stop();
lifes-=1;
show_game_window("You lose one life! "+lifes+" lifes left");
targetpos=random(1,19);
target.stream("sounds/target" + random(1,10) + ".ogg");
target.play_looped();
position_sound_1d(target, pos, targetpos, 1, 1);
targethit.restart();
}
}
}
}