added tileson still debugging
This commit is contained in:
@ -76,12 +76,11 @@ int last_time;
|
||||
int current_time;
|
||||
int diff_time;
|
||||
|
||||
//tson::Tileson t;
|
||||
|
||||
int Game::pTileX = 0;
|
||||
int Game::pTileY = 0;
|
||||
|
||||
tson::Tileson t;
|
||||
std::unique_ptr<tson::Map> map = t.parse(std::filesystem::path("../../assets/maps/testmap.json"));
|
||||
|
||||
std::string Game::BoolToString(bool b) {
|
||||
std::string myString;
|
||||
if (b) {
|
||||
@ -247,30 +246,35 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
|
||||
// ---------------------------------------
|
||||
// Tileson tryout
|
||||
printf("Trying out Tileson, does it work?");
|
||||
if(map->getStatus() == tson::ParseStatus::OK)
|
||||
{
|
||||
printf("Tileson successfully parsed the tilemap");
|
||||
//Gets the layer called "Object Layer" from the "ultimate_demo.json map
|
||||
tson::Layer *tileLayer = map->getLayer("Tile Layer 1"); //This is an Object Layer
|
||||
|
||||
//Example from a Tile Layer
|
||||
//I know for a fact that this is a Tile Layer, but you can check it this way to be sure.
|
||||
if(tileLayer->getType() == tson::LayerType::TileLayer)
|
||||
{
|
||||
//pos = position in tile units
|
||||
printf("Tileson found layer of tiles");
|
||||
/*for(auto &[pos, tileObject] : tileLayer->getTileObjects()) //Loops through absolutely all existing tileObjects
|
||||
{
|
||||
tson::Tileset *tileset = tileObject.getTile()->getTileset();
|
||||
tson::Rect drawingRect = tileObject.getDrawingRect();
|
||||
tson::Vector2f position = tileObject.getPosition();
|
||||
}*/
|
||||
}
|
||||
|
||||
} else {
|
||||
printf("Failed to load Tileson map");
|
||||
}
|
||||
// printf("Trying out Tileson, does it work?");
|
||||
//
|
||||
//
|
||||
// //std::unique_ptr<tson::Map> map = t.parse(std::filesystem::path("../../assets/maps/testmap.json"));
|
||||
// std::unique_ptr<tson::Map> map = t.parse(tson_files::_ULTIMATE_TEST_JSON, tson_files::_ULTIMATE_TEST_JSON_SIZE);
|
||||
//
|
||||
// if(map->getStatus() == tson::ParseStatus::OK)
|
||||
// {
|
||||
// printf("Tileson successfully parsed the tilemap");
|
||||
// //Gets the layer called "Object Layer" from the "ultimate_demo.json map
|
||||
// //tson::Layer *tileLayer = map->getLayer("Tile Layer 1"); //This is an Object Layer
|
||||
//
|
||||
// //Example from a Tile Layer
|
||||
// //I know for a fact that this is a Tile Layer, but you can check it this way to be sure.
|
||||
// // if(tileLayer->getType() == tson::LayerType::TileLayer)
|
||||
// // {
|
||||
// // //pos = position in tile units
|
||||
// // printf("Tileson found layer of tiles");
|
||||
// // /*for(auto &[pos, tileObject] : tileLayer->getTileObjects()) //Loops through absolutely all existing tileObjects
|
||||
// // {
|
||||
// // tson::Tileset *tileset = tileObject.getTile()->getTileset();
|
||||
// // tson::Rect drawingRect = tileObject.getDrawingRect();
|
||||
// // tson::Vector2f position = tileObject.getPosition();
|
||||
// // }*/
|
||||
// // }
|
||||
//
|
||||
// } else {
|
||||
// printf("Failed to load Tileson map");
|
||||
// }
|
||||
|
||||
playerPosition = Vector2D().Zero();
|
||||
pVel = Vector2D().Zero();
|
||||
@ -326,8 +330,8 @@ void Game::update()
|
||||
|
||||
if (Mix_PlayingMusic() == 0 && gsm->currentState == GameStateManager::ST_COREGAME)
|
||||
{
|
||||
std::cout << "Play Music Now" << std::endl;
|
||||
Mix_PlayMusic(assets->GetMusicTrack("simonZ"), -1);
|
||||
// std::cout << "Play Music Now" << std::endl;
|
||||
// Mix_PlayMusic(assets->GetMusicTrack("simonZ"), -1);
|
||||
}
|
||||
if (Mix_PlayingMusic() != 0 && gsm->currentState != GameStateManager::ST_COREGAME)
|
||||
{
|
||||
|
Reference in New Issue
Block a user