本文整理汇总了C++中CSurface::draw_text方法的典型用法代码示例。如果您正苦于以下问题:C++ CSurface::draw_text方法的具体用法?C++ CSurface::draw_text怎么用?C++ CSurface::draw_text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSurface
的用法示例。
在下文中一共展示了CSurface::draw_text方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
init(); //init SDL
g_CWindow.SSurface = SDL_SetVideoMode( WIDTH , HEIGHT , 32 , SDL_DOUBLEBUF|SDL_HWSURFACE|SDL_ANYFORMAT); //assign surface
g_pCMenu = MD2Model::load("menu.md2");
g_SPlayer.pCModel = MD2Model::load("player.md2");
g_SPlayer.pCLaser = MD2Model::load("laser.md2");
g_pCLoop = MD2Model::load("loop.md2");
Uint32 u32Start;
while (g_bRunning)
{
u32Start = SDL_GetTicks(); //Get the tick this cycle started on
if(g_dAngle>360)
g_dAngle = 0;
if(g_dAngle < 0 )
g_dAngle = 360;
control(); //get user input
if(!g_bStart)
draw_menu(); //Draw 'Seizure Ships!
else
if(!lost)
game(); //Update game status
else
lose();
if(!lost) {
if(g_bThreadVisualization) { //Shows triangles drawn by each thread
g_CWindow.draw_text("Work thread 1",0,24*2,RED);
g_CWindow.draw_text("Work thread 2",0,24*3,GREEN);
g_CWindow.draw_text("Work thread 3",0,24*4,BLUE);
g_CWindow.draw_text("Work thread 4",0,24*5,CYAN);
g_CWindow.draw_text("Work thread 5",0,24*6,PURPLE);
g_CWindow.draw_text("Work thread 6",0,24*7,YELLOW);
g_CWindow.draw_text("Press 'v' to disable Thread Visualization mode",0,24*19,WHITE);
}
else {
g_CWindow.draw_text("Press 'v' to enable Thread Visualization mode",0,24*19,WHITE);
}
g_CWindow.draw_text("Press 'p' to pause",0,24*17,WHITE);
g_CWindow.draw_text("Controls: ARROWS to move and ENTER to fire",0,24*18,WHITE);
backdrop(); //Draw our g_pCLoop backdrop
}
if((g_bRestart)&&(lost)) { //you suck at this game
thread a(system,"start.exe");
SDL_Delay(100); //Give system enough time to execute new instance
exit(0);
}
else
g_bRestart = false;
g_CWindow.draw(); //Update screen
if(1000/60>(SDL_GetTicks()-u32Start)) //Always keep constant framerate (60fps)
SDL_Delay(1000/60-(SDL_GetTicks()-u32Start));
}
return 0;
}
示例2: lose
void lose() {
SColor STextColor;
if(lose_duration % 2) //Flicker
STextColor = RED;
else
STextColor = BLACK;
g_CWindow.draw_text(" :::!~!!!!!:.",0,24,STextColor);
g_CWindow.draw_text(" .xUHWH!! !!?M88WHX:.",0,24*2,STextColor);
g_CWindow.draw_text(" .X*#[email protected]$!! !X!M$$$$$$WWx:.",0,24*3,STextColor);
g_CWindow.draw_text(" :!!!!!!?H! :!$!$$$$$$$$$$8X:",0,24*4,STextColor);
g_CWindow.draw_text(" !!~ ~:~!! :~!$!#$$$$$$$$$$8X:",0,24*5,STextColor);
g_CWindow.draw_text(" :!~::!H!< ~.U$X!?R$$$$$$$$MM!",0,24*6,STextColor);
g_CWindow.draw_text(" ~!~!!!!~~ .:XW$$$U!!?$$$$$$RMM!",0,24*7,STextColor);
g_CWindow.draw_text(" !:~~~ .:!M#T#$$$$WX??#MRRMMM!",0,24*8,STextColor);
g_CWindow.draw_text(" ~?WuxiW*` `##$$$$8!!!!??!!!",0,24*9,STextColor);
g_CWindow.draw_text(" :X- M$$$$ `#T#$T~!8$WUXU~",0,24*10,STextColor);
g_CWindow.draw_text(" :%` ~#$$$m: ~!~ ?$$$$$$",0,24*11,STextColor);
g_CWindow.draw_text(" :!`.- ~T$$$$8xx. .xWW- ~####*#",0,24*12,STextColor);
g_CWindow.draw_text("..... -~~:<` ! ~?T#[email protected]@[email protected]*?$$ /`",0,24*13,STextColor);
g_CWindow.draw_text("[email protected]@M!!! .!~~ !! .:XUW$W!~ `#~: :",0,24*14,STextColor);
g_CWindow.draw_text("##~~`.:x%`!! !H: !WM$$$$Ti.: .!WUn+!`",0,24*15,STextColor);
g_CWindow.draw_text(":::~:!!`:X~ .: ?H.!u #$$$B$$$!W:U!T$$M~",0,24*16,STextColor);
g_CWindow.draw_text(".~~ :[email protected]!.-~ [email protected](#*$$$W$TH$! `",0,24*17,STextColor);
g_CWindow.draw_text(".~!X$?!-~ : ?$$$B$Wu(#**$RM!",0,24*18,STextColor);
g_CWindow.draw_text("[email protected]~~ ! : ~$$$$$B$$en:`` YOU HAVE DIED",0,24*19,STextColor);
lose_duration--;
if(lose_duration < 0) {
g_CWindow.draw_text("Would you like to play again?",0,24*2,WHITE);
g_CWindow.draw_text(" Y/N?",0,24*3,WHITE);
}
}