int alien_fire(alien *a1) { if (a1 == NULL) { return 1; } projectile_init(NULL, (unsigned short) (a1->x + ALIEN_WIDTH / 2), a1->y + ALIEN_HEIGHT+ALIEN_Y_DELTA, ALIEN_PROJECTILE_VELOCITY); //TODO remove + ALIEN_Y_DELTA AFTER THE DIMENSIONS ARE SORTED OUT return 0; }
void starship_fire(starship_t *starship, stage_t *stage) { if (starship->charge > FIRE_DRAIN) { entity_t *entity = (entity_t*)starship; int projectile_id = -1; if (entity->type == PLAYER) projectile_id = ((player_t*)starship)->player_id; uint16_t damage = 10 * (starship->weaponry_level + 1); projectile_t *projectile = malloc(sizeof(projectile_t)); projectile_init(projectile, projectile_id, damage, (movement_t){entity->movement.position, vec2_scale(entity->movement.orientation, PROJECTILE_SPEED), {0, 0}, entity->movement.orientation}); stage_add_entity(stage, (entity_t*)projectile); starship->charge -= FIRE_DRAIN; } }
projectile* _engine_uwz_shoot_add_projectile(engine *p, warzone *p_wz, int player_rid, intpoint location, enum direction direction) { int i, projectiles_per_tank = p_wz->rules.MAX_PROJECTILES_PER_TANK; projectile *p_proj; for (i = 0; i < projectiles_per_tank; i++) { p_proj = p_wz->projectiles + player_rid * projectiles_per_tank + i; if (p_proj->direction != DIRECTION_0) { continue; } projectile_init(p_proj, location.x, location.y, direction, player_rid); return p_proj; } return NULL; }