Black screen upon loading new map

Hey forum, I have a small problem with my map loading function.
The initial map loads perfectly fine, but when I load the second it shows a black screen where I can still see my hero (but no other tiles and he hasn't moved like he's supposed too) and crashes.
This is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
void newMapTile::onCollision(Game& game)
{
    game.map = new Map(game.t, fileName);
    int newX, newY;
    cout<<"calling";
    newX =  x*32 - game.player.pSprite.GetPosition().x; //calculating new position of player
    newY =  y*32 - game.player.pSprite.GetPosition().y; //x and y are class members.

    game.player.move(newX, Player::LEFT); //move the player in that direction
    game.moveWindow(Player::LEFT); //move view (camera)
    game.player.move(newY, Player::UP);
    game.moveWindow(Player::UP);
}


What could be going wrong?
some possibilities:

- is fileName still valid?
- can newX and newY be negative numbers (are negative numbers valid?)
- are x and y member variables? are they still valid?
All 3 are valid...
The weird thing is he doesn't even move AT ALL.
And everything turns black...
you need to set breakpoints in the program and/or dump the variables to cerr
if they all look good, do you need to do some kind of cls()?
I already debugged it all and it all seemed good :S

EDIT: found out I hadn't moved the View properly! All fixed now :D
Last edited on
Topic archived. No new replies allowed.