void Game_Battler::UpdateGauge(int multiplier) { if (!Exists()) { if (IsDead()) { SetGauge(0); } return; } if (gauge > GetMaxGauge()) { return; } gauge += GetAgi() * multiplier; //printf("%s: %.2f\n", GetName().c_str(), ((float)gauge / EASYRPG_GAUGE_MAX_VALUE) * 100); }
void Game_Battler::RemoveBattleStates() { std::vector<int16_t>& states = GetStates(); // If death is non-permanent change HP to 1 if (IsDead() && non_permanent(1)) { ChangeHp(1); } for (size_t i = 0; i < states.size(); ++i) { if (non_permanent(i + 1)) { states[i] = 0; } } }
static void tossSingleReduceStates( a_state *state ) { a_shift_action *saction; a_sym *shift_sym; if( IsDead( state ) ) { return; } /* iterate over all shifts in the state */ for( saction = state->trans; (shift_sym = saction->sym) != NULL; ++saction ) { if( saction->units_checked ) continue; shiftToSingleReduce( state, saction ); } }
bool Cell::ReadyToDivide() { assert(!IsDead()); if (mUndergoingApoptosis || HasCellProperty<ApoptoticCellProperty>()) { return false; } // NOTE - we run the SRN model here first before the CCM mpSrnModel->SimulateToCurrentTime(); // This in turn runs any simulations within the CCM through ReadyToDivide(); mCanDivide = mpCellCycleModel->ReadyToDivide(); return mCanDivide; }
void C4Effect::ClearAll(int32_t iClearFlag) { // simply remove access all effects recursively, and do removal calls // this does not regard lower-level effects being added in the removal calls, // because this could hang the engine with poorly coded effects if (pNext) pNext->ClearAll(iClearFlag); if ((Target && !Target->Status) || IsDead()) return; int32_t iPrevPrio = iPriority; SetDead(); if (CallStop(iClearFlag, false) == C4Fx_Stop_Deny) { // this stop-callback might have deleted the object and then denied its own removal // must not modify self in this case... if (Target && !Target->Status) return; // effect denied to be removed: recover it iPriority = iPrevPrio; } // Update OnFire cache if (Target && WildcardMatch(C4Fx_AnyFire, GetName()) && IsDead()) if (!Get(C4Fx_AnyFire)) Target->SetOnFire(false); if (IsDead() && !GetCallbackScript()) Call(P_Destruction, &C4AulParSet(iClearFlag)); }
void CLocalPlayer::HandlePassengerKey( void ) { // Are we spawned and not dead and not already in a vehicle? if( IsSpawned() && !IsDead() && !m_pVehicle ) { // CNetworkVehicle * pVehicle = NULL; EntityId seat = 0; // Get the closest vehicle in range GetClosestVehicle( &pVehicle, &seat ); CLogFile::Printf( "CLocalPlayer::HandlePassengerKey() - Vehicle: 0x%p, Seat: %d", pVehicle, seat ); // Did we get a closest vehicle and a seat? if( pVehicle && seat ) { // Get the old control state bOldControlState = AreControlsLocked(); // Get the old camera lock state bOldCameraState = pCore->GetCamera()->IsLocked(); CLogFile::Printf( "CLocalPlayer::HandlePassengerKey() - bOldControlState: %s, bOldCameraState: %s", (bOldControlState ? "true" : "false"), (bOldCameraState ? "true" : "false") ); // Lock the player controls LockControls( true ); // Set the player state SetState( PLAYERSTATE_PASSENGER ); CLogFile::Printf( "CLocalPlayer::HandlePassengerKey() - Putting player in passenger seat..." ); // Get in the vehicle PutInVehicle( pVehicle, seat ); CLogFile::Printf( "CLocalPlayer::HandlePassengerKey() - Done!" ); // Unlock camera control if( !bOldCameraState ) // checking this because after we put in vehicle, it locks control :( pCore->GetCamera()->LockControl( false ); // Reset the controls //*(DWORD *)(m_pPlayerPed->GetPed() + 0x310) = 6; //LockControls( bState ); } } }
void Player::Update(double currentTime, double elapsedTime) { float current = float(currentTime); float elapsed = float(elapsedTime); if (IsDead()) { TimeUntilRespawn -= elapsed; if (TimeUntilRespawn <= 0.0f) { // respawn the player. Velocity[0] = 0.0f; Velocity[1] = 0.0f; Position[0] = ViewportWidth * 0.5f; Position[1] = ViewportHeight * 0.5f; TargetPoint[0] = ViewportWidth * 0.5f; TargetPoint[1] = ViewportHeight * 0.5f; TargetVector[0] = 0.0f; TargetVector[1] = 0.0f; TimeUntilRespawn = 0.0f; } } else { Position[0] += Velocity[0]; Position[1] += Velocity[1]; Position[0] = clamp(Position[0], 0, ViewportWidth); Position[1] = clamp(Position[1], 0, ViewportHeight); if (CooldownRemaining > 0.0f) { CooldownRemaining -= elapsed; } else { float cos_a = cosf(Orientation); float sin_a = sinf(Orientation); float vel_x = 11.0f * cos_a; float vel_y = 11.0f * sin_a; float pos_x = Position[0]; float pos_y = Position[1]; Bullet *ent = new Bullet(pos_x, pos_y, vel_x, vel_y); EntityManager::GetInstance()->Add(ent); CooldownRemaining = COOLDOWN_TIME; } } UNUSED_LOCAL(current); }
void Player::PlayerRunHandler(Packet* poPacket) { if (IsDead() || GetScene() == NULL) { XLog(LEVEL_ERROR, "%s can not run: dead:%d scene:%s\n", m_sName, m_bDead, m_poScene ? "true" : "NULL"); return; } uint16_t uPosX = 0; uint16_t uPosY = 0; int16_t nSpeedX = 0; int16_t nSpeedY = 0; uint32_t uClientMSTime = 0; g_oPKReader.SetPacket(poPacket); g_oPKReader >> uPosX >> uPosY >> nSpeedX >> nSpeedY >> uClientMSTime; //客户端提供的时间值必须大于起始时间值 if (uClientMSTime < m_nClientRunStartMSTime) { XLog(LEVEL_ERROR, "%s sync pos: start run client time invalid\n", m_sName); Actor::SendSyncPosition(); return; } MapConf* poMapConf = m_poScene->GetMapConf(); if (uPosX >= poMapConf->nPixelWidth || uPosY >= poMapConf->nPixelHeight || poMapConf->IsBlockUnit(uPosX/gnUnitWidth, uPosY/gnUnitHeight)) { XLog(LEVEL_ERROR, "%s sync pos: start run pos invalid\n", m_sName); Actor::SendSyncPosition(); return; } //正在移动则先更新移动后的新位置 if (m_nRunStartMSTime > 0) { Actor::UpdateRunState(m_nRunStartMSTime + uClientMSTime - m_nClientRunStartMSTime); } //客户端与服务器坐标误差在一定范围内,则以客户端坐标为准 if (!BattleUtil::IsAcceptablePositionFaultBit(m_oPos.x, m_oPos.y, uPosX, uPosY)) { XLog(LEVEL_ERROR, "%s sync pos: start run faultbit srv:(%d, %d) clt:(%d,%d)\n", m_sName, m_oPos.x, m_oPos.y, uPosX, uPosY); uPosX = (uint16_t)m_oPos.x; uPosY = (uint16_t)m_oPos.y; Actor::SendSyncPosition(); } Actor::SetPos(Point(uPosX, uPosY), __FILE__, __LINE__); m_nClientRunStartMSTime = uClientMSTime; Actor::StartRun(nSpeedX, nSpeedY); }
void Player::Update(uint32_t diff) { m_session->Update(diff); if (!IsUpdateEnabled()) return; if (IsMoving() && !IsDead()) { float dx = cos(GetMoveAngle())*diff*m_playerSpeed; float dy = sin(GetMoveAngle())*diff*m_playerSpeed; Position plpos(m_position.x + dx, m_position.y + dy); Relocate(plpos, true); } }
void PythonInterpCtrl::KillProcess() { if(IsDead()) return; if(m_killlevel==0) { SendKill(); m_killlevel=1; return; } if(m_killlevel==1) { m_pyinterp->KillProcess(); return; } }
bool Ship::OnDamage(Object *attacker, float kgDamage) { if (!IsDead()) { float dam = kgDamage*0.001f; if (m_stats.shield_mass_left > 0.0f) { if (m_stats.shield_mass_left > dam) { m_stats.shield_mass_left -= dam; dam = 0; } else { dam -= m_stats.shield_mass_left; m_stats.shield_mass_left = 0; } } m_stats.hull_mass_left -= dam; if (m_stats.hull_mass_left < 0) { if (attacker) { if (attacker->IsType(Object::BODY)) { // XXX remove this call. kill stuff (including elite rating) should be in a script static_cast<Body*>(attacker)->OnHaveKilled(this); LuaEvent::Queue("onShipDestroyed", this, dynamic_cast<Body*>(attacker)); } if (attacker->IsType(Object::SHIP)) Polit::NotifyOfCrime(static_cast<Ship*>(attacker), Polit::CRIME_MURDER); } Explode(); } else { if (attacker && attacker->IsType(Object::SHIP)) Polit::NotifyOfCrime(static_cast<Ship*>(attacker), Polit::CRIME_PIRACY); if (Pi::rng.Double() < kgDamage) Sfx::Add(this, Sfx::TYPE_DAMAGE); if (dam < 0.01 * float(GetShipType().hullMass)) Sound::BodyMakeNoise(this, "Hull_hit_Small", 1.0f); else Sound::BodyMakeNoise(this, "Hull_Hit_Medium", 1.0f); } } //printf("Ouch! %s took %.1f kilos of damage from %s! (%.1f t hull left)\n", GetLabel().c_str(), kgDamage, attacker->GetLabel().c_str(), m_stats.hull_mass_left); return true; }
bool CHL2MP_Player::HandleCommand_JoinTeam( int team ) { #ifndef GE_DLL if ( !GetGlobalTeam( team ) || team == 0 ) { Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team ); return false; } if ( team == TEAM_SPECTATOR ) { // Prevent this is the cvar is set if ( !mp_allowspectators.GetInt() ) { ClientPrint( this, HUD_PRINTCENTER, "#Cannot_Be_Spectator" ); return false; } if ( GetTeamNumber() != TEAM_UNASSIGNED && !IsDead() ) { m_fNextSuicideTime = gpGlobals->curtime; // allow the suicide to work CommitSuicide(); // add 1 to frags to balance out the 1 subtracted for killing yourself IncrementFragCount( 1 ); } ChangeTeam( TEAM_SPECTATOR ); return true; } else { StopObserverMode(); State_Transition(STATE_ACTIVE); } // Switch their actual team... ChangeTeam( team ); return true; #else return false; #endif }
void Game_Battler::AddState(int state_id) { const RPG::State* state = ReaderUtil::GetElement(Data::states, state_id); if (!state) { Output::Warning("AddState: Can't add state with invalid ID %d", state_id); return; } if (IsDead()) { return; } if (state_id == 1) { SetGauge(0); RemoveAllStates(); SetCharged(false); SetHp(0); SetAtkModifier(0); SetDefModifier(0); SetSpiModifier(0); SetAgiModifier(0); SetIsDefending(false); SetCharged(false); attribute_shift.clear(); attribute_shift.resize(Data::attributes.size()); } std::vector<int16_t>& states = GetStates(); if (state_id - 1 >= static_cast<int>(states.size())) { states.resize(state_id); } states[state_id - 1] = 1; // Clear states that are more than 10 priority points below the // significant state const RPG::State* sig_state = GetSignificantState(); for (size_t i = 0; i < states.size(); ++i) { if (Data::states[i].priority <= sig_state->priority - 10) { states[i] = 0; } } if (IsDefending() && GetSignificantRestriction() != RPG::State::Restriction_normal) { SetIsDefending(false); } }
/** Handle received data from a directly connected server. * @param[in] cptr Peer server that sent us data. * @param[in] buffer Input buffer. * @param[in] length Number of bytes in input buffer. * @return 1 on success or CPTR_KILLED if the client is squit. */ int server_dopacket(struct Client* cptr, const char* buffer, int length) { const char* src; char* endp; char* client_buffer; assert(0 != cptr); update_bytes_received(cptr, length); client_buffer = cli_buffer(cptr); endp = client_buffer + cli_count(cptr); src = buffer; while (length-- > 0) { *endp = *src++; /* * Yuck. Stuck. To make sure we stay backward compatible, * we must assume that either CR or LF terminates the message * and not CR-LF. By allowing CR or LF (alone) into the body * of messages, backward compatibility is lost and major * problems will arise. - Avalon */ if (IsEol(*endp)) { if (endp == client_buffer) continue; /* Skip extra LF/CR's */ *endp = '\0'; update_messages_received(cptr); if (parse_server(cptr, cli_buffer(cptr), endp) == CPTR_KILLED) return CPTR_KILLED; /* * Socket is dead so exit */ if (IsDead(cptr)) return exit_client(cptr, cptr, &me, cli_info(cptr)); endp = client_buffer; } else if (endp < client_buffer + BUFSIZE) ++endp; /* There is always room for the null */ } cli_count(cptr) = endp - cli_buffer(cptr); return 1; }
long PythonInterpCtrl::LaunchProcess(const wxString &processcmd, const wxArrayString &options) // bool ParseLinks, bool LinkClicks, const wxString &LinkRegex { if(!IsDead()) return -1; //TODO: Option to use XMLRPC over localhost or pipe, currently always use pipe // m_port=m_portalloc.RequestPort(); //TODO: Request port limited to 3 ports // if(m_port<0) // return -1; m_port = -1; //Use XmlRpc over pipe //TODO: get the command and working dir from config #ifdef __WXMSW__ // wxString cmd=_T("cmd /c interp.py ")+wxString::Format(_T(" %i"),m_port); //TODO: this could have process destruction issues on earlier version of wxWidgets (kills cmd, but not python) wxString cmd=_T("python -u interp.py ")+wxString::Format(_T(" %i"),m_port); //TODO: this could have process destruction issues on earlier version of wxWidgets (kills cmd, but not python) wxString python=_T("\\python"); wxString interp=_T("\\interp.py"); #else wxString cmd=_T("python -u interp.py ")+wxString::Format(_T(" %i"),m_port); wxString python=_T("/python"); wxString interp=_T("/interp.py"); #endif wxString gpath = ConfigManager::GetDataFolder(true)+python; wxString lpath = ConfigManager::GetDataFolder(false)+python; bool global=false,local=false; if(wxFileName::FileExists(gpath+interp)) { wxSetWorkingDirectory(gpath); global=true; } if(wxFileName::FileExists(lpath+interp)) { wxSetWorkingDirectory(lpath); local=true; } if(!global&&!local) //No interpreter script found, return failure. return -2; //TODO: Return meaningful messages (or at least use the codeblocks logger) m_pyinterp = new XmlRpcInstance(cmd,m_port,_T("localhost"),this); if(m_pyinterp->IsDead()) { Manager::Get()->GetLogManager()->Log(_("Error Starting Interpreter")); return -1; } //TODO: Perform any initial communication with the running python process... return 1; }
VOID CPlayer::Update(float nLoopTime) { static float nStarttime=0; static int nOldState=STAND; nStarttime+=nLoopTime; if (IsDead()) { m_nState=DEAD; } if (nOldState!=m_nState) { m_pPlayerMesh->SetAnimationNum(m_nState); nStarttime=0; nOldState=m_nState; } if (m_nState==DEAD) { if (nStarttime>m_fAnimPeriod[m_nState]-0.1) { return; } } if (m_bControl) { if (nStarttime>m_fAnimPeriod[m_nState]) { nStarttime=0; m_bControl=false; } } else { if (m_bGTarget) { m_nState=READYATTACK; } else m_nState=STAND; } m_pPlayerMesh->Update(nLoopTime); }
void Game_Battler::RemoveState(int state_id) { const RPG::State* state = ReaderUtil::GetElement(Data::states, state_id); if (!state) { Output::Warning("RemoveState: Can't delete state with invalid ID %d", state_id); return; } std::vector<int16_t>& states = GetStates(); if (state_id - 1 >= static_cast<int>(states.size())) { return; } if (state_id == 1 && IsDead()) { SetHp(1); } states[state_id - 1] = 0; }
bool AggressiveDCEPass::IsTargetDead(Instruction* inst) { const uint32_t tId = inst->GetSingleWordInOperand(0); Instruction* tInst = get_def_use_mgr()->GetDef(tId); if (IsAnnotationInst(tInst->opcode())) { // This must be a decoration group. We go through annotations in a specific // order. So if this is not used by any group or group member decorates, it // is dead. assert(tInst->opcode() == SpvOpDecorationGroup); bool dead = true; get_def_use_mgr()->ForEachUser(tInst, [&dead](Instruction* user) { if (user->opcode() == SpvOpGroupDecorate || user->opcode() == SpvOpGroupMemberDecorate) dead = false; }); return dead; } return IsDead(tInst); }
/** * 如果当前线程存在 Isolate 对象, 表示已经初始化过了 */ bool V8::Initialize() { Isolate *isolate = Isolate::UncheckedCurrent(); if (isolate != NULL && isolate->IsInitialized()) { return true; } Isolate::EnterDefaultIsolate(); if (IsDead()) return false; isolate = Isolate::Current(); if (isolate->IsInitialized()) return true; is_running_ = true; has_been_set_up_ = true; return isolate->Init(); }
void CEnemy::Update(float fElapsedTime) { // DANIEL CODE BEGIN if(IsDead()) { if((timeGetTime() - m_dwDeadTimeStamp) > (m_fRespawnTime * 1000)) { Ressurect(); SetPosX(m_ptRespawnPosition.x); SetPosY(m_ptRespawnPosition.y); } } // DANIEL CODE END else { CBaseCharacter::Update(fElapsedTime); } }
bool CHL2MP_Player::HandleCommand_JoinTeam( int team ) { if ( !GetGlobalTeam( team ) || team == 0 ) { Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team ); return false; } if ( team == TEAM_SPECTATOR ) { // Prevent this is the cvar is set if ( !mp_allowspectators.GetInt() ) { ClientPrint( this, HUD_PRINTCENTER, "#Cannot_Be_Spectator" ); return false; } if ( /*GetTeamNumber() != TEAM_UNASSIGNED &&*/ !IsDead() ) //DHL - Skillet - Players in deathmatch are unassigned { m_fNextSuicideTime = gpGlobals->curtime; // allow the suicide to work CommitSuicide(); // add 1 to frags to balance out the 1 subtracted for killing yourself IncrementFragCount( 1 ); GetTeam()->AddScore( 1 ); //DHL - Skillet - Required to keep the scoreboard headers from getting out of sync } ChangeTeam( TEAM_SPECTATOR ); return true; } else { StopObserverMode(); State_Transition(STATE_ACTIVE); } // Switch their actual team... ChangeTeam( team ); return true; }
void Piloto::Update(float dt) { if(robo == NULL){ StateMachine(dt); Input(dt); vida.Update(); vida.SetX(box.RectCenterX()); vida.SetY(box.RectCenterY()); if(IsDead() == true){ cout << this->nome <<": Fui morrido!! gwaa a a a.... D: " << endl; mapReference->At( currentPosition.x, currentPosition.y ).state = FREE; mapReference->At( currentPosition.x , currentPosition.y ).occuper = NULL; } }else{ box.SetRectCenterX(robo->box.RectCenterX()); box.SetRectCenterY(robo->box.RectCenterY()); } }
bool CActorInstance::CanAct() { if (IsDead()) return false; if (IsStun()) return false; if (IsParalysis()) return false; if (IsFaint()) return false; if (IsSleep()) return false; return true; }
HitResult CShip::HitCheck(Position hitPos) { // 입력 받은 포지션 값에 자기가 맞았는지 피격 결과를 반환한다. // 입력 받은 값과 포지션에 저장 된 값을 비교하여 결과를 반환한다. // 히트하면 HPCURRENT를 1 깎는다. // HPCURRENT가 0이 되면 파괴 되었다고 반환한다. int arraySize = sizeof(m_Pos) / sizeof(m_Pos[0]); for(int i = 0; i < arraySize; i++) { if(m_Pos[i].x == hitPos.x && m_Pos[i].y == hitPos.y) { if(m_Pos[i].bHit == false) { m_Pos[i].bHit = true; --m_HPCurrent; } return (IsDead()) ? DESTROY : HIT; /* if(IsDead()) { char string[255]; int shipDestroyCount = CGameManager::GetInstance()->GetDestroyCount(); CGameManager::GetInstance()->SetDestroyCount(++shipDestroyCount); sprintf_s(string, "%d번째 배가 터졌습니다. ", shipDestroyCount); CUIManager::GetInstance()->BroadCast(string); return DESTROY; } else return HIT; */ } } return MISS; }
void SpriteEffect::Render(){ if (IsDead()){ return; } if(HasSprite){ sp.SetAlpha(Alpha); sp.SetScale(Point(Scale,Scale)); //sp.SetCenter(Point(sp.GetWidth()/Frame,sp.GetHeight()/Frame)); sp.Render(box.x-Camera::pos.x,box.y-Camera::pos.y,rotation); sp.SetAlpha(255); }else if(txt.IsWorking()){ txt.SetRotation(rotation); //txt.SetScale(Point(Scale,Scale)); txt.SetAlpha(Alpha); txt.Render(Camera::AdjustPosition(box)); txt.SetAlpha(255); } }
void ArAIProperty::UpdateDummyAI(float dt) { auto pNpc = GetEntity<ArNPCEntity>(); if (!pNpc->IsDead()) { // ObjID_t targetID = pNpc->GetLockTargetID(); // if (targetID != INVALID_OBJ_ID && targetID != pNpc->getID()) // { // Ptr<GameEntity> entityTarget = GameEntityManager::getSingleton().findEntity(targetID); // if (entityTarget.isvalid() && entityTarget->GetRenderObject().isvalid()) // { // pNpc->GetMoveProperty()->TurnTo(entityTarget->GetPosition()); // } // } } else { //pNpc->GetMoveProperty()->synDirection(INVALID_DIRECTION_VALUE); } }
void Cell::StartApoptosis(bool setDeathTime) { assert(!IsDead()); if (mUndergoingApoptosis) { EXCEPTION("StartApoptosis() called when already undergoing apoptosis"); } mUndergoingApoptosis = true; mStartOfApoptosisTime = SimulationTime::Instance()->GetTime(); if (setDeathTime) { mDeathTime = mStartOfApoptosisTime + mApoptosisTime; } else { mDeathTime = DBL_MAX; } AddCellProperty(mCellPropertyCollection.GetCellPropertyRegistry()->Get<ApoptoticCellProperty>()); }
// NOTE: Let enemy entities call player's Die(), that's probably // easiest way to keep everything in sync void CPlayer::OnCollision(CEntity* Entity) { // Prevent multiple handlings for same collissions if( IsDead() || Entity->IsDead()) return; switch(Entity->Type) { case ENTITY_TYPE_ITEM: if (!TookHit) { Points = Points + 100; if( Entity->SubType == ENTITY_SUBTYPE_ITEM_WPN_NORMAL ) { Gun.ChangeType(GUN_NORMAL); } else if( Entity->SubType == ENTITY_SUBTYPE_ITEM_WPN_BEAM ) { Gun.ChangeType(GUN_BEAM); } else if( Entity->SubType == ENTITY_SUBTYPE_ITEM_WPN_MISSILE ) { Gun.ChangeType(GUN_MISSILES); } else if( Entity->SubType == ENTITY_SUBTYPE_ITEM_POINTS ) { Points = Points+900; } else if( Entity->SubType == ENTITY_SUBTYPE_ITEM_LIFEUP ) { Points = Points+400; if( Lives < 5 ) { Lives++; } } else if (Entity->SubType == ENTITY_SUBTYPE_ITEM_KILL_ENEMIES) { CFactory::Factory.CreateSlowMotion(LEVEL_SLOWMO_8X, 1000); CFactory::Factory.KillEnemiesOnScreen(); } } Entity->Die(); break; default: // Unknown collision break; } return; }
void Penguins::Update(float dt) { tShoot.Update(dt); float limSpeedpos = 190, limSpeedneg = -190; if (InputManager::GetInstance().IsKeyDown(SDLK_w)) { if (linearSpeed > limSpeedneg) linearSpeed -= dt*100; } if (InputManager::GetInstance().IsKeyDown(SDLK_s)) { if (linearSpeed < limSpeedpos) linearSpeed += dt*100; } if (!(InputManager::GetInstance().IsKeyDown(SDLK_w) || InputManager::GetInstance().IsKeyDown(SDLK_s))){ linearSpeed -= dt*linearSpeed; } if (InputManager::GetInstance().IsKeyDown(SDLK_a)){ rotation -= dt*100; } if (InputManager::GetInstance().IsKeyDown(SDLK_d)) { rotation += dt*100; } if (InputManager::GetInstance().MousePress(SDL_BUTTON_LEFT)) { if (tShoot.Get() > 0.4) { Shoot(); tShoot.Restart(); } } if ((linearSpeed < 1) && (linearSpeed > -1)) box.SetRect(box.GetXrect(), box.GetYrect(), box.GetWrect(), box.GetHrect()); else box.SetRect(box.GetXrect() - dt*linearSpeed*cos((rotation*M_PI) / 180), box.GetYrect() - dt*linearSpeed*sin((rotation*M_PI) / 180), box.GetWrect(), box.GetHrect()); cannonAngle = box.CenterRect(box).Inclinacao(InputManager::GetInstance().GetMouseX() - Camera::pos.GetXpoint(), InputManager::GetInstance().GetMouseY() - Camera::pos.GetYpoint(), box.CenterRect(box)); if (IsDead()){ Sprite animationSp("img/penguindeath.png", 5, 0.08); StillAnimation* animation = new StillAnimation(box.CenterRect(box).GetXpoint(), box.CenterRect(box).GetYpoint(), rotation, animationSp, 0.6, true); Game::GetInstance().GetCurrentState().AddObject(animation); Sound boom("audio/boom.wav"); boom.Play(0.5); } }
void Creature::ApplyDamage(Creature* attacker, const DamageInfo& info) { std::string damageName = DamageTypeStringLookup[info.type]; std::string elementName = ElementStringLookup[info.element]; if (IsDead()) { std::cout << m_name << "'s corpse "; } else { std::cout << m_name; } std::cout << " took " << info.amount << " " << damageName; if (info.element != Element::NONE) { std::cout << " " << elementName; } std::cout << " damage from " << attacker->GetName() << "\n"; if (m_health > 0 && m_health - info.amount <= 0) { if (m_health - info.amount < -m_maxHealth) { std::cout << m_name << " explodes into a fine pink mist!\n"; } else { std::cout << m_name << " dies!\n"; } } m_health -= info.amount; }