-
Notifications
You must be signed in to change notification settings - Fork 1
/
Freeze.cpp
49 lines (41 loc) · 1.24 KB
/
Freeze.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
#include "Freeze.h"
Freeze::Freeze() : Entity() {
spriteData.width = freezeNS::WIDTH;
spriteData.height = freezeNS::HEIGHT;
spriteData.rect.bottom = freezeNS::HEIGHT;
spriteData.rect.right = freezeNS::WIDTH;
spriteData.scale = freezeNS::SCALING;
velocity.x = 0;
velocity.y = 0;
startFrame = freezeNS::START_FRAME;
endFrame = freezeNS::END_FRAME;
currentFrame = startFrame;
radius = freezeNS::WIDTH / 2.0f;
collisionType = entityNS::CIRCLE;
objectType = OBJECT_TYPE_FREEZE;
frameDelay = 0.01f;
health = 999;
}
bool Freeze::initialize(Game *gamePtr, int width, int height, int ncols, TextureManager *textureM) {
return(Entity::initialize(gamePtr, width, height, ncols, textureM));
}
void Freeze::draw() {
Image::draw();
}
void Freeze::update(float deltaTime) {
Entity::update(deltaTime);
if (currentFrame == endFrame) {
setHealth(0);
}
}
void Freeze::setNewLocation() {
setX(GAME_WIDTH / 2 - freezeNS::WIDTH / 2 * freezeNS::SCALING);
setY(GAME_HEIGHT / 2 - freezeNS::WIDTH / 2 * freezeNS::SCALING);
}
void Freeze::spawn() {
setFrames(freezeNS::START_FRAME, freezeNS::END_FRAME);
setCurrentFrame(freezeNS::START_FRAME);
setNewLocation();
setFrameDelay(freezeNS::ANIMATION_DELAY);
setRect();
}