This might belong in the Alternative Game Libraries, but my problems are too "beginner" for that place, hence I'll post in this forum.
Here's the link to the code I'm going to be talking about (it's big): http://rapidshare.com/files/87683590/p_sunrise_3.zip.html
It's a Visual C++ 2005 project. The SDL files needed are included in the project.
The First Problem:
I see many SDL programs use the printf() to output errors. Whenever I do that, the command prompt doesn't even appear when I compile my program. Am I missing something? I tried using <iostream> but that doesn't do anything.
The Second Problem:
I have a "interface" (called Locatable, though it should be called something else) that has a draw function. Classes that implement Locatable have a draw function fully implemented (except for Sprite which is abstract).
This draw function is called in the Environment class through a loop. Thing is, it doesn't draw a single thing. I do know why. This line of code...
SDL_FillRect( screen, NULL, 0 );
...blacks everything out. However, when I remove that line of code, it draws, but it leaves a trail behind like a game of Snake. That's not supposed to happen. I tried many things but all are to no avail and, quite frankly, I am tired of this problem.
Here's the segment that draws all the sprites and such.
// Renders the environment and shows it on the screen.
void Environment::show()
{
// Clears the screen first.
SDL_FillRect( screen, NULL, 0 );
// Shows the environment.
apply_surface( posX, posY, screen, shell->get_surface(), NULL );
// Shows each of the objects within the environment.
for ( unsigned int index = 0; index < objects.size(); index++ ) {
Locatable* loc = objects.at( index );
loc->draw();
}
// Updates the screen.
update();
}
Thanks.