var allow_fire = 1;
action bullet_act()
{
while( my )
{
// we must use IGNORE_PUSH to prevent the bullet from getting stuck in the player
c_move( my, vector( 32*time_step, 0, 0 ), nullvector, IGNORE_PASSABLE | IGNORE_PUSH );
if( trace_hit ) // this is true if I hit an object
ent_remove(my);
wait(1);
}
}
action player_act()
{
my.push = -1;
while( my )
{
if( key_space && allow_fire ) // if key_space is pressed...
{
your = ent_create( "bullet.mdl", my.x, bullet_act ); // fire a bullet
vec_set( your.pan, my.pan ); // set your angles
allow_fire = 0; // this prevents multiple bullets from appearing whenever the space bar is held down
}
if( !key_space ) allow_fire = 1;
wait(1);
}
}