////////////////////////////////////////////////////////
var dead_birds = 0;
var shot = 0;
VECTOR bullet_speed;
var bullets = 10; // number of bullets
//////////////////////////////////////////////////////////////
FONT* arial_font = "Arial#14b";
//////////////////////////////////////////////////////////////
BMAP* cursor_pcx = "cursor.pcx"; // cursor bitmap
//////////////////////////////////////////////////////////////
SOUND* beep_sound = "beep.wav";
SOUND* enemyshot_snd = "enemyshot.wav";
SOUND* playershot_snd = "playershot.wav";
SOUND* enemydead_snd = "dead.wav";
//////////////////////////////////////////////////////////////
function move_bullet();
function remove_bullets();
function player_shoots();
function move_crows();
function kill_crows();
//////////////////////////////////////////////////////////////
STRING* moorhuhn_wmb = "moorhuhn.wmb";
STRING* bullet_mdl = "bullet.mdl";
STRING* crow_mdl = "crow.mdl";
///////////////////////////////////////////////////////////////
PANEL* cursor_pan=
{
bmap = cursor_pcx;
pos_x = 392; // (800 - 16) / 2
pos_y = 292; // (600 - 16) / 2
flags = OVERLAY | VISIBLE;
}
PANEL* info_pan= // displays the bullets and the number of birds that were shot
{
pos_x = 0;
pos_y = 0;
digits = 10, 575, "Health:%.0f", arial_font, 1, 100; // player's health is always 100
digits = 330, 575, "Bullets:%.0f", arial_font, 1, bullets;
digits = 660, 575, "Bodies:%.0f", arial_font, 1, dead_birds;
flags = VISIBLE;
}
////////////////////////////////////////////////////////////////
function main()
{
video_mode = 7; // 800x600
video_depth = 32; // 32 bits
video_screen = 1; // start the game in full screen mode
vec_zero(bullet_speed);
level_load (moorhuhn_wmb);
}
action my_player() // attach this action to the player
{
player = my; // I'm the player
set(my,INVISIBLE);// and I'm invisible - who cares?
camera.x = player.x;
camera.y = player.y;
camera.z = player.z; // choose a convenient position for the player to get a good camera
camera.pan = 90; // initial camera.pan position
while (1) // as long as the player is alive
{
camera.tilt += 10 * mouse_force.y * time_step;
camera.tilt = clamp (camera.tilt, -30, 30);
//if (camera.tilt < -25) {camera.tilt += 1;}
//if (camera.tilt > 25) {camera.tilt -= 1;}
camera.pan -= 10 * mouse_force.x * time_step;
//if (camera.pan < 60) {camera.pan += 1;} // 90 - 30
//if (camera.pan > 120) {camera.pan -= 1;} // 90 + 30
camera.pan = clamp (camera.pan, 45, 135);
if (mouse_left == 1 && bullets > 0 && shot==0)
{
player_shoots();
}
player.pan = camera.pan; // rotate the player too
player.tilt = camera.tilt; // not just the camera
if ((mouse_right == 1) && (bullets == 0)) // right click to reload the gun
{
bullets = 10;
while (mouse_right == 1) {wait (1);}
}
wait (1);
}
}
function player_shoots()
{
shot=1;
while (mouse_left == 1 && shot==1) {wait (1);}
snd_play (playershot_snd, 70, 0);
ent_create (bullet_mdl, player.x, move_bullet);
bullets -= 1; // you have used a bullet
shot=0;
}
function move_bullet()
{
wait (1);
if (my == NULL) {return;}
my.emask = ENABLE_BLOCK | ENABLE_ENTITY;
my.event = remove_bullets;
set(my,PASSABLE);
my.pan = you.pan;
my.tilt = you.tilt;
my.skill1 = 0;
bullet_speed.x = 500*time_step;
bullet_speed.y = 0;
bullet_speed.z = 0;
while (my.skill1 < 50)
{
if (my == NULL) {return;}
if (my.skill1 < 0.1) // don't collide with the creator
{
set(my,PASSABLE);
}
else
{
reset(my,PASSABLE);
}
my.skill1 += 0.1 * time_step;
c_move (me,bullet_speed, nullvector,GLIDE);
wait (1);
}
ent_remove (my);
}
function remove_bullets()
{
wait (1);
ent_remove (my);
}
function generate_birds_startup()
{
VECTOR temp;
vec_zero(temp);
wait (-1); // wait until the level is loaded
while (1)
{
temp.x = -1000;
temp.y = random (1000);
temp.z = 100 + random (500);
ent_create (crow_mdl, temp, move_crows);
wait (-3); // generate a crow every 3 seconds
}
}
function move_crows()
{
my.emask = ENABLE_IMPACT;
my.event = kill_crows;
var crow_speed;
crow_speed = 5 + random(5);
while ((my.x < 1250) && (my.skill40 == 0))
{
my.x += crow_speed * time_step;
ent_animate (me, "walk", my.skill42, ANM_CYCLE);
my.skill42 += 5 * time_step;
wait (1);
}
}
function kill_crows()
{
my.skill40 = 1; // stop the crow
set(my,INVISIBLE);
my.emask = ~ENABLE_IMPACT; // can't be shot from now on
my.event = NULL;
dead_birds += 1;
my.skill10 = 0;
snd_play (enemydead_snd, 70, 0);
wait(-.5);
ent_remove (my);
}