/*************************************************************
 * Function: setup ()                                        *
 * Date Created: September 29, 2012                          *
 * Date Last Modified: September 30, 2012                    *
 * Description: This function initializes the srand () to be *
 *              to get random numbers to simulate values     *
 *              rolling a die. It also calls introScreen ()  *
 * Input parameters: void                                    *
 * Returns: void                                             *
 * Preconditions: time.h included for time ()                *
 * Postconditions: srand () initiated and title shown on     *
 *                 screen                                    *
 *************************************************************/
void setup (void)
{
	/* initiates srand () function necessary for rand () */
	srand ((unsigned int) time (NULL));

	/* Animated welcome screen is displayed on the screen  */
	introScreen ();
}
예제 #2
0
int main(void) {
	armcmx_init();
	printf("Hello!\n");
	
	//setup
  GLCD.Init();   // initialise the library, non inverted writes pixels onto a clear screen
  if(GLCD.Height >= 64)   
    icon = ArduinoIcon64x64;  // the 64 pixel high icon
  else
    icon = ArduinoIcon64x32;  // the 32 pixel high icon
  introScreen();
  GLCD.ClearScreen(); 

  GLCD.SelectFont(System5x7, BLACK); // font for the default text area
  GLCD.println("GLCD version ");
  GLCD.println(" armcmx ");
		
  GLCD.DrawRect(8,16,110,32);  // rounded rectangle around text area   

	/*
	srand(23);
	int x = 0, y = 0;
//	uint8 d;
//	uint16 color = 0xff;
	while (1) {
		x = rand() % 127;
		y = rand() % 63;
		delay_ms(20);
		GLCD.SetDot(x, y, 1);
//		x = ++x % 128;
//		if (x == 0) 
//			y = ++y % 64;
	}
	*/
	while (1) {
  iter = 0;
  startMillis = millis();
  while( millis() - startMillis < 1000){ // loop for one second
    GLCD.DrawRect(0, 0, 64, 61, BLACK); // rectangle in left side of screen
    GLCD.DrawRoundRect(68, 0, 58, 61, 5, BLACK);  // rounded rectangle around text area   
    for(int i=0; i < 62; i += 4)
      GLCD.DrawLine(1,1,63,i, BLACK);  // draw lines from upper left down right side of rectangle  
    GLCD.DrawCircle(32,31,30,BLACK);   // draw circle centered in the left side of screen  
    GLCD.FillRect(92,40,16,16, WHITE); // clear previous spinner position  
    drawSpinner(loops++,100,48);       // draw new spinner position
    //GLCD.FillRect(24,txtLINE3,14,14, WHITE);  // clear text area that will be drawn below 
    GLCD.CursorTo(5,5);               // locate curser for printing text
    GLCD.PrintNumber(++iter);         // print current iteration at the current cursor position 
  } 
  // display number of iterations in one second
  GLCD.ClearScreen();               // clear the screen  
  GLCD.CursorTo(14,2);              // positon cursor  
  GLCD.Puts("FPS= ");               // print a text string
  GLCD.PrintNumber(iter);           // print a number 
	}
}
예제 #3
0
/*! \brief Paints the necessary object on the screen.
 * Precondition: a QPaintEvent is called.
 * Postcondition: Necessary objects are painted on the screen.
 * \param *event QT event pointer*/
void Game::paintEvent(QPaintEvent *event)
{
  	QPainter painter(this);

 	//always paints iphone on screen
	painter.drawImage(iphone.getRect(), iphone.getImage());

	if (gameOver) // If gameOver is true
	{
		gameOverScreen(painter); //paint game over screen
  	}
	else if (gameWon) // If gameWon is true
	{
		victoryScreen(painter); //paint victory screen
  	}
  	else if(bSOD) // If bSOD is true, Paint Blue Screen of Death
	{
		//loads Blue Screen of Death image
  		blueScreenImage.load("blueScreenDeath.png"); 
  		blueScreenRect = blueScreenImage.rect();
		blueScreenRect.moveTo(28,150);
		
		//Paints Blue Screen of Death image
		painter.drawImage(blueScreenRect, blueScreenImage);

		//Paints Points on status bar of iphone
		getPoints(painter);

		//resets last direction to nothing
		lastDir = ' ';
		
  	}	
	else if(introPrompt1) // If introPrompt1 is true
	{
		introScreen(painter); //paint intro screen 1 screen
	}
	else if(introPrompt2) // If introPrompt2 is true
	{
		introScreen(painter); //paint intro screen 2 screen
	}
  	else // if has game Started
	{

    		snake->drawSnake(painter); // paint Snake on screen
    		painter.drawImage(food->getRect(), food->getImage()); // paint Food on screen

		if(winSpawn) // If winSpawn is true
		{
			painter.drawImage(foodWinner->getRect(), foodWinner->getImage()); // paint foodWinner on screen
			winCounter++; // increament winCounter

			if(winCounter%100==0) //if winCounter%100==0, then set up variables to stop painting foodWinner
			{
				deathSpawn = FALSE;
				winSpawn = FALSE;
				doOneTime = TRUE;
				spawnWinnerCount = 0;
			}
		}
		else if(deathSpawn) // If deathSpawn is true
		{
			painter.drawImage(specialFood->getRect(), specialFood->getImage()); // paint specialFood on screen
			deathCounter++; // increament deathCounter
			spawnWinnerCount++; // increament spawnWinnerCount

 			//if deathCounter%100==0, then set up variables to stop painting specialFood.
			//if spawnWinnerCount%1000==0, then set up variables to start painting foodWinner.
			if(deathCounter%100==0 || spawnWinnerCount%1000==0)
			{
				deathSpawn = FALSE;
				doOneTime = TRUE;
			}

		}

		//Paints Points on status bar of iphone
		getPoints(painter);
  	}
}