本文整理汇总了C++中Foo::move方法的典型用法代码示例。如果您正苦于以下问题:C++ Foo::move方法的具体用法?C++ Foo::move怎么用?C++ Foo::move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foo
的用法示例。
在下文中一共展示了Foo::move方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//Functions
int main(int argc, char* args[])
{
bool quit = false;
if(init() == false)
{
return 1;
}
//Load the files
if(load_files() == false)
{
return 1;
}
set_clips();
Timer fps;
Foo walk;
//While user hasn't quit
while(quit == false)
{
fps.start();
while(SDL_PollEvent(&event))
{
walk.handle_events();
if(event.type == SDL_QUIT)
{
quit = true;
}
}
walk.move();
SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
walk.show();
if(SDL_Flip(screen) == -1)
{
return 1;
}
if(fps.get_ticks() < 1000 / FRAMES_PER_SECOND)
{
SDL_Delay((1000 / FRAMES_PER_SECOND) - fps.get_ticks());
}
}
clean_up();
return 0;
}
示例2: main
int main( int argc, char* args[] )
{
//Quit flag
bool quit = false;
//Initialize
if( init() == false )
{
return 1;
}
//Load the files
if( load_files() == false )
{
return 1;
}
//Clip the sprite sheet
set_clips();
//The frame rate regulator
Timer fps;
//The stick figure
Foo walk;
//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 stick figure
walk.handle_events();
//If the user has Xed out the window
if( event.type == SDL_QUIT )
{
//Quit the program
quit = true;
}
}
//Move the stick figure
walk.move();
//Fill the screen white
SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );
//Show the stick figure on the screen
walk.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();
return 0;
}
示例3: dino_main
void dino_main()
{
start= SDL_GetTicks();
for(int i=0; i<600; i++)
{
randx[i]= rand()%600 + 1;
randy[i]= rand()%420 + 1;
if (randy[i]>220 && randy[i]<270)
{
randx[i]=randx[i-1];
randy[i]=randx[i-1];
}
}
bool quit = false;
set_clips();
//The frame rate regulator
Timer fps;
//The stick figure
Foo walk;
//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 stick figure
walk.handle_events();
//If the user has Xed out the window
if( event.type == SDL_QUIT )
{
//Quit the program
quit = true;
}
}
//Move the stick figure
walk.move(randx,randy);
//Fill the screen white
//SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0, 0xFF, 0xFF ) );
apply_surface(0,0,back_grass,screen);
score_dis = TTF_RenderText_Solid( font, "Score", textColor );
apply_surface( 460, 450, score_dis, screen );
SDL_FillRect( screen, &wall, SDL_MapRGB( screen->format, 0, 0xFF, 0xFF ) );
SDL_FillRect( screen, &wall2, SDL_MapRGB( screen->format, 0, 0xFF, 0xFF ));
walk.show();
//Update the screen
if( SDL_Flip( screen ) == -1 )
{
}
//Cap the frame rate
if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
{
SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
}
}
}