Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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*#M@$!!  !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#$$@@W@*?$$      /`",0,24*13,STextColor);
g_CWindow.draw_text("W$@@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(".~~   :X@!.-~   ?@WTWo(#*$$$W$TH$! `",0,24*17,STextColor);
g_CWindow.draw_text(".~!X$?!-~    : ?$$$B$Wu(#**$RM!",0,24*18,STextColor);
g_CWindow.draw_text("$R@i.~~ !     :   ~$$$$$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);
   }
}