in procgen/src/games/ninja.cpp [379:411]
void game_step() override {
BasicAbstractGame::game_step();
if (action_vx > 0)
agent->is_reflected = false;
if (action_vx < 0)
agent->is_reflected = true;
if (special_action > 0 && (cur_time - last_fire_time) >= 3) {
float theta = 0;
float bullet_vel = 1;
if (special_action == 1) {
theta = 0;
} else if (special_action == 2) {
theta = PI / 4;
} else if (special_action == 3) {
theta = PI / 2;
} else if (special_action == 4) {
theta = -1 * PI / 4;
}
if (agent->is_reflected) {
theta = PI - theta;
}
auto new_bullet = add_entity(agent->x, agent->y, bullet_vel * cos(theta), bullet_vel * sin(theta), .25, THROWING_STAR);
new_bullet->collides_with_entities = true;
new_bullet->expire_time = 15;
new_bullet->smart_step = true;
last_fire_time = cur_time;
}
}