halsafar/libtmx-parser added to project
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
|
||||
#include "Game.hpp"
|
||||
#include "../assetmgr/TextureManager.h"
|
||||
#include "../assetmgr/Map.h"
|
||||
// #include "../assetmgr/Map.h"
|
||||
#include "../ecs/Components.h"
|
||||
#include "Collision.h"
|
||||
#include <string>
|
||||
@ -21,8 +21,10 @@
|
||||
// #include "../ui/UIText.h"
|
||||
#include "../ui/UINineSlice.h"
|
||||
#include "../cjson/cJSON.h"
|
||||
#include "tmxparser.h"
|
||||
|
||||
Map* map;
|
||||
|
||||
// Map* map;
|
||||
Manager manager;
|
||||
UINineSlice* my9Slice;
|
||||
UINineSlice* scoreboard9Slice;
|
||||
@ -117,7 +119,17 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Couldn't initialize SDL audio mixer!, Error: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
|
||||
// Trying out the halsafar/libtmx-parser
|
||||
tmxparser::TmxReturn error;
|
||||
tmxparser::TmxMap map;
|
||||
error = tmxparser::parseFromFile("assets/maps/testmap.tmx", &map, "assets/textures/tiles/");
|
||||
// current_time = SDL_GetTicks();
|
||||
if (!error)
|
||||
{
|
||||
printf("Yay! Tile map loaded with no errors.\n");
|
||||
std::cout << "Map width: " << map.width << " tiles wide by: " << map.height << " tiles high" << std::endl;
|
||||
}
|
||||
|
||||
assets->AddTexture("terrain", "assets/textures/tiles/br-tiles.png");
|
||||
assets->AddTexture("player", "assets/textures/actors/firefighter.png");
|
||||
@ -133,7 +145,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
assets->AddSoundClip("bark1","assets/audio/sfx/Bark1.wav");
|
||||
assets->AddSoundClip("bark2","assets/audio/sfx/Bark2.wav");
|
||||
|
||||
map = new Map("terrain",globalScale,16);
|
||||
// map = new Map("terrain",globalScale,16);
|
||||
|
||||
// std::string myText = "Find lost puppies!\nThey need your help!";
|
||||
std::string myText = "Press U to Start";
|
||||
@ -171,7 +183,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
|
||||
//ecs implementation
|
||||
|
||||
map->LoadMap("assets/maps/br-map-color.txt",70,45, globalScale);
|
||||
// map->LoadMap("assets/maps/br-map-color.txt",70,45, globalScale);
|
||||
|
||||
player.addComponent<TransformComponent>(860*globalScale,640*globalScale,22,42,globalScale);
|
||||
player.addComponent<SpriteComponent>("player", SpriteComponent::spriteAnimation, "assets/textures/actors/firefighter.json");
|
||||
@ -298,10 +310,10 @@ void Game::update()
|
||||
camera.x = 0;
|
||||
if (camera.y < 0)
|
||||
camera.y = 0;
|
||||
if (camera.x > map->width-camera.w)
|
||||
camera.x = map->width-camera.w;
|
||||
if (camera.y > map->height-camera.h)
|
||||
camera.y = map->height-camera.h;
|
||||
// if (camera.x > map->width-camera.w)
|
||||
// camera.x = map->width-camera.w;
|
||||
// if (camera.y > map->height-camera.h)
|
||||
// camera.y = map->height-camera.h;
|
||||
if (Game::debugCollisionBoxes)
|
||||
{
|
||||
for (auto& c: colliders)
|
||||
|
Reference in New Issue
Block a user