本文整理汇总了C++中CGameManager::Refresh方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameManager::Refresh方法的具体用法?C++ CGameManager::Refresh怎么用?C++ CGameManager::Refresh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameManager
的用法示例。
在下文中一共展示了CGameManager::Refresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ( int argc, char** argv )
{
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf( "Unable to init SDL: %s\n", SDL_GetError() );
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode(SCREENW, SCREENH, 32,
SDL_HWSURFACE|SDL_DOUBLEBUF);
if ( !screen )
{
printf("Unable to set 800x600 video: %s\n", SDL_GetError());
return 1;
}
SDL_WM_SetCaption("Szit the Game", NULL);
if( TTF_Init() == -1 )
{
printf("Unable to initialize font");
return 1;
}
font=TTF_OpenFont("tahoma.ttf", 28);
if(font){printf("Success");}
// centre the bitmap on screen
CGameManager manager;
bool done = false;
CBlock blockT(0, -1, 0, 0, 0, 1, 0, 0, -1, 100, 100, 100); //t
blockT.TryTurn();
blockT.Turn();
blockT.TryTurn();
blockT.Turn();
CBlock blockZ(0, -1,-1,0,-1,0,0,1,0, 198,255,126); //z
CBlock blockS(0, -1,0,0,0,0,-1,1,-1, 126,196,255); //s
CBlock blockO(1, 0,0,1,0,0,1,1,1, 100, 100, 0); //o
CBlock blockI(0, 0,-1,0,0,0,1,0,2, 255,159,126); //i
CBlock blockJ(0, -1,1,0,1,0,0,0,-1, 139,77,156); //j
CBlock blockL(0, 0,-1,0,0,0,1,1,1, 255,229,126); //l
CBlock GameBlock(0, -1, 0, 0, 0, 1, 0, 0, -1, 179,206,221); //creating t
CBlock NextBlock(0, -1, 0, 0, 0, 1, 0, 0, -1, 179,206,221); //t
//CBlock GameBlock(0, -1,0,0,0,0,-1,1,-1); //s
//CBlock GameBlock(0, 0,-1,0,0,0,1,0,2); //i
CButton start(300, 350, 200, 50, 100, 100, 100, 150, 150, 150, 1, "Start");
CButton help(300, 425, 200, 50, 100, 100, 100, 150, 150, 150, 0, "Help");
CButton exit(300, 500, 200, 50, 100, 100, 100, 150, 150, 150, 0, "Exit");
CButton easy(100, 350, 200, 50, 200, 200, 200, 255, 255, 255, 0, "Easy");
CButton medium(300, 350, 200, 50, 200, 200, 200, 255, 255, 255, 1, "Medium");
CButton hard(500, 350, 200, 50, 200, 200, 200, 255, 255, 255, 0, "Hard");
manager.Refresh(&GameBlock, &NextBlock);
manager.Refresh(&GameBlock, &NextBlock);
srand(time(NULL));
switch(rand()%7){
case 0: GameBlock.Set(0, -1, 0, 0, 0, 1, 0, 0, -1,179,206,221);break; //t
case 1: GameBlock.Set(0, -1,-1,0,-1,0,0,1,0, 198,255,126);break; //z
case 2: GameBlock.Set(0, -1,0,0,0,0,-1,1,-1, 126,196,255);break; //s
case 3: GameBlock.Set(1, 0,0,1,0,0,1,1,1, 100, 100, 0);break; //o
case 4: GameBlock.Set(0, 0,-1,0,0,0,1,0,2, 255,159,126);break; //i
case 5: GameBlock.Set(0, -1,1,0,1,0,0,0,-1, 139,77,156);break; //j
case 6: GameBlock.Set(0, 0,-1,0,0,0,1,1,1, 255,229,126);break; //l
}
srand(time(NULL)+SDL_GetTicks());
switch(rand()%7){
case 0: NextBlock.Set(0, -1, 0, 0, 0, 1, 0, 0, -1,179,206,221);break; //t
case 1: NextBlock.Set(0, -1,-1,0,-1,0,0,1,0, 198,255,126);break; //z
case 2: NextBlock.Set(0, -1,0,0,0,0,-1,1,-1, 126,196,255);break; //s
case 3: NextBlock.Set(1, 0,0,1,0,0,1,1,1, 100, 100, 0);break; //o
case 4: NextBlock.Set(0, 0,-1,0,0,0,1,0,2, 255,159,126);break; //i
case 5: NextBlock.Set(0, -1,1,0,1,0,0,0,-1, 139,77,156);break; //j
case 6: NextBlock.Set(0, 0,-1,0,0,0,1,1,1, 255,229,126);break; //l
}
// program main loop
while (!done)
{
// message processing loop
SDL_Event event;
++frame;
SetFPS();
LastFrame=SDL_GetTicks();
if(gamestatus==1){manager.Refresh(&GameBlock, &NextBlock);
}
while (SDL_PollEvent(&event))
{
// check for messages
switch (event.type)
//.........这里部分代码省略.........