Alright, so I fixed all the problems I had by following your instructions about the
conditional checks. It took me some time but with a little luck I was able to make it work after all!
Now I'd like to know how you would make a 2 by 3 map, where every time I get to the limit of a screen, it changes the background (and other components) and lets me go from screen to screen in my virtual map :o.. Not too sure if that made sense but here's what I did.
background.h
#ifndef BACKGROUND_H_
#define BACKGROUND_H_
using namespace std;
class Background
{
public:
int Generate_Background1();
int Generate_Background2();
int Generate_Background3();
int Generate_Background4();
int Generate_Background5();
int Generate_Background6();
// Background();
// ~Background);
private:
};
#endif
test_pos() (in my player1.h)
int Player1::test_pos()
{
Background background;
//SCREEN 1
//Screen 1 to Right
if ( (Screen == 1) && (dbSpriteX(playerID) >= 640) )
{
dbSetWindowTitle("Screen 4");
background.Generate_Background4();
dbSprite(playerID, (dbSpriteX(playerID) - 640), dbSpriteY(playerID), 4);
}
//Screen 1 to Top
if ( (Screen == 1) && (dbSpriteY(playerID) <= 0) )
{
dbSetWindowTitle("Screen 2");
background.Generate_Background2();
dbSprite(playerID, dbSpriteX(playerID), (dbSpriteY(playerID) + 474), 4);
}
//Screen 1 to Left
if ( (Screen == 1) && (dbSpriteX(playerID) <= 0) )
{
dbSetWindowTitle("Left Border");
dbSprite(playerID, 0, dbSpriteY(playerID), 4);
}
//Screen 1 to Bottom
if ( (Screen == 1) && (dbSpriteY(playerID) >= 475) )
{
dbSetWindowTitle("Bottom Border");
dbSprite(playerID, dbSpriteX(playerID), 475, 4);
}
//SCREEN 2
//Screen 2 to Top
if ( (Screen == 2) && (dbSpriteY(playerID) <= 0) )
{
background.Generate_Background3();
dbSprite(playerID, dbSpriteX(playerID), (dbSpriteY(playerID) + 473), 4);
}
//Screen 2 to Right
if ( (Screen == 2) && (dbSpriteX(playerID) >= 640) )
{
background.Generate_Background5();
dbSprite(playerID, (dbSpriteX(playerID) - 638), dbSpriteY(playerID), 4);
}
//Screen 2 to Bottom
if ( (Screen == 2) && (dbSpriteY(playerID) >= 475) )
{
background.Generate_Background1();
dbSprite(playerID, dbSpriteX(playerID), (dbSpriteY(playerID) - 473), 4);
}
//Screen 2 to Left
if ( (Screen == 2) && (dbSpriteX(playerID) <= 0) )
{
dbSprite(playerID, 0, dbSpriteY(playerID), 4);
}
if (Screen == 2)
{
dbSetWindowTitle("Screen 2 TRUE");
}
return 0;
}
Basically what I do is I have (or will have) six different screens, the way i'll make the game know whether it is screen #x or not is that i'll change the number in the 'Screen' variable every time I get to the extremes of the screens.
[what works now/and doesn't]:
FYI:Screen variable is initiated in main.cpp, outside the loop.
My first screen's left and bottom borders work fine.
When I go to the top, it'll put me into a screen that seems to not have been programmed with any borders but I clearly wrote 'Screen = 2' ... So I have no idea what's wrong.
Thanks again oh god s: