fixed PRINT_LOG in samples
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
This commit is contained in:
@@ -17,12 +17,12 @@ class String
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char *createU32ToString(u32 a);
|
static char *createU32ToString(const u32 a);
|
||||||
static char *createWithLeadingZeros(char *a);
|
static char *createWithLeadingZeros(const char *a);
|
||||||
static char *createCopy(char *source);
|
static char *createCopy(const char *source);
|
||||||
static u32 getLength(char *a);
|
static u32 getLength(const char *a);
|
||||||
static char *createConcatenated(char *a, char *b);
|
static char *createConcatenated(const char *a, const char *b);
|
||||||
static char *createWithoutExtension(char *source);
|
static char *createWithoutExtension(const char *source);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
|
|||||||
u32 sig_read = 0, row = 0, i = 0, j = 0;
|
u32 sig_read = 0, row = 0, i = 0, j = 0;
|
||||||
int bit_depth, color_type, interlace_type;
|
int bit_depth, color_type, interlace_type;
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL);
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
assertMsg(png_ptr, "PNG struct info init failed(1)!");
|
assertMsg(png_ptr, "PNG read struct init failed!");
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
assertMsg(info_ptr, "PNG struct info init failed(2)!");
|
assertMsg(info_ptr, "PNG info struct init failed!");
|
||||||
assertMsg(!setjmp(png_jmpbuf(png_ptr)), "PNG reader fatal error!");
|
assertMsg(!setjmp(png_jmpbuf(png_ptr)), "PNG reader fatal error!");
|
||||||
|
|
||||||
png_init_io(png_ptr, file);
|
png_init_io(png_ptr, file);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define CHAR_BIT 8
|
#define CHAR_BIT 8
|
||||||
|
|
||||||
char *String::createU32ToString(u32 a)
|
char *String::createU32ToString(const u32 a)
|
||||||
{
|
{
|
||||||
char *result = new char[(((sizeof a) * CHAR_BIT) + 2) / 3 + 2];
|
char *result = new char[(((sizeof a) * CHAR_BIT) + 2) / 3 + 2];
|
||||||
sprintf(result, "%d", a);
|
sprintf(result, "%d", a);
|
||||||
@@ -21,7 +21,7 @@ char *String::createU32ToString(u32 a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Converts "123" to "000123". 6 digits length */
|
/** Converts "123" to "000123". 6 digits length */
|
||||||
char *String::createWithLeadingZeros(char *a)
|
char *String::createWithLeadingZeros(const char *a)
|
||||||
{
|
{
|
||||||
const u8 digitsAmount = 6;
|
const u8 digitsAmount = 6;
|
||||||
char *part = createConcatenated("00000000", a);
|
char *part = createConcatenated("00000000", a);
|
||||||
@@ -35,7 +35,7 @@ char *String::createWithLeadingZeros(char *a)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *String::createWithoutExtension(char *source)
|
char *String::createWithoutExtension(const char *source)
|
||||||
{
|
{
|
||||||
u32 length = 0;
|
u32 length = 0;
|
||||||
for (;; length++)
|
for (;; length++)
|
||||||
@@ -48,7 +48,7 @@ char *String::createWithoutExtension(char *source)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *String::createCopy(char *source)
|
char *String::createCopy(const char *source)
|
||||||
{
|
{
|
||||||
u32 srcLength = getLength(source);
|
u32 srcLength = getLength(source);
|
||||||
char *res = new char[srcLength + 1];
|
char *res = new char[srcLength + 1];
|
||||||
@@ -59,7 +59,7 @@ char *String::createCopy(char *source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For test\0 will return 4
|
// For test\0 will return 4
|
||||||
u32 String::getLength(char *a)
|
u32 String::getLength(const char *a)
|
||||||
{
|
{
|
||||||
if (a == NULL)
|
if (a == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -68,7 +68,7 @@ u32 String::getLength(char *a)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *String::createConcatenated(char *a, char *b)
|
char *String::createConcatenated(const char *a, const char *b)
|
||||||
{
|
{
|
||||||
u32 aLength = getLength(a);
|
u32 aLength = getLength(a);
|
||||||
u32 bLength = getLength(b);
|
u32 bLength = getLength(b);
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ const float CAMERA_Y = 30.0F;
|
|||||||
|
|
||||||
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing camera");
|
consoleLog("Initializing camera");
|
||||||
verticalLevel = 80.0F;
|
verticalLevel = 80.0F;
|
||||||
PRINT_LOG("Camera initialized!");
|
consoleLog("Camera initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera::~Camera() {}
|
Camera::~Camera() {}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
Cubes::Cubes(Engine *t_engine)
|
Cubes::Cubes(Engine *t_engine)
|
||||||
: engine(t_engine), camera(&t_engine->screen)
|
: engine(t_engine), camera(&t_engine->screen)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initing cubes sample");
|
consoleLog("Initing cubes sample");
|
||||||
}
|
}
|
||||||
|
|
||||||
Cubes::~Cubes()
|
Cubes::~Cubes()
|
||||||
@@ -21,14 +21,16 @@ Cubes::~Cubes()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cubes::onInit(){
|
void Cubes::onInit()
|
||||||
|
{
|
||||||
texRepo = engine->renderer->getTextureRepository();
|
texRepo = engine->renderer->getTextureRepository();
|
||||||
cube = new Cube(texRepo);
|
cube = new Cube(texRepo);
|
||||||
setBgColorAndAmbientColor();
|
setBgColorAndAmbientColor();
|
||||||
engine->renderer->setCameraDefinitions(&camera.view, &camera.unitCirclePosition, camera.planes);
|
engine->renderer->setCameraDefinitions(&camera.view, &camera.unitCirclePosition, camera.planes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cubes::onUpdate(){
|
void Cubes::onUpdate()
|
||||||
|
{
|
||||||
camera.update(engine->pad, cube->mesh);
|
camera.update(engine->pad, cube->mesh);
|
||||||
cube->update(engine->pad, camera);
|
cube->update(engine->pad, camera);
|
||||||
engine->renderer->draw(cube->mesh);
|
engine->renderer->draw(cube->mesh);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
PRINT_LOG("INIT");
|
|
||||||
Engine engine = Engine();
|
Engine engine = Engine();
|
||||||
Cubes game = Cubes(&engine);
|
Cubes game = Cubes(&engine);
|
||||||
game.engine->init(&game, 128);
|
game.engine->init(&game, 128);
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
// Constructors/Destructors
|
// Constructors/Destructors
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
Cube::Cube( TextureRepository *t_texRepo )
|
Cube::Cube(TextureRepository *t_texRepo)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating cube");
|
consoleLog("Creating cube");
|
||||||
texRepo = t_texRepo;
|
texRepo = t_texRepo;
|
||||||
speed = 1.2F;
|
speed = 1.2F;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ Cube::Cube( TextureRepository *t_texRepo )
|
|||||||
|
|
||||||
texRepo->addByMesh("meshes/cube/", mesh, PNG);
|
texRepo->addByMesh("meshes/cube/", mesh, PNG);
|
||||||
|
|
||||||
PRINT_LOG("Cube object created!");
|
consoleLog("Cube object created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cube::update(const Pad &t_pad, const Camera &t_camera)
|
void Cube::update(const Pad &t_pad, const Camera &t_camera)
|
||||||
@@ -68,10 +68,11 @@ Vector3 *Cube::getNextPosition(const Pad &t_pad, const Camera &t_camera)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cube::rotate(const Pad &t_pad){
|
void Cube::rotate(const Pad &t_pad)
|
||||||
|
{
|
||||||
//if (t_pad.rJoyH >= 200)
|
//if (t_pad.rJoyH >= 200)
|
||||||
//else if (t_pad.rJoyH <= 100)
|
//else if (t_pad.rJoyH <= 100)
|
||||||
mesh.rotation.x += (0.01 * speed);
|
mesh.rotation.x += (0.01 * speed);
|
||||||
mesh.rotation.y += (0.01 * speed);
|
mesh.rotation.y += (0.01 * speed);
|
||||||
mesh.rotation.z += (0.01 * speed);
|
mesh.rotation.z += (0.01 * speed);
|
||||||
}
|
}
|
||||||
@@ -21,9 +21,9 @@ const float CAMERA_Y = 30.0F;
|
|||||||
|
|
||||||
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing camera");
|
consoleLog("Initializing camera");
|
||||||
verticalLevel = 80.0F;
|
verticalLevel = 80.0F;
|
||||||
PRINT_LOG("Camera initialized!");
|
consoleLog("Camera initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera::~Camera() {}
|
Camera::~Camera() {}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ FloorManager::~FloorManager()
|
|||||||
*/
|
*/
|
||||||
void FloorManager::calcSpiral(int X, int Y)
|
void FloorManager::calcSpiral(int X, int Y)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Calculating square spiral for floors");
|
consoleLog("Calculating square spiral for floors");
|
||||||
int x, y, dx;
|
int x, y, dx;
|
||||||
x = y = dx = 0;
|
x = y = dx = 0;
|
||||||
int dy = -1;
|
int dy = -1;
|
||||||
@@ -73,7 +73,7 @@ void FloorManager::calcSpiral(int X, int Y)
|
|||||||
x += dx;
|
x += dx;
|
||||||
y += dy;
|
y += dy;
|
||||||
}
|
}
|
||||||
PRINT_LOG("Square spiral calculated!");
|
consoleLog("Square spiral calculated!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize all floors by:
|
/** Initialize all floors by:
|
||||||
@@ -82,7 +82,7 @@ void FloorManager::calcSpiral(int X, int Y)
|
|||||||
*/
|
*/
|
||||||
void FloorManager::initFloors()
|
void FloorManager::initFloors()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing floors");
|
consoleLog("Initializing floors");
|
||||||
floors[0].mesh.loadObj("meshes/floor/", "floor", 3.0F, false);
|
floors[0].mesh.loadObj("meshes/floor/", "floor", 3.0F, false);
|
||||||
floors[0].mesh.shouldBeFrustumCulled = true;
|
floors[0].mesh.shouldBeFrustumCulled = true;
|
||||||
floors[0].mesh.shouldBeLighted = true;
|
floors[0].mesh.shouldBeLighted = true;
|
||||||
@@ -95,7 +95,7 @@ void FloorManager::initFloors()
|
|||||||
texRepo->getBySpriteOrMesh(floors[0].mesh.getMaterial(0).getId())->addLink(floors[i].mesh.getMaterial(0).getId());
|
texRepo->getBySpriteOrMesh(floors[0].mesh.getMaterial(0).getId())->addLink(floors[i].mesh.getMaterial(0).getId());
|
||||||
meshes[i] = &floors[i].mesh;
|
meshes[i] = &floors[i].mesh;
|
||||||
}
|
}
|
||||||
PRINT_LOG("Floors initialized!");
|
consoleLog("Floors initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Main floor loop.
|
/** Main floor loop.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
LightManager::LightManager()
|
LightManager::LightManager()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating light manager!");
|
consoleLog("Creating light manager!");
|
||||||
bulbsCount = 2;
|
bulbsCount = 2;
|
||||||
|
|
||||||
bulbs = new LightBulb[2];
|
bulbs = new LightBulb[2];
|
||||||
@@ -31,7 +31,7 @@ LightManager::LightManager()
|
|||||||
|
|
||||||
audioOffset = audioTick = 0;
|
audioOffset = audioTick = 0;
|
||||||
|
|
||||||
PRINT_LOG("Light manager created!");
|
consoleLog("Light manager created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
LightManager::~LightManager()
|
LightManager::~LightManager()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
Enemy::Enemy(TextureRepository *t_texRepo)
|
Enemy::Enemy(TextureRepository *t_texRepo)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating enemy object");
|
consoleLog("Creating enemy object");
|
||||||
|
|
||||||
meshes = new Mesh[getMeshesCount()];
|
meshes = new Mesh[getMeshesCount()];
|
||||||
drawMeshes = new Mesh *[getMeshesCount()];
|
drawMeshes = new Mesh *[getMeshesCount()];
|
||||||
@@ -48,7 +48,7 @@ Enemy::Enemy(TextureRepository *t_texRepo)
|
|||||||
|
|
||||||
isKilled = true;
|
isKilled = true;
|
||||||
|
|
||||||
PRINT_LOG("Enemy object created!");
|
consoleLog("Enemy object created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Enemy::~Enemy()
|
Enemy::~Enemy()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
Player::Player(Audio *t_audio, TextureRepository *t_texRepo)
|
Player::Player(Audio *t_audio, TextureRepository *t_texRepo)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating player object");
|
consoleLog("Creating player object");
|
||||||
texRepo = t_texRepo;
|
texRepo = t_texRepo;
|
||||||
audio = t_audio;
|
audio = t_audio;
|
||||||
gravity = 0.1F;
|
gravity = 0.1F;
|
||||||
@@ -53,7 +53,7 @@ Player::Player(Audio *t_audio, TextureRepository *t_texRepo)
|
|||||||
boomAdpcm = audio->loadADPCM("sounds/boom.adpcm");
|
boomAdpcm = audio->loadADPCM("sounds/boom.adpcm");
|
||||||
audio->setADPCMVolume(70, 0);
|
audio->setADPCMVolume(70, 0);
|
||||||
|
|
||||||
PRINT_LOG("Player object created!");
|
consoleLog("Player object created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player()
|
Player::~Player()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
Ui::Ui(TextureRepository *t_texRepo)
|
Ui::Ui(TextureRepository *t_texRepo)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing ui");
|
consoleLog("Initializing ui");
|
||||||
|
|
||||||
isTask1Done = false;
|
isTask1Done = false;
|
||||||
isTask2Done = false;
|
isTask2Done = false;
|
||||||
@@ -52,7 +52,7 @@ Ui::Ui(TextureRepository *t_texRepo)
|
|||||||
grayCheckboxTex->addLink(task1Checkbox.getId());
|
grayCheckboxTex->addLink(task1Checkbox.getId());
|
||||||
grayCheckboxTex->addLink(task2Checkbox.getId());
|
grayCheckboxTex->addLink(task2Checkbox.getId());
|
||||||
|
|
||||||
PRINT_LOG("Ui initialized!");
|
consoleLog("Ui initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::~Ui() {}
|
Ui::~Ui() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user