Beispiel #1
0
void draw_enemies()
{
  Uint16 i;
  ENEMY *p;
  SIDE s;

  for( i = 0; i < num_enemies; i++ ) {

    p = get_enemy( i );

    /* Attempt to move the enemy. */
    if( move_enemy( p ) == 0 )
      continue;

    /* Do things for an active enemy. */
    if( IS_ACTIVE(p->flags) ) {
      draw_sprite( p->current );  /* Draw it. */

      /* Check for a collision with the ship. */
      s = sprite_collide( p->current, get_ship_sprite() );
      if( s.none == 0  ) {
        hit_enemy( p, 5 );
        ship_hit( s );
      }
    }
  }

}
Beispiel #2
0
ENEMY *check_enemy_collide( SPRITE *s )
{
  Uint16 i;
  ENEMY *p;

  for( i = 0; i < num_enemies; i++ ) {

    p = get_enemy( i );
    
    if( sprite_collide( p->current, s ).none == 0 )
      return p;

  }

  return NULL;
}
Beispiel #3
0
void CL::cp_proc(Sprite *sprite)
{
	collision_function *table;
	collision_function code;
	int type;
	Sprite *hit;

	type = _cl_type;
	hit = sprite_collide(_cl_list, sprite->_sprite_x, sprite->_sprite_y, sprite->_sprite_w, sprite->_sprite_h, type);
	if (hit)
	{
		//call collision code for type
		table = _cl_table;
		type = hit->_sprite_type;
		while (!(type & 1))
		{
			type = type >> 1;
			table++;
		}
		code = *table;
		if (code) { (*code)(sprite, hit); }
	}
}