bool Mob::tick(){ cooldown>0 ? cooldown-- : cooldown=0; if (checkPlayer() && gp->lvl->IPlayer->HitPoints>0){ if (cooldown==0){ iprintf("Attacking!"); gp->som.playSFX(1, 1024); int att = Attack - ((Player*)gp->lvl->IPlayer)->MainHand.getDef(); att < 0 ? att=0 : att=att; gp->lvl->IPlayer->HitPoints -= att; cooldown = Cooltime; } } else{ moveIdle(); } if(Moving){ switch (IMoveDir){ case left: aX-=1; ISprite.HFlip = true; break; case right: aX+=1; ISprite.HFlip = false; break; case up: aY-=1; ISprite.HFlip = false; break; case down: aY+=1; ISprite.HFlip = false; break; } } int frame = (aX)/8 + (aY)/8; if (frame<0){frame -= 2*frame;}; if (IMoveDir!=down && Multidir){ frame+=2; if(IMoveDir==up){ frame+=2; } } ISprite.AnimFrame = frame; calcGrid(); calcSprite(); return true; }
void CritterMovementComponent::Update(float fTime, GameObject* pOwner) { moveIdle(fTime, pOwner); }