在我的 int main() 代码段中,我声明了一个标识符(平铺)。在某些行上,标识符认为它是未声明的,而在其他行上,它识别出它是声明。初始声明在所有括号之外(除了主要的)。为什么会出现这种情况?
int main( int argc, char* args[] )
{
//Quit flag
bool quit = false;
//The dot
Dot myDot;
//The tiles that will be used
Tile *tiles[ TOTAL_TILES ];
//The frame rate regulator
Timer fps;
//Initialize
if( init() == false )
{
return 1;
}
//Load the files
if( load_files() == false )
{
return 1;
}
//Clip the tile sheet
clip_tiles();
//Set the tiles
if( set_tiles( tile ) == false )
{
return 1;
}
//While the user hasn't quit
while( quit == false )
{
//Start the frame timer
fps.start();
//While there's events to handle
while( SDL_PollEvent( &event ) )
{
//Handle events for the dot
myDot.handle_input();
//If the user has Xed out the window
if( event.type == SDL_QUIT )
{
//Quit the program
quit = true;
}
}
//Move the dot
myDot.move( tiles );
//Set the camera
myDot.set_camera();
//Show the tiles
for( int t = 0; t < TOTAL_TILES; t++ )
{
tiles[ t ]->show();
}
//Show the dot on the screen
myDot.show();
//Update the screen
if( SDL_Flip( screen ) == -1 )
{
return 1;
}
//Cap the frame rate
if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
{
SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
}
}
//Clean up
clean_up( tile );
return 0;
}
我的问题是clean_up ( tile);
和set_up ( tile );
- 或者至少那是我的错误代码排列的地方。