Esempio n. 1
0
void render(){
        display.Clear();
        drawGhost();
        drawBlock(CODE);
        drawMap();
        drawBorders();
        drawNextBlock();
        sprintf(TEXT,"Score: %i",score);
        display.DrawString(TEXT,  ((WIDTH))*BLOCKPIXSIZE, (0)*BLOCKPIXSIZE,0,0x00FF00);
        sprintf(TEXT,"Highscore: %i",hscore);
        display.DrawString(TEXT,  ((WIDTH))*BLOCKPIXSIZE, (1)*BLOCKPIXSIZE,0,0x00FF00);
        sprintf(TEXT,"Next:");
        display.DrawString(TEXT,  ((WIDTH))*BLOCKPIXSIZE, (4)*BLOCKPIXSIZE,0,0x00FF00);
        display.Render();
}
Esempio n. 2
0
void lostGame(){
     display.Clear(); drawMap(); display.Render();
     //====================Highscore if(score < hscore)
     if(score < hscore){
             //sprintf (DEBUGMSG2, "You lose nub.\nScore: %i\nHighscore: %i",score,hscore);  
             //MessageBox (0, DEBUGMSG2, "You Lost!", MB_ICONINFORMATION);
     }
     else{
          hscore = score;
          saveHighscore(&score);
         // sprintf (DEBUGMSG2, "You just achieved a highscore\nHighscore: %i",hscore);
          //MessageBox (0, DEBUGMSG2, "Nice!!!", MB_ICONINFORMATION);
          
          
     }
     resetGame();
}
Esempio n. 3
0
int RunF54Test(const char * deviceFile, f54_report_types reportType, bool continuousMode, bool noReset)
{
	int rc;
	HIDDevice rmidevice;
	Display * display;

	if (continuousMode)
	{
		display = new AnsiConsole();
	}
	else
	{
		display = new Display();
	}

	display->Clear();

	rc = rmidevice.Open(deviceFile);
	if (rc)
		return rc;

	F54Test f54Test(rmidevice, *display);

	rc = f54Test.Prepare(reportType);
	if (rc)
		return rc;

	stopRequested = false;

	do {
		rc = f54Test.Run();
	}
	while (continuousMode && !stopRequested);

	if (!noReset)
		rmidevice.Reset();

	rmidevice.Close();

	delete display;

	return rc;
}
Esempio n. 4
0
void resetGame(){
     
     //==========================START MSG Prints Highscore
     while(!keyboard.s){
        display.Clear();
        drawMap();
        drawBorders();
        sprintf(TEXT,"Press 's' to start");
        display.DrawString(TEXT,  0, (HEIGHT/2)*BLOCKPIXSIZE,0,0x00FF00);
        display.Render();
        keyboard.Poll(); 
        SDL_Delay(50);
         }
     for(int i=0;i < WIDTH;i++){
         for(int ii=0;ii < HEIGHT;ii++){
                 map[i][ii] = 0;
         }
     }
    score = 0;
    newBlock();
}
Esempio n. 5
0
int main (int argc, char *argv[])
{    
    srand ( time(NULL) );
    
    sound.LoadSound("blockHit","hit.wav");
    sound.LoadSound("horizontal","horizon2.wav");
    sound.LoadSound("rotate","rotate.wav");
    
    loadHighscore(&hscore);
    
    resetGame();
    
    while (keyboard.Quit == false)
    {   
          if(keyboard.r){

                       keyboard.Clear();
                       resetGame();
        }
        
        if(keyboard.p){

                       SDL_Delay(100);
                       keyboard.Poll();
                       keyboard.Clear();
                       while(!keyboard.p){
                            keyboard.Poll(); 
                            display.Clear();
                            drawBorders();
                            sprintf(TEXT,"Game is paused.");
                            display.DrawString(TEXT,  0, (HEIGHT/2)*BLOCKPIXSIZE,0,0x00FF00);
                            display.Render();
                            SDL_Delay(50);
                       }
        }
        int speed = 0;
        speed = score/2400;
        if(speed > 40){speed = 40;}
        
        if(!(cycle% (60-speed)) || keyboard.Down){fallBlock(); HorizontalStrip(); if(keyboard.Down)keyboard.Clear(); }
        
        keyboard.Poll();
        if(keyboard.Left && InvasiveCheckPass(blockx-1,blocky,blockt,blockr)){ --blockx; keyboard.Clear();}
        if(keyboard.Right && InvasiveCheckPass(blockx+1,blocky,blockt,blockr)){++blockx; keyboard.Clear();}
        
        if(keyboard.Up && InvasiveCheckPass(blockx,blocky,blockt,blockr+1)){ 
             blockr = (++blockr > 3) ? 0 : blockr; updateBlockBoundaries();
             sound.PlaySound("rotate",80,0);
             keyboard.Clear();
             
        }
        
        if(keyboard.Space){
            while(InvasiveCheckPass(blockx,blocky+1,blockt,blockr)){fallBlock(); HorizontalStrip();}
            gridLockBlock();
            keyboard.Clear();
            SDL_Delay(80);
        }
    
        
        blockx = (blockx< -minxcord) ? -minxcord : ((blockx > (WIDTH-1)-maxxcord) ? (WIDTH-1)-maxxcord : blockx);
        
        
        render(); 
        
        char TXT[128];
        if(speed > 30){sprintf(TXT,"EXTREME PENTRIX: %i",hscore);}
        else{sprintf(TXT,"Pentrix Highscore: %i",hscore);}
        display.Caption(TXT);
        
        
        SDL_Delay (4); cycle = (++cycle > 239) ? 1 : cycle;
    }

    return 0;
}