summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2015-03-14 21:02:01 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2015-03-14 21:02:01 -0400
commitb563953a4846bab720cae17ef4ab5a8296730c7c (patch)
treee585bda1e4a8b979c8864cd25a84f663122c83b7 /src
parent6b1dcc5df51df4a2d8b724187eb1bcdb4fd9df8b (diff)
downloadtherapy-b563953a4846bab720cae17ef4ab5a8296730c7c.tar.gz
therapy-b563953a4846bab720cae17ef4ab5a8296730c7c.tar.bz2
therapy-b563953a4846bab720cae17ef4ab5a8296730c7c.zip
Started writing map editor
Diffstat (limited to 'src')
-rw-r--r--src/components/map_collision.cpp2
-rw-r--r--src/components/map_render.cpp2
-rw-r--r--src/game.h2
-rw-r--r--src/map.cpp8
4 files changed, 7 insertions, 7 deletions
diff --git a/src/components/map_collision.cpp b/src/components/map_collision.cpp index f385320..9afa6f8 100644 --- a/src/components/map_collision.cpp +++ b/src/components/map_collision.cpp
@@ -7,7 +7,7 @@ MapCollisionComponent::MapCollisionComponent(const Map& map) : map(map)
7 addCollision(-6, 0, GAME_WIDTH, Direction::left, (map.getLeftMap() == nullptr) ? Collision::Type::wrap : Collision::Type::teleport); 7 addCollision(-6, 0, GAME_WIDTH, Direction::left, (map.getLeftMap() == nullptr) ? Collision::Type::wrap : Collision::Type::teleport);
8 addCollision(GAME_WIDTH+6, 0, GAME_WIDTH, Direction::right, (map.getRightMap() == nullptr) ? Collision::Type::reverse : Collision::Type::teleport); 8 addCollision(GAME_WIDTH+6, 0, GAME_WIDTH, Direction::right, (map.getRightMap() == nullptr) ? Collision::Type::reverse : Collision::Type::teleport);
9 9
10 for (int i=0; i<MAP_WIDTH*(MAP_HEIGHT-1); i++) 10 for (int i=0; i<MAP_WIDTH*MAP_HEIGHT; i++)
11 { 11 {
12 int x = i % MAP_WIDTH; 12 int x = i % MAP_WIDTH;
13 int y = i / MAP_WIDTH; 13 int y = i / MAP_WIDTH;
diff --git a/src/components/map_render.cpp b/src/components/map_render.cpp index d93afe6..6fdfcc3 100644 --- a/src/components/map_render.cpp +++ b/src/components/map_render.cpp
@@ -8,7 +8,7 @@ MapRenderComponent::MapRenderComponent(const Map& map) : screen(GAME_WIDTH, GAME
8 8
9 Texture tiles("../res/tiles.png"); 9 Texture tiles("../res/tiles.png");
10 10
11 for (int i=0; i<MAP_WIDTH*(MAP_HEIGHT-1); i++) 11 for (int i=0; i<MAP_WIDTH*MAP_HEIGHT; i++)
12 { 12 {
13 int tile = map.getMapdata()[i]; 13 int tile = map.getMapdata()[i];
14 int x = i % MAP_WIDTH; 14 int x = i % MAP_WIDTH;
diff --git a/src/game.h b/src/game.h index a4620d4..1818cec 100644 --- a/src/game.h +++ b/src/game.h
@@ -14,7 +14,7 @@ const int TILE_HEIGHT = 8;
14const int GAME_WIDTH = 320; 14const int GAME_WIDTH = 320;
15const int GAME_HEIGHT = 200; 15const int GAME_HEIGHT = 200;
16const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH; 16const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH;
17const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT; 17const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1;
18 18
19const int FRAMES_PER_SECOND = 60; 19const int FRAMES_PER_SECOND = 60;
20const double SECONDS_PER_FRAME = 1.0 / FRAMES_PER_SECOND; 20const double SECONDS_PER_FRAME = 1.0 / FRAMES_PER_SECOND;
diff --git a/src/map.cpp b/src/map.cpp index 73eb2b4..6b83442 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -50,9 +50,9 @@ Map::Map(const std::string name)
50 } else if (!xmlStrcmp(node->name, (const xmlChar*) "environment")) 50 } else if (!xmlStrcmp(node->name, (const xmlChar*) "environment"))
51 { 51 {
52 xmlChar* key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1); 52 xmlChar* key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
53 mapdata = (int*) malloc(MAP_WIDTH*(MAP_HEIGHT-1)*sizeof(int)); 53 mapdata = (int*) malloc(MAP_WIDTH*MAP_HEIGHT*sizeof(int));
54 mapdata[0] = atoi(strtok((char*) key, ",\n")); 54 mapdata[0] = atoi(strtok((char*) key, ",\n"));
55 for (int i=1; i<(MAP_WIDTH*(MAP_HEIGHT-1)); i++) 55 for (int i=1; i<(MAP_WIDTH*MAP_HEIGHT); i++)
56 { 56 {
57 mapdata[i] = atoi(strtok(NULL, ",\n")); 57 mapdata[i] = atoi(strtok(NULL, ",\n"));
58 } 58 }
@@ -100,8 +100,8 @@ Map::Map(const std::string name)
100 100
101Map::Map(const Map& map) 101Map::Map(const Map& map)
102{ 102{
103 mapdata = (int*) malloc(MAP_WIDTH*(MAP_HEIGHT-1)*sizeof(int)); 103 mapdata = (int*) malloc(MAP_WIDTH*MAP_HEIGHT*sizeof(int));
104 memcpy(mapdata, map.mapdata, MAP_WIDTH*(MAP_HEIGHT-1)*sizeof(int)); 104 memcpy(mapdata, map.mapdata, MAP_WIDTH*MAP_HEIGHT*sizeof(int));
105 105
106 title = (char*) malloc((MAP_WIDTH+1)*sizeof(char)); 106 title = (char*) malloc((MAP_WIDTH+1)*sizeof(char));
107 strncpy(title, map.title, MAP_WIDTH+1); 107 strncpy(title, map.title, MAP_WIDTH+1);