![]() |
|
This thread is locked; no one can reply to it.
![]() ![]() |
1
2
|
load_bitmap trouble |
Raf Vermeulen
Member #7,166
April 2006
|
I started a new project today, prototyping an addition to a game engine I already have. I pretty much took over all initialization code and the basic objects from the existing code (which works fine), but stripped the unnecessary parts out (like animation code, as I don't plan on animations on the prototype for now) The dumb thing is, that it doesn't want to load the tileset... Tile::Tile() : /* deze methode is sneller dan wanneer ze in de constructor staan */ size(32), type(0) { if(!m_tile) load_tileset("Gfx/Tile.bmp"); if (!m_tile) cout << "Spritesheet not loaded\n"; } (file classes.cpp) void Tile::load_tileset(const char *tileset) { Tile::m_tile = load_bitmap(tileset, NULL); } as the output always gives: "Spritesheet not loaded". m_tile is a static, protected bitmap in Tile, btw. |
piccolo
Member #3,163
January 2003
![]() |
i think you posted the wrong version of the code. in this version there are a lot of return errors and it wont compile. wow |
Raf Vermeulen
Member #7,166
April 2006
|
I only got one version. What're the errors it gives there? Might have something to do with the problem. The IDE I use, is Dev-C++ v.4.9.9.2, with the standard compiler coming with it and with the Allegro linker parameter. |
piccolo
Member #3,163
January 2003
![]() |
there are more tell me when you get the code to the state where you said you had the problem then ill down load the code. wow |
Raf Vermeulen
Member #7,166
April 2006
|
Got some trouble with placing the virtual int get_index() part. It keeps saying "virtual outside class declaration" |
piccolo
Member #3,163
January 2003
![]() |
i c so you did not have a problem with any loading of any map:-X ill take a look at the current code then. wow |
Raf Vermeulen
Member #7,166
April 2006
|
The problem's with loading the spritesheet;) If I reinstate the draw-function, the program crashes as it doesn't load the bitmap. |
piccolo
Member #3,163
January 2003
![]() |
well i tried i wont be able to do it to night there is just to many things to change and fix. take a look at this site this is where I and a lot of other people learned about tile maps. http://agdn.netfirms.com/main/ word of advice compile more so your error don't build up like they have. this site has a 7 lesson plan that you should follow about making tile maps and editors. wow |
Raf Vermeulen
Member #7,166
April 2006
|
Ok, thanks. I'll read up on it. |
piccolo
Member #3,163
January 2003
![]() |
feel free to message me about any one of the tutorials be cause i have completed them all.;D wow |
Raf Vermeulen
Member #7,166
April 2006
|
Hmmm, I went through all the tutorials, but they didn't tell me how to fix the spritesheet loading. It was an interesting read, though. |
piccolo
Member #3,163
January 2003
![]() |
they use sprite sheets in those tutorials. wow |
Raf Vermeulen
Member #7,166
April 2006
|
Yeah, but so do I in my other code, and it all works, both in that other code and in that tutorial, but I do the same thing in this code, but it doesn't work here =S |
piccolo
Member #3,163
January 2003
![]() |
in your code you have a lot of basic errors stacked on top of each other. wow |
Raf Vermeulen
Member #7,166
April 2006
|
Hmmm... same thing for the other code (the one from that thread from yesterday), or'm I missing something? That one worked. This one compiles (here, at least), but doesn't work in runtime, so there must be a difference somewhere which I can't spot. What errors's it give there when compiling? |
piccolo
Member #3,163
January 2003
![]() |
in your code you have a lot of basic errors stacked on top of each other. wow |
Raf Vermeulen
Member #7,166
April 2006
|
How'm I supposed to fix these errors if my compiler doesn't give any and if you don't tell me what they are when you notice them???? |
CGamesPlay
Member #2,559
July 2002
![]() |
How do you run the program? Most likely the problem is that you are in a different directory that you think you are. -- Ryan Patterson - <http://cgamesplay.com/> |
Raf Vermeulen
Member #7,166
April 2006
|
I've tried running it from Dev-C++ right after compiling, from inside the directory, and from inside the other code's directory (which uses the same subfolder and spritesheet's filename), and it all does the same. |
CGamesPlay
Member #2,559
July 2002
![]() |
Try putting this code in the load_tileset function: if(!file_exists(tileset)) cerr << "Spritesheet does not exist at location " << tileset << "!" << endl; else if((m_tile = load_bitmap(tileset, NULL)) == NULL) cerr << "Spritesheet exists, but failed to load!" << endl;
-- Ryan Patterson - <http://cgamesplay.com/> |
Raf Vermeulen
Member #7,166
April 2006
|
Ok, file_exists didn't quite work (didn't want to compile, and if I added 0, NULL, it gave runtime crashes), so I did it like this: FILE * file; file = fopen(tileset,"r"); if (!file) cout << "Error with opening of file\n"; else cout << "Could open file\n"; fclose(file); if( (Tile::m_tile = load_bitmap(tileset, NULL)) == NULL) cout << "PROBLEM!\n";
The output of this is: So it can reach the file, but something's wrong with the load_bitmap part. Not much that can be done wrong with that, though =S |
CGamesPlay
Member #2,559
July 2002
![]() |
So, what are your color conversion settings? (Do you call set_color_conversion?) What is your color depth? If you compile using the debug version of Allegro, do you get an assertion failure? -- Ryan Patterson - <http://cgamesplay.com/> |
Raf Vermeulen
Member #7,166
April 2006
|
I don't know how to compile with the debug version. Color depth's set to 16. Set_color_conversion's not called. The graphical mode's set like this: set_color_depth(16); if(set_gfx_mode( GFX_AUTODETECT_WINDOWED, SCR_WIDTH, SCR_HEIGHT, 0, 0)) exit(1); buffer = create_bitmap(WIDTH*32, HEIGHT*32); That's the same as in the other code, where it does load the tileset. I also tried loading the tileset from the other code, and that gives the same problem. |
Kauhiz
Member #4,798
July 2004
|
Quote: I also tried loading the tileset from the other code, and that gives the same problem. Hmm, I wonder where the problem could be, then... --- |
CGamesPlay
Member #2,559
July 2002
![]() |
You should write a simple test case to load the bitmap and blit it to the screen in as few lines as possible. Don't put the bitmap in a subdirectory or anything, just load and blit. I want to see if this is a problem with Allegro. -- Ryan Patterson - <http://cgamesplay.com/> |
|
1
2
|