Allegro bitmap is null even when initialized
Hello folks I've come across this problem where my bitmap will not become initialized.
I've doubled checked my code and I can't see anything wrong, but it might be because I'm pretty tired atm.
Here is the relevant code;
Main.cpp - This isn't really relevant code, just another question here, is this a proper way of approaching what I am trying to accomplish? A small 2D game:
const float FPS = 60.0;
const float frameFPS = 10.0;
initialize *init = new initialize();
Character::Character(std::string filePath, std::string n, int var, int var2, int speed)
image = al_load_bitmap(filePath.c_str());
if(image == NULL)
std::cout << filePath.c_str() << " could not be loaded." << std::endl;
name = n;
maxHealth = 10, health = maxHealth;
x = var, y = var2, this->speed = speed;
No, the image is certainly there.. I will post the rest of the code in 2-3 minutes.
display = NULL;
event_queue = NULL;
timer = NULL;
frameTimer = NULL;
loop = true, redraw = false;
No, the image is certainly there.
Stick a al_filename_exists("player.png") somewhere and make sure it returns true. The only other real reason it wouldn't work is if the image addon was compiled without png support (unlikely unless you compiled it yourself) or the png file itself is corrupted.
I am pretty sure that the image file is NOT corrupted, that being said I've both jpg and bmp too which I just saved in paint which usually works.. I'm using pre-compiled Allegro 5.0.10 bins.
Edit: I tried al_filename_exists("player.png") and it returns true.
Edit edit: The program works now ALL OF A SUDDEN!?!? I haven't changed a thing.
I still do appreciate everyone's help, thanks
Thread #615086. Printed from Allegro.cc
Hm, random things happing tend to mean you have a memory corruption issue change a line of code, even adding a printf can "hide" them temporarily.