-
Notifications
You must be signed in to change notification settings - Fork 1
/
playerDeath.cpp
55 lines (48 loc) · 1.23 KB
/
playerDeath.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <cmath>
#include "playerDeath.h"
#include "gamedata.h"
#include <limits>
using std::cout; using std::endl;
void PlayerDeath::advanceFrame(Uint32 ticks) {
// Frame animation specialized for a dying crow (rip):
timeSinceLastFrame += ticks;
if (timeSinceLastFrame > deathInterval) {
if (currentFrame < numberOfFrames-1) {
++currentFrame;
}
timeSinceLastFrame = 0;
}
}
PlayerDeath::
PlayerDeath(const std::string& name, const std::vector<Frame*>& fm) :
MultiframeSprite(name, fm, 1.0),
dead(false),
timeSinceLastFrame( 0 ),
deathInterval(Gamedata::getInstance()->getXmlInt(name+"DeadAfter")*1000)
{ }
PlayerDeath::PlayerDeath(const PlayerDeath& s) :
MultiframeSprite(s),
dead(s.dead),
timeSinceLastFrame( 0 ),
deathInterval(s.deathInterval)
{ }
PlayerDeath& PlayerDeath::operator=(const PlayerDeath& rhs) {
//MultiframeSprite::operator=(rhs);
dead = rhs.dead;
std::cout << "FIX THIS" << std::endl;
return *this;
}
void PlayerDeath::update(Uint32 ticks) {
if(timeSinceLastFrame < deathInterval){
if ( Y() + frameHeight >= worldHeight ){
velocityX(0);
velocityY(0);
}
timeSinceLastFrame += ticks;
MultiframeSprite::update(ticks);
}
else {
dead = true;
}
}