I have been going over this code for 2 days now trying to figure out why the background image for this loading screen will not appear. I have created an object named BG_INDEX that keeps track of all the background information for a given room including the background image, whether the background is tiled or stretched, and scrolling speeds. I also created an object named BG_CTRL that will handle the BG_INDEX objects; for example, during the loading phase it will create all of the BG_INDEX objects with all of the desired parameters and the main.cpp program interfaces through BG_CTRL to control the BG_INDEX from there on out.
The program executes without error and going through the code in debug mode line by line leads me to believe that each variable has been assigned the correct values and each function the correct parameters but for some reason the background image just never appears on the loading screen. Here is the code:
bg_ctrl.h:
bg_ctrl.cpp:
#include "bg_ctrl.h" BG_CTRL::BG_CTRL(){} BG_CTRL::~BG_CTRL(){} void BG_CTRL::initiate(){ bgIndex[LOAD].initiate( 102, 576, 380-102, 717-576, 1); bgIndex[MENU].initiate( 268, 367, 32, 32, 2, 0, 10); bgIndex[CREDITS].initiate( 268, 367, 32, 32, 2, 0, 10); } ALLEGRO_BITMAP* BG_CTRL::step(){ return bgIndex[roomIndex].step(); }
bg_index.h:
bg_index.cpp:
main.cpp:
BG_CTRL is referenced in main.cpp on lines 33, 52, and 96.
My logic for drawing the background the way I do is this:
I have a canvas which is huge and has room for a full extra tile on each side of it (so a scrolling image can go in any direction without drawing out of bounds) and I have a fullImage which is extended ONE tile past what is needed for the display because that's all that's needed to make the scrolling appearance and it draws to the canvas at the end of each step(). bgImage is made the same size as the display and will be directly drawn to the backbuffer. bgImage is made by extracting the middle of the canvas the same size as the display (keeping an extra "unseen" tile size on all sides to work the magic).
The problem is first noticeable on line 58 when the display should be updated (in update_progress_bar function called from load_game called from main())
]]>