-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackgroundTile.cpp
More file actions
55 lines (54 loc) · 2.54 KB
/
BackgroundTile.cpp
File metadata and controls
55 lines (54 loc) · 2.54 KB
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
55
#include "BackgroundTile.h"
#include "renderContext.h"
#include "gameData.h"
void BackgroundTile::draw() const {
tile->draw(getX(), getY(), getScale());
}
/*==============================================================================
==============================================================================*/
void BackgroundTile::update(Uint32 ticks) { life_span += ticks; }
/*==============================================================================
==============================================================================*/
int BackgroundTile::getScaledWidth() const {
return getScale() * tile->getWidth();
}
/*==============================================================================
==============================================================================*/
int BackgroundTile::getScaledHeight() const {
return getScale() * tile->getHeight();
}
/*==============================================================================
==============================================================================*/
const Image* BackgroundTile::getImage() const {
return tile;
}
/*==============================================================================
==============================================================================*/
const SDL_Surface* BackgroundTile::getSurface() const {
return tile->getSurface();
}
/*==============================================================================
==============================================================================*/
BackgroundTile::BackgroundTile(const std::string& tile_id,
int x, int y, int _ID) :
Drawable(tile_id, Vector2f(x, y), Vector2f(0, 0), 1.0),
ID(_ID),
tile( ImageFactory::getInstance().getImage(tile_id) ),
life_span(0) {
/* Set item states and walkable state based on the ID based in. */
switch (ID) {
case 1: isWalkable = false; item_on_tile = false; break;
case 2: isWalkable = false; item_on_tile = false; break;
case 3: isWalkable = true; item_on_tile = false; break;
case 4: isWalkable = true; item_on_tile = true; break;
case 5: isWalkable = false; item_on_tile = false; break;
case 6: isWalkable = false; item_on_tile = false; break;
case 7: isWalkable = false; item_on_tile = false; break;
case 8: isWalkable = false; item_on_tile = false; break;
}
}
/*==============================================================================
==============================================================================*/
BackgroundTile::~BackgroundTile() {
// delete tile;
}