void Portal::OnPlayerCollision(Player* p) { if (m_collidingPlayers.count(p) > 0) { return; } Assert(m_destId != -1); GameObject* obj = TheGame::Instance()->GetGameObject(m_destId); Assert(obj); Portal* otherPortal = dynamic_cast<Portal*>(obj); if (otherPortal) { // Set the other object as collided with, so we don't keep travelling // back and forth between 2 portals otherPortal->m_collidingPlayers.insert(p); } // Can't take pets through portal, so using it has a cost p->DropPets(); Vec3f pos = obj->GetPos(); p->SetPos(pos); // Set the player forward dir to the heading of the portal //p->SetDir(GetDir()); // Special state, with spiral for a split second static GSSpiral* sp = TheGSSpiral::Instance(); sp->SetPrevState(TheGSMain::Instance()); TheGame::Instance()->SetCurrentState(sp); PlayWav("laser_x"); }
void PlatCae::Check() { if (MX - Pos < - 400) { Matarme(); return; } if (!Activo) { if (MX - Pos < 800) Activo = true; else return; } if (TiempoRestante == NoHayCaida) { if (APC && APCX >= MCX && APCX <= MCX + 2 && APCY == MCY) { APC = false; Nicho->ImagenNicholasY = MY - 90; TiempoRestante = RetardoPlataformaCae; } } else if (TiempoRestante == 0) { // Movimiento! MY += VY * Delta + Delta * Delta * AceleracionGravedad / 2; VY += Delta * AceleracionGravedad; if (MY > 700) { Matarme(); return; } } else { TiempoRestante -= Delta; if (TiempoRestante <= 0) { PlayWav(sndPuenteCae); TiempoRestante = 0; Nivel->SetEventos(MCX ,MCY,evNulo); Nivel->SetEventos(MCX + 1,MCY,evNulo); Nivel->SetEventos(MCX + 2,MCY,evNulo); } } }
void PuenteCae::Check() { if (TiempoRestante == 0) { // Movimiento! MY += VY * Delta + Delta * Delta * AceleracionGravedad / 2; VY += Delta * AceleracionGravedad; if (MY > 600) Matarme(); } else { TiempoRestante -= Delta; if (TiempoRestante <= 0) { PlayWav(sndPuenteCae); TiempoRestante = 0; Nivel->SetEventos(MCX, MCY, evNulo); } } }
int AalibPlay(int channel) { if ((channel<1)||(channel>48)) { return PSPAALIB_ERROR_INVALID_CHANNEL; } if (!channels[channel].initialized) { return PSPAALIB_ERROR_UNINITIALIZED_CHANNEL; } if (!AalibGetStopReason(channel)) { return PSPAALIB_SUCCESS; } int hardwareChannel=GetFreeHardwareChannel(); if (hardwareChannel==-1) { return PSPAALIB_WARNING_NO_FREE_CHANNELS; } hardwareChannels[hardwareChannel]=channel; sceKernelStartThread(threads[hardwareChannel],sizeof(int),(void*)(&hardwareChannel)); if ((PSPAALIB_CHANNEL_WAV_1<=channel)&&(channel<=PSPAALIB_CHANNEL_WAV_32)) { return PlayWav(channel-PSPAALIB_CHANNEL_WAV_1); } if ((PSPAALIB_CHANNEL_OGG_1<=channel)&&(channel<=PSPAALIB_CHANNEL_OGG_10)) { return PlayOgg(channel-PSPAALIB_CHANNEL_OGG_1); } if ((PSPAALIB_CHANNEL_SCEMP3_1<=channel)&&(channel<=PSPAALIB_CHANNEL_SCEMP3_2)) { return PlaySceMp3(channel-PSPAALIB_CHANNEL_SCEMP3_1); } if ((PSPAALIB_CHANNEL_AT3_1<=channel)&&(channel<=PSPAALIB_CHANNEL_AT3_2)) { return PlayAt3(channel-PSPAALIB_CHANNEL_AT3_1); } return PSPAALIB_ERROR_INVALID_CHANNEL; }
void PowerUpManager::Update() { float dt = TheTimer::Instance()->GetDt(); for (int i = 0; i < MAX_PLAYERS; i++) { if (powerUpTime[i] > 0) { #ifdef POWERUP_DEBUG std::cout << "Power up for player " << i << " is active! " << powerUpTime[i] << "\n"; #endif static float sec = 0; sec += dt; if (sec > 1.0f) { sec -= 1.0f; PlayWav("tick"); } powerUpTime[i] -= dt; if (powerUpTime[i] <= 0) { powerUpTime[i] = 0; powerUps[i] = POWERUP_NONE; // NOT: SetPowerUp(i, POWERUP_NONE); // Undo the power up effect here commands[i]->Undo(); commands[i] = nullptr; #ifdef POWERUP_DEBUG std::cout << "Power up for player " << i << " has just deactivated!\n"; #endif } } } }
bool Robots::ColisionTortuga() { long Cantidad, Total; Tortuga * AuxPunta; Cantidad = 0; Total = Tortugas->Tamano(); Tortugas->SelPrimero(); while (Cantidad < Total) { AuxPunta = ((Tortuga *)Tortugas->Avanzar()); RECT R1,R2; SetRect(&R1,(long)AuxPunta->ImagenTortugaX ,(long)AuxPunta->ImagenTortugaY, (long)AuxPunta->ImagenTortugaX + 90,(long)AuxPunta->ImagenTortugaY + 30); SetRect(&R2,(long)ImagenRobotsX ,(long)ImagenRobotsY, (long)ImagenRobotsX + 60,(long)ImagenRobotsY + 60); if (!AuxPunta->EstoyMuerto && AuxPunta->Resbalando && ColisionGeneral(R1,R2,imglstEnemigos[AuxPunta->ImagenTortugaPicture],imglstJefes[ImagenRobotsPicture])) { PlayWav(sndCaida); Puntaje += PuntajeMuerteTortuga * Multiplicador; ObjetoBase *CartelPuntaje = new Cartel(); Cartel *AuxCartel = (Cartel *)CartelPuntaje; char Cadena[MAX_LONG_CARTEL]; ltoa(PuntajeMuerteTortuga * Multiplicador,Cadena); AuxCartel->Inicializar(AuxPunta->ImagenTortugaX, AuxPunta->ImagenTortugaY, Cadena, RGB(255,255,255)); Carteles->Agregar(CartelPuntaje); AuxPunta->EstoyMuerto = true; AuxPunta->ImagenTortugaPicture = TortugaRev; AuxPunta->VY = -SaltoTortugaImpacto; return true; } Cantidad++; } return false; }
void CollidePlayerDino(GameObject* go1, GameObject* go2) { Player* player = dynamic_cast<Player*>(go1); Assert(player); Dino* dino = dynamic_cast<Dino*>(go2); Assert(dino); if (dino->IsDead()) { return; // this actually happened! } // Get the pets to flee the dino PetList pets = player->GetPets(); player->DropPets(); for (PetList::iterator it = pets.begin(); it != pets.end(); ++it) { Pet* pet = *it; AI* ai = pet->GetAI(AIFlee::NAME); ai->SetTarget(dino); pet->SetAI(ai); pet->SetIsFalling(true); } Vec3f vel = player->GetVel(); player->SetVel(-vel); vel = dino->GetVel(); dino->SetVel(Vec3f(0, 0, 0)); dino->SetAI(AIStunned::NAME); PlayWav("hammer_anvil3"); // NB No file ext WWCamera* cam = GetActiveCamera(); Assert(cam); cam->SetEarthquake(1.0f); // TODO CONFIG }
bool Robots::RevisarMuerte() { if (ColisionBolaFuego()) PlayWav(sndMetalRebote); if (Intermitente <= 0 && ColisionRayoEnergia()) { if (GolpesRestantes > 0) { PlayWav(sndGolpeRobots); GolpesRestantes--; Intermitente = TiempoIntermitenciaRobots; } else { PlayWav(sndCaida); ImagenRobotsPicture = RobotsRev; Puntaje += PuntajeMuerteRobots * Multiplicador; ObjetoBase *CartelPuntaje = new Cartel(); Cartel *AuxCartel = (Cartel *)CartelPuntaje; char Cadena[MAX_LONG_CARTEL]; ltoa(PuntajeMuerteRobots * Multiplicador,Cadena); AuxCartel->Inicializar(ImagenRobotsX, ImagenRobotsY, Cadena,RGB(255,255,255)); Carteles->Agregar(CartelPuntaje); EstoyMuerto = true; VY = -SaltoRobotsImpacto; return true; } } if (Intermitente <= 0 && ColisionTortuga()) { if (GolpesRestantes > 2) { PlayWav(sndGolpeRobots); GolpesRestantes -= 3; Intermitente = TiempoIntermitenciaRobots; } else { PlayWav(sndCaida); ImagenRobotsPicture = RobotsRev; Puntaje += PuntajeMuerteRobots * Multiplicador; ObjetoBase *CartelPuntaje = new Cartel(); Cartel *AuxCartel = (Cartel *)CartelPuntaje; char Cadena[MAX_LONG_CARTEL]; ltoa(PuntajeMuerteRobots * Multiplicador,Cadena); AuxCartel->Inicializar(ImagenRobotsX, ImagenRobotsY, Cadena,RGB(255,255,255)); Carteles->Agregar(CartelPuntaje); EstoyMuerto = true; VY = -SaltoRobotsImpacto; return true; } } RECT R; SetRect(&R,(long)ImagenRobotsX ,(long)ImagenRobotsY, (long)ImagenRobotsX + 60,(long)ImagenRobotsY + 60); if ((!Nicho->AuraEscudo) && ColisionaNicholas(R,imglstJefes[ImagenRobotsPicture]) != ColNula) Hitazo = true; return false; }