static void Action(TAction * a) { TWatch *t; TCondition *c; while (1) { switch (a->action) { case ACTION_NULL: return; case ACTION_SOUND: PlaySoundAt(a->x, a->y, a->tileFlags); break; case ACTION_SETTRIGGER: Map(a->x, a->y).flags |= TILE_TRIGGER; break; case ACTION_CLEARTRIGGER: Map(a->x, a->y).flags &= ~TILE_TRIGGER; break; case ACTION_CHANGETILE: Map(a->x, a->y).flags = a->tileFlags; Map(a->x, a->y).pic = a->tilePic; break; case ACTION_SETTIMEDWATCH: t = FindWatch(a->x); if (t) { c = t->conditions; while (c && c->condition != CONDITION_NULL) { if (c->condition == CONDITION_TIMEDDELAY) { c->x = a->y; break; } c++; } ActivateWatch(t->index); } break; case ACTION_ACTIVATEWATCH: ActivateWatch(a->x); break; case ACTION_DEACTIVATEWATCH: DeactivateWatch(a->x); break; } a++; } }
int PlayerSpecialCommands(TActor * actor, int cmd, struct PlayerData *data) { int i; if (!actor) return NO; if (((cmd | actor->lastCmd) & CMD_BUTTON2) == 0) actor->flags &= ~FLAGS_SPECIAL_USED; if ((cmd & CMD_BUTTON2) != 0 && (cmd & (CMD_LEFT | CMD_RIGHT | CMD_UP | CMD_DOWN)) != 0 && actor->dx == 0 && actor->dy == 0) { SlideActor(actor, cmd); actor->flags |= FLAGS_SPECIAL_USED; } else if ((actor->lastCmd & CMD_BUTTON2) != 0 && (cmd & CMD_BUTTON2) == 0 && (actor->flags & FLAGS_SPECIAL_USED) == 0 && (cmd & (CMD_LEFT | CMD_RIGHT | CMD_UP | CMD_DOWN)) == 0 && // actor->dx == 0 && actor->dy == 0 && data->weaponCount > 1) { for (i = 0; i < data->weaponCount; i++) if (actor->gun == data->weapons[i]) break; i++; if (i >= data->weaponCount) i = 0; actor->gun = data->weapons[i]; PlaySoundAt(actor->tileItem.x, actor->tileItem.y, SND_SWITCH); } else return NO; actor->lastCmd = cmd; return YES; }
void CollisionSoundPlayer::PlaySound(const b2Body *body, ofSoundPlayer *sound, int &next_index) { const float speed = ofClamp(body->GetLinearVelocity().Length() / 10.0, 0.8f, 1.0f); sound[next_index].setSpeed(speed + 0.01 * ofRandomf()); PlaySoundAt(body, &sound[next_index]); next_index = (next_index + 1) % kConcurrentSounds; }
void CollisionSoundPlayer::PlayPlayer2Win(const b2Body *ball) { PlaySoundAt(ball, &player2_score7); PlaySoundAt(ball, &player2_winfade); }
void CollisionSoundPlayer::PlayPlayer2Score(const b2Body *ball) { PlaySoundAt(ball, &player2_score); }
void CollisionSoundPlayer::PlayPlayer2Hit(const b2Body *ball) { ofSoundPlayer *choice = &backhit[static_cast<int>(ofRandom(0, 4))]; PlaySoundAt(ball, choice); }