本文整理汇总了C++中Dot::setCamera方法的典型用法代码示例。如果您正苦于以下问题:C++ Dot::setCamera方法的具体用法?C++ Dot::setCamera怎么用?C++ Dot::setCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dot
的用法示例。
在下文中一共展示了Dot::setCamera方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
void loop () {
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
//Handle input for the dot
dot.handleEvent( e );
}
//Move the dot
dot.move( tileSet );
dot.setCamera( camera );
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render level
for( int i = 0; i < TOTAL_TILES; ++i )
{
tileSet[ i ]->render( camera );
}
//Render dot
dot.render( camera );
//Update screen
SDL_RenderPresent( gRenderer );
}
示例2: main
//.........这里部分代码省略.........
frames1.start();
// message processing loop
SDL_Event event;
while (SDL_PollEvent(&event))
{
//cout << &event << endl;
//SDL_Event *e = &event;
myDot.change_heading(event);
myDot.handle_input(event);
if(event.type == SDL_QUIT)
{
done = true;
}
// get keystates
//Uint8 *keystates = SDL_GetKeyState(NULL);
if(event.type == SDL_KEYDOWN)
{
if(event.key.keysym.sym == SDLK_p)
{
if(Mix_PlayingMusic() == 0)
{
sm1.playAll();
}
else
{
if(Mix_PausedMusic() == 1)
{
Mix_ResumeMusic();
}
else
{
Mix_PauseMusic();
}
}
}
if(event.key.keysym.sym == SDLK_ESCAPE)
{
done = true;
}
}
}
myDot.move(setup1, world1, delta.get_ticks());
myDot.shoot(setup1);
delta.start();
myDot.setCamera(setup1);
im1.drawAll(myDot, setup1, world1);
myDot.showParticleD(im1, setup1);
im1.drawPlayer(setup1, myDot);
myDot.showBulletD(im1, setup1);
/**
Uint8 *keystates = SDL_GetKeyState(NULL);
if(keystates[SDLK_p])
{
// key state template
}
**/
//SDL_Surface* test = TTF_RenderText_Solid(im1.getFont(), "test", im1.getColour());
//im1.applySurface(10, 10, test, newScreen);
if(SDL_Flip(setup1.getScreen()) == -1)
{
return 1;
}
//framecount++;
//cout << "frames" << SDL_GetTicks() << endl;
if(frames1.get_ticks() < 1000 / setup1.getFPS())
{
SDL_Delay((1000 / setup1.getFPS()) - frames1.get_ticks());
//cout << "delay" << 1000 / setup1.getFPS() - frames1.get_ticks();
}
}// end main loop
//Mix_FreeMusic(bgm);
setup1.freeScreen();
im1.clean();
sm1.cleanSound();
// all is well ;)
printf("Exited cleanly\n");
return 0;
}
示例3: main
int main( int argc, char* args[] )
{
//Start up SDL and create window
if( !init() )
{
printf( "Failed to initialize!\n" );
}
else
{
//The level tiles
Tile* tileSet[ TOTAL_TILES ];
//Load media
if( !loadMedia( tileSet ) )
{
printf( "Failed to load media!\n" );
}
else
{
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//The dot that will be moving around on the screen
Dot dot;
//Level camera
SDL_Rect camera = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT };
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
//Handle input for the dot
dot.handleEvent( e );
}
//Move the dot
dot.move( tileSet );
dot.setCamera( camera );
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render level
for( int i = 0; i < TOTAL_TILES; ++i )
{
tileSet[ i ]->render( camera );
}
//Render dot
dot.render( camera );
//Update screen
SDL_RenderPresent( gRenderer );
}
}
//Free resources and close SDL
close( tileSet );
}
return 0;
}