-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel.cpp
More file actions
37 lines (30 loc) · 852 Bytes
/
level.cpp
File metadata and controls
37 lines (30 loc) · 852 Bytes
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
#include "level.h"
Level::Level() {
bricks = new GameObject[MAP_SIZE];
image = NULL;
}
Level::~Level() {
delete[] bricks;
}
void Level::init(Texture2D& default_texture) {
image = &default_texture;
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
bricks[j + i * 20].pos.x = -1.0f + i / 10.0f + 1 / 20.0f;
bricks[j + i * 20].pos.y = -1.0f + j / 10.0f + 1 / 20.0f;
bricks[j + i * 20].size.x = 1 / 20.0f;
bricks[j + i * 20].size.y = 1 / 20.0f;
bricks[j + i * 20].image = NULL;
bricks[j + i * 20].cols = 2;
bricks[j + i * 20].rows = 2;
}
}
for (int i = 0; i < 20 * 20; i++) {
bricks[i].frame = i % 3;
if (i%3) bricks[i].solid = true;
}
}
void Level::loadLevel(const char* const file) {
std::string vs = Utility::getFileData(file);
const char* cvs = vs.c_str();
}