debugging loadmap
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,6 +1,6 @@
|
|||||||
macos:
|
macos:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -lSDL2_image -lSDL2_mixer -o bin/volcano_macos
|
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -o bin/volcano_macos
|
||||||
linux:
|
linux:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -lSDL2_image -lSDL2_mixer -o bin/volcano_macos
|
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -o bin/volcano_macos
|
||||||
@@ -8,8 +8,14 @@
|
|||||||
#include "volcano.h"
|
#include "volcano.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define CLOSE_SOUND(a) if (a != nullptr) JA_DeleteSound(a); a = nullptr
|
#define CLOSE_SOUND(a) \
|
||||||
#define CLOSE_MUSIC(a) if (a != nullptr) JA_DeleteMusic(a); a = nullptr
|
if (a != nullptr) \
|
||||||
|
JA_DeleteSound(a); \
|
||||||
|
a = nullptr
|
||||||
|
#define CLOSE_MUSIC(a) \
|
||||||
|
if (a != nullptr) \
|
||||||
|
JA_DeleteMusic(a); \
|
||||||
|
a = nullptr
|
||||||
|
|
||||||
void allocatePointers()
|
void allocatePointers()
|
||||||
{
|
{
|
||||||
@@ -259,7 +265,7 @@ void setExecutablePath(std::string path)
|
|||||||
executablePath = path.substr(0, path.find_last_of("\\/"));
|
executablePath = path.substr(0, path.find_last_of("\\/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadMap()
|
/*void LoadMap_old()
|
||||||
{
|
{
|
||||||
std::string p = executablePath + "/" + FILE_MAP_VOLCANO.c_str();
|
std::string p = executablePath + "/" + FILE_MAP_VOLCANO.c_str();
|
||||||
std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
||||||
@@ -291,6 +297,63 @@ void LoadMap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void LoadMap()
|
||||||
|
{
|
||||||
|
std::string p = executablePath + "/" + FILE_MAP_VOLCANO.c_str();
|
||||||
|
std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
||||||
|
|
||||||
|
SDL_RWops *file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||||
|
Uint8 *w = new Uint8();
|
||||||
|
Uint8 *h = new Uint8();
|
||||||
|
Uint8 column = 0;
|
||||||
|
Uint8 line = 0;
|
||||||
|
Uint8 room = 0;
|
||||||
|
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
printf("Warning: Unable to open %s file\n", filename.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Reading file %s\n", filename.c_str());
|
||||||
|
|
||||||
|
SDL_RWread(file, w, sizeof(Uint8), 1);
|
||||||
|
SDL_RWread(file, h, sizeof(Uint8), 1);
|
||||||
|
|
||||||
|
long size = (*w) * (*h);
|
||||||
|
|
||||||
|
map.tile = new Uint8[size];
|
||||||
|
map.actor = new Uint8[size];
|
||||||
|
|
||||||
|
for (Uint32 i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
SDL_RWread(file, &map.tile[i], sizeof(Uint8), 1);
|
||||||
|
column++;
|
||||||
|
//std::cout << std::to_string(map.tile[i]);
|
||||||
|
printf("%-3s ", std::to_string(map.tile[i]).c_str());
|
||||||
|
if (column == ROOM_WIDTH_IN_TILES)
|
||||||
|
{
|
||||||
|
column = 0;
|
||||||
|
line++;
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
if (line == ROOM_HEIGHT_IN_TILES)
|
||||||
|
{
|
||||||
|
line = 0;
|
||||||
|
printf("==================== ROOM #%-3s =================================\n", std::to_string(room).c_str());
|
||||||
|
room++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Uint32 i = 0; i < size; i++)
|
||||||
|
SDL_RWread(file, &map.actor[i], sizeof(Uint8), 1);
|
||||||
|
|
||||||
|
SDL_RWclose(file);
|
||||||
|
}
|
||||||
|
delete w;
|
||||||
|
delete h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadRoom(int num)
|
void LoadRoom(int num)
|
||||||
@@ -1410,10 +1473,7 @@ void DrawMap()
|
|||||||
src_rect1.y = (GetTile(i, j) / 16) * MAP_TILE_HEIGHT;
|
src_rect1.y = (GetTile(i, j) / 16) * MAP_TILE_HEIGHT;
|
||||||
dst_rect1.x = i * MAP_TILE_WIDTH;
|
dst_rect1.x = i * MAP_TILE_WIDTH;
|
||||||
dst_rect1.y = j * MAP_TILE_HEIGHT;
|
dst_rect1.y = j * MAP_TILE_HEIGHT;
|
||||||
// DES 2021
|
map.sprite_tile->render(renderer, dst_rect1.x, dst_rect1.y, &src_rect1, 45.0);
|
||||||
map.sprite_tile->render(renderer, dst_rect1.x, dst_rect1.y, &src_rect1);
|
|
||||||
// END
|
|
||||||
//map.sprite_tile->render(renderer, dst_rect1.x, dst_rect1.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8 i = 0;
|
Uint8 i = 0;
|
||||||
@@ -1741,7 +1801,7 @@ void IniProgram()
|
|||||||
prog.music_enabled = true;
|
prog.music_enabled = true;
|
||||||
prog.filter = true;
|
prog.filter = true;
|
||||||
SetProgSection(SECTION_MENU);
|
SetProgSection(SECTION_MENU);
|
||||||
prog.debug = false;
|
prog.debug = true;
|
||||||
|
|
||||||
/*if (prog.music_enabled) // [TODO] Jail_Audio encara no permet canviar el volum
|
/*if (prog.music_enabled) // [TODO] Jail_Audio encara no permet canviar el volum
|
||||||
Mix_VolumeMusic(100);
|
Mix_VolumeMusic(100);
|
||||||
|
|||||||
Reference in New Issue
Block a user