Пример #1
0
void ShowPlayerSettings(MI0283QT9 lcd, MENUOBJECTS obj, MY_USART serial){
	while(1){
		lcd.drawText(0, 15, "Player", OBJECTCOLOR, BACKGROUND, 3);
		
		if(obj.drawButton(lcd, "Difficulty", 20, 75, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showDifficulty(lcd, obj, serial);
		}
		
		if(obj.drawButton(lcd, "Color", 20, 135, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showPlayerColor(lcd, obj, serial);
		}
		
		if(obj.drawButton(lcd, "Sensitivity", 20, 195, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showSensitivity(lcd, obj, serial);
		}
		if(obj.drawButton(lcd, "Back", 20, 270, 200, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
		
	}
}
Пример #2
0
extern void showHighscoreMenu(MI0283QT9 lcd, MENUOBJECTS obj, MY_USART serial){
	
	lcd.fillScreen(BACKGROUND);
	while(1){
		
		char title[] = "Highscore";
		uint8_t lengthOfString = (strlen(title) * 26); 
		uint8_t x = (240 - lengthOfString);
		
		lcd.drawText(x, 15, title, OBJECTCOLOR, BACKGROUND, 3);
		lcd.drawText(20, 75, "1", OBJECTCOLOR, BACKGROUND, 2);
		lcd.drawText(70, 75, "Eld", OBJECTCOLOR, BACKGROUND, 2);
		lcd.drawText(20, 135, "2", OBJECTCOLOR, BACKGROUND, 2);
		lcd.drawText(70, 135, "Wil", OBJECTCOLOR, BACKGROUND, 2);
		lcd.drawText(20, 195, "3", OBJECTCOLOR, BACKGROUND, 2);
		lcd.drawText(70, 195, "Mic", OBJECTCOLOR, BACKGROUND, 2);
		
		
		if(obj.drawButton(lcd, "Back", 20, 255, 200, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
		
	}
}
Пример #3
0
//main menu with buttons for accesing sub menus 
extern void showSettingMenu(MI0283QT9 lcd){
	
	lcd.fillScreen(BACKGROUND);
	
	while(1){
		if(returnToMain){
			returnToMain=0;
			lcd.fillScreen(BACKGROUND);
			break;
		}
		
		char title[] = "Settings";
		uint8_t lengthOfString = (strlen(title) * 26); 
		uint8_t x = (240 - lengthOfString);
		
		lcd.drawText(x, 15, title, OBJECTCOLOR, BACKGROUND, 3);
		
		//button for opening sub menu difficulty
		if(drawButton(lcd, "Player", 20, 75, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			ShowPlayerSettings(lcd);
		}
		
		//button for opening sub menu generator
		if(drawButton(lcd, "Generator", 20, 135, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showGenerator(lcd);
		}
		
		//button for resetting score
		if(drawButton(lcd, "Reset Score", 20, 195, 200, 40)){
			EEPROM.write(171, 0);
			EEPROM.write(174, 'A');
			EEPROM.write(175, 'A');
			EEPROM.write(176, 'A');
			
			EEPROM.write(172, 0);
			EEPROM.write(177, 'A');
			EEPROM.write(178, 'A');
			EEPROM.write(179, 'A');
			
			EEPROM.write(173, 0);
			EEPROM.write(180, 'A');
			EEPROM.write(181, 'A');
			EEPROM.write(182, 'A');
		}
		
		//button to return to main menu
		if(drawButton(lcd, "Back", 20, 270, 200, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
	}
}
Пример #4
0
void showGameOverMenuMP(MI0283QT9 lcd, uint16_t score, uint8_t won){
	lcd.fillScreen(BACKGROUND);
	exitMultiplayer();
	while(1){
		if(won){
			char title[] = "You Won!";
			
			lcd.drawText(centerText(title,3), 15, title, OBJECTCOLOR, BACKGROUND, 3);
			
			
			lcd.drawText(centerText("Your Score:", 2), 60, "Your Score:", OBJECTCOLOR, BACKGROUND, 2);
			
			lcd.drawInteger(70, 100, score, DEC, OBJECTCOLOR, BACKGROUND, 3);
			
			
			if(drawButton(lcd, "Restart", 20, 220, 200, 40))
			{
				showMpMenu(lcd);
			}
			
			//return to main menu. You will first break to the game loop. In the game loop is an if statement. If return to main = 1 then you will break to the main menu.
			if(drawButton(lcd, "Main Menu", 20, 270, 200, 40))
			{
				lcd.fillScreen(BACKGROUND);
				returnToMain = 1;
				break;
			}
			
		}else if(!won){
			char title[] = "You Lost!";
			
			lcd.drawText(centerText(title,3), 15, title, OBJECTCOLOR, BACKGROUND, 3);
			
			
			lcd.drawText(centerText("Your Score:", 2), 60, "Your Score:", OBJECTCOLOR, BACKGROUND, 2);
			
			lcd.drawInteger(70, 100, score, DEC, OBJECTCOLOR, BACKGROUND, 3);
			
			
			if(drawButton(lcd, "Restart", 20, 220, 200, 40))
			{
				showMpMenu(lcd);
			}
			
			//return to main menu. You will first break to the game loop. In the game loop is an if statement. If return to main = 1 then you will break to the main menu.
			if(drawButton(lcd, "Main Menu", 20, 270, 200, 40))
			{
				lcd.fillScreen(BACKGROUND);
				returnToMain = 1;
				break;
			}
		}
	}
}
Пример #5
0
void showGameOverMenuMP(MI0283QT9 lcd, uint16_t score){
	while(1){
		if(true /*you won */){
			char title[] = "You Won!";
			
			lcd.drawText(centerText(title,3), 15, title, OBJECTCOLOR, BACKGROUND, 3);
			
			
			lcd.drawText(centerText("Your Score:", 2), 60, "Your Score:", OBJECTCOLOR, BACKGROUND, 2);
			
			lcd.drawInteger(70, 100, score, DEC, OBJECTCOLOR, BACKGROUND, 3);
			
			
			if(drawButton(lcd, "Restart", 20, 220, 200, 40))
			{
				showMpMenu(lcd);
			}
			
			//button for opening sub menu generator
			if(drawButton(lcd, "Main Menu", 20, 270, 200, 40))
			{
				lcd.fillScreen(BACKGROUND);
				returnToMain = 1;
				break;
			}
			
		}else{
			char title[] = "You Lost!";
			
			lcd.drawText(centerText(title,3), 15, title, OBJECTCOLOR, BACKGROUND, 3);
			
			
			lcd.drawText(centerText("Your Score:", 2), 60, "Your Score:", OBJECTCOLOR, BACKGROUND, 2);
			
			lcd.drawInteger(70, 100, score, DEC, OBJECTCOLOR, BACKGROUND, 3);
			
			
			if(drawButton(lcd, "Restart", 20, 220, 200, 40))
			{
				showMpMenu(lcd);
			}
			
			//button for opening sub menu generator
			if(drawButton(lcd, "Main Menu", 20, 270, 200, 40))
			{
				lcd.fillScreen(BACKGROUND);
				returnToMain = 1;
				break;
			}
		}
	}
}
Пример #6
0
extern void showPauseMenu(MI0283QT9 lcd){
	lcd.fillScreen(BACKGROUND);
	
	while(1){
		
		
		lcd.drawText(centerText("Pause", 3), 15, "Pause", OBJECTCOLOR, BACKGROUND, 3);
		if(drawButton(lcd, "Resume Game", 20, 75, 200, 40)){	
			showDefaultLayout(lcd);
			break;
		}
		if(drawButton(lcd, "Restart Game", 20, 135, 200, 40)){
			restartGame = 1;
			break;
		}	
		if(drawButton(lcd, "Settings", 20, 195, 200, 40)){
			showSettingMenu(lcd);
		}
		if(drawButton(lcd, "Main Menu", 20, 255, 200, 40)){
			returnToMain = 1;
			break;
		}
		
	}
}
Пример #7
0
extern void showDefaultLayout(MI0283QT9 lcd){
	
	lcd.fillScreen(ROADCOLOR);
	lcd.drawRect(0, 0, 20, 320, GRASSCOLOR);
	lcd.drawRect(220, 0, 20, 320, GRASSCOLOR);
		
}
Пример #8
0
void showPlayerColor(MI0283QT9 lcd){
	
	while(1){
	
		lcd.drawText(0, 15, "Color", OBJECTCOLOR, BACKGROUND, 3);

		red = drawSlider(lcd, 60, red, red, 0,0);

		green = drawSlider(lcd, 100, green , 0 , green, 0);
		
		blue = drawSlider(lcd, 140, blue, 0, 0 , blue);
		
		//draw a car
		lcd.drawRect(100, 180, 40, 64, RGB(red,green,blue));
		lcd.drawLine(100+1,180+16,100+10, 180+26, RGB(red,green,blue));
		lcd.drawLine(100+39,180+16,100+30, 180+26, RGB(red,green,blue));
		lcd.drawLine(100+10,180+26,100+30, 180+26, RGB(red,green,blue));
		lcd.drawLine(100+10,180+38,100+30, 180+38, RGB(red,green,blue));
		lcd.drawLine(100+1,180+48,100+10, 180+38, RGB(red,green,blue));
		lcd.drawLine(100+39,180+48,100+30, 180+38, RGB(red,green,blue));
		lcd.drawLine(100+10,180+26,100+10, 180+38, RGB(red,green,blue));
		lcd.drawLine(100+30,180+26,100+30, 180+38, RGB(red,green,blue));
		lcd.drawLine(100,180+16,100+38, 180+16, RGB(red,green,blue));
		lcd.drawLine(100,180+48,100+38, 180+48, RGB(red,green,blue));
	
		if(drawButton(lcd, "Accept", 20, 270, 200, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
	}
}
Пример #9
0
//sub menu which contains checkboxes for setting generator options (realtime, pretime) including logics to allow only one button to be set
void showGenerator(MI0283QT9 lcd, MENUOBJECTS obj, MY_USART serial){
	
	uint8_t up = 0;
	uint8_t down = 0;
	uint8_t start = 0;
	while(1){
		
		char title[] = "Generator";
		uint8_t lengthOfString = (strlen(title) * 26);
		uint8_t x = (240 - lengthOfString);
		
		lcd.drawText(x, 15, title, OBJECTCOLOR, BACKGROUND, 3);
		
		lcd.drawText(15, 90 , "Real-Time:", OBJECTCOLOR, BACKGROUND, 2);
		obj.drawCheckbox(lcd, 177, (97 - 24), 48, &realTime);
		
		lcd.drawText(15, 180, "Pre-Time :", OBJECTCOLOR, BACKGROUND, 2);
		obj.drawCheckbox(lcd, 177, (187 - 24), 48, &preTime);
		
		
		if(preTime && !start){
			up = 1;
			down = 0;
			start = 1;
		} else if(realTime && !start){
			up = 0;
			down = 1;
			start = 1;
		}
		
		if(preTime && up){
			//serial.sendString("preTime selected \n");
			
			if(realTime){
				preTime = 0;
				up = 0;
				down = 1;
			}
			
		} 
		
		if(realTime && down){
			//serial.sendString("realTime selected\n");
			if(preTime){
				realTime = 0;
				up = 1;
				down = 0;
			}
		} 
		
		
		
		if(obj.drawButton(lcd, "Back", 20, 270, 200, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
	}
}
Пример #10
0
void showNoHighScore(MI0283QT9 lcd, uint16_t score,  uint8_t isHighscore){
	while(1){
		
		char title[] = "You DIED!";
		
		lcd.drawText(centerText(title, 3), 15, title, OBJECTCOLOR, BACKGROUND, 3);
		if(!isHighscore){
			
			
			
			lcd.drawText(centerText("Your Score:", 2), 50, "Your Score:", OBJECTCOLOR, BACKGROUND, 2);
			if(hard){
				lcd.drawText(centerText("Hard Bonus Score ( x 2)!", 1), 75, "Hard Bonus Score ( x 2)!", OBJECTCOLOR, BACKGROUND, 1);
			}
			
			lcd.drawInteger(70, 100, score, DEC, OBJECTCOLOR, BACKGROUND, 3);
			
			
			lcd.drawText(centerText("Your Need:", 2), 140, "You Need:", OBJECTCOLOR, BACKGROUND, 2);
			//read in the eeprom the score of the 3rd best score and draw it on the screen.
			lcd.drawInteger(70, 170, EEPROM.read(173), DEC, OBJECTCOLOR, BACKGROUND, 3);
		} 
		
		
		
		//restart game. You will first break to the game loop. In the game loop is an if statement. If restart game = 1 then all values of variables will be set to 0. 
		if(drawButton(lcd, "Restart", 20, 220, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			restartGame = 1;
			break;
		}
		
		//return to main menu. You will first break to the game loop. In the game loop is an if statement. If return to main = 1 then you will break to the main menu.
		if(drawButton(lcd, "Main Menu", 20, 270, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			returnToMain = 1;
			break;
		}
	}
	
}
Пример #11
0
void ShowPlayerSettings(MI0283QT9 lcd){
	while(1){
		if(returnToMain){
			break;
		}
		
		lcd.drawText(0, 15, "Player", OBJECTCOLOR, BACKGROUND, 3);
		
		if(drawButton(lcd, "Difficulty", 20, 75, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showDifficulty(lcd);
		}
		
		if(drawButton(lcd, "Color", 20, 135, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showPlayerColor(lcd);
		}
		
		if(drawButton(lcd, "NunChuck", 20, 195, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showController(lcd);
		}
		if(drawButton(lcd,"H", 20,270, 95, 40)){
			returnToMain = 1;
		}
		
		if(drawButton(lcd, "B", 125, 270, 95, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
		
	}
}
Пример #12
0
extern void showMainMenu(MI0283QT9 lcd, MENUOBJECTS obj, MY_USART serial){
	
	lcd.fillScreen(BACKGROUND);
	while(1){
		
		char title[] = "RaceGame";
		uint8_t lengthOfString = (strlen(title) * 26); 
		uint8_t x = (240 - lengthOfString);
		
		lcd.drawText(x, 15, title, OBJECTCOLOR, BACKGROUND, 3);
		if(obj.drawButton(lcd, "Singleplayer", 20, 75, 200, 40)){
			showGame(lcd, obj, serial);
		}
		if(obj.drawButton(lcd, "Settings", 20, 135, 200, 40)){
			showSettingMenu(lcd,obj,serial);
		}
		if(obj.drawButton(lcd, "Highscore", 20, 195, 200, 40)){
			showHighscoreMenu(lcd, obj, serial);
		}
		
	}
}
Пример #13
0
//main game loop 
extern void showGame(MI0283QT9 lcd){
	//setup seed
	
	uint16_t seed = (rand() % 65534) + 1;
	srand(seed);
	
	//setup car
	uint8_t x = 2;
	uint8_t movCounter = 0;
	uint8_t colored[] = {red,green,blue};
	uint16_t score = 0;
	uint8_t pSensitivity = 0;
	
	  initGenObjects();
	//objects preGenObjects[128];

	
	if (sLow == 1)
	{
		pSensitivity = 5;
	} else if (sMedium == 1)
	{
		pSensitivity = 4;
	} else if (sHigh == 1){
		pSensitivity = 3;
	}
	
	//Draw game road
	showDefaultLayout(lcd);
	
	nun.nunchuck_init();

	posYobj1 = 0;
	posYobj2 = 0;
	posYobj3 = 0;

	prevposXobj1 = 0;
	prevposXobj2 = 0;
	prevposXobj3 = 0;

	keepObj2Alive = 0;
	keepObj3Alive = 0;
	
	uint8_t carHitMax = 15;
	uint8_t truckHitmax = 18;
	
	
	uint8_t countDown = 3;
	
	//start game loop
	while(1){
		
		
		
		if(returnToMain){
			returnToMain = 0;
			lcd.fillScreen(BACKGROUND);
			break;
		}
		
		if(restartGame){
			
			
			posYobj1 = 0;
			posYobj2 = 0;
			posYobj3 = 0;

			prevposXobj1 = 0;
			prevposXobj2 = 0;
			prevposXobj3 = 0;

			keepObj2Alive = 0;
			keepObj3Alive = 0;
			
			
			//Draw game road
			 initGenObjects();
			
			
			x = 2;
			
			movCounter = 0;
			colored[0] = red;
			colored[1] = green;
			colored[2] = blue;
			score = 0;
			
			pSensitivity = 0;
			
			if (sLow == 1)
			{
				pSensitivity = 5;
			} 
			else if (sMedium == 1)
			{
				pSensitivity = 4;
			}
			else if (sHigh == 1)
			{
				pSensitivity = 3;
			}
			
			showDefaultLayout(lcd);
			
			onBeginB = 0;
			restartGame = 0;
			countDown = 3;
		}
		
		//countdown before game start
		while(countDown != 0){
			lcd.drawInteger(centerText(" ", 3), 150, countDown, DEC, OBJECTCOLOR, BACKGROUND, 3);
			_delay_ms(1000);
			lcd.drawInteger(centerText(" ", 3), 150, countDown, DEC, BACKGROUND, BACKGROUND, 3);
			if(countDown == 1){
				lcd.drawText(centerText("START" , 3), 150, "START", OBJECTCOLOR, BACKGROUND, 3);
				_delay_ms(1000);
				lcd.drawText(centerText("START" , 3), 150, "START", BACKGROUND, BACKGROUND, 3);
			}
			countDown--;
		}
		//shows the enemy cars
		showGenObjects(lcd);
		
		//Draw player car at start location
		drawCar(lcd, x, 12,colored);
		
		
		
		
		//If obj1 is at you y location, check if objectx = playerx
		if((object[0].type == 1 && object[0].posY >= 12  && object[0].posY <= carHitMax ) || (object[0].type == 2 && object[0].posY >= 12 && object[0].posY <= truckHitmax)){
			if (object[0].posX == x ) {
				showGameOverMenu(lcd, score);
			}else{
				
				if(object[0].posY == carHitMax  || object[0].posY == truckHitmax){
					score = object[0].type + score;
				}
				
				
			}
		}else if((object[1].type == 1 && object[1].posY >= 12 && object[1].posY <= carHitMax ) || (object[1].type == 2 && object[1].posY >= 12 && object[1].posY <= truckHitmax)){
			//If obj2 is at player y location, check if objectx = playerx
			if (object[1].posX == x) {				
				showGameOverMenu(lcd,score);
			}else{
				
				if(object[1].posY == carHitMax  || object[1].posY == truckHitmax){
					score = object[1].type + score;
				}
			}
		} else if((object[2].type == 1 && object[2].posY >= 12 && object[2].posY <= carHitMax ) || (object[2].type == 2 && object[2].posY >= 12 && object[2].posY <= truckHitmax)){
			
			//If obj3 is at player y location, check if objectx = playerx
			if (object[2].posX == x) {
				showGameOverMenu(lcd,score);
			}else{
				
				if(object[2].posY == carHitMax || object[2].posY == truckHitmax){
					score = object[2].type + score;
				}
			}
		}
		
		
		
		//draws car at x depending on tilt, and y = 12 (front of car), y = 15 end of car
		if(nun.retreive_data()){
			
			
			if (nun.getC() ==1) {
				showPauseMenu(lcd);
			}
			
			
			//if nunchuck is tilted right, increment x
			if(nun.getAccX() > 148 || nun.getJoyX() > 150){
				if(movCounter == 0){
					removeCar(lcd, x, 12);
					if(x<4){
						x++;
					}
					movCounter++;
					}else{
					movCounter++;
					if(movCounter>=pSensitivity){
						movCounter = 0;
					}
				}
				drawCar(lcd, x, 12, colored);
			}
			//draw car at x location
			//if nunchuck is tilted left, substract 1 from x
			else if((nun.getAccX() > 70 && nun.getAccX() < 108) || nun.getJoyX() < 90){
				if(movCounter==0){
					removeCar(lcd, x, 12);
					if(x>0){
						x--;
					}
					movCounter++;
					}else{
					movCounter++;
					if(movCounter>=pSensitivity){
						movCounter = 0;
					}
				}
				//draw car at x location
				drawCar(lcd, x, 12, colored);
				//if nunchuck is in middle, movCounter = 0
			}else if(nun.getAccX() > 120 && nun.getAccX() < 136){
				movCounter = 0;
			}
			
			lcd.drawInteger(22, 2, score, DEC, GRASSCOLOR, BACKGROUND, 1);
			
		}
	}
}
Пример #14
0
//sub menu which contains checkboxes for setting generator options (realtime, pretime) including logics to allow only one button to be set
void showGenerator(MI0283QT9 lcd){
	
	uint8_t up = 0;
	uint8_t down = 0;
	uint8_t start = 0;
	while(1){
		if(returnToMain){
			break;
		}
		
		char title[] = "Generator";
		uint8_t lengthOfString = (strlen(title) * 26);
		uint8_t x = (240 - lengthOfString);
		
		lcd.drawText(x, 15, title, OBJECTCOLOR, BACKGROUND, 3);
		
		lcd.drawText(15, 90 , "Real-Time:", OBJECTCOLOR, BACKGROUND, 2);
		drawCheckbox(lcd, 177, (97 - 24), 48, &realTime);
		
		lcd.drawText(15, 180, "Pre-Time :", OBJECTCOLOR, BACKGROUND, 2);
		drawCheckbox(lcd, 177, (187 - 24), 48, &preTime);
		
		
		if(preTime && !start){
			up = 1;
			down = 0;
			start = 1;
		} else if(realTime && !start){
			up = 0;
			down = 1;
			start = 1;
		}
		
		if(preTime && up){
			
			if(realTime){
				preTime = 0;
				up = 0;
				down = 1;
			}
			
		} 
		
		if(realTime && down){
			if(preTime){
				realTime = 0;
				up = 1;
				down = 0;
			}
		} 
		
		
		
		if(drawButton(lcd,"H", 20,270, 95, 40)){
			returnToMain = 1;
		}
		
		if(drawButton(lcd, "B", 125, 270, 95, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
	}
}
Пример #15
0
void showSensitivity(MI0283QT9 lcd){
	
	uint8_t sUp = 0;
	uint8_t sDown = 0;
	uint8_t sStart = 0;
	
	while(1){
		if(returnToMain){
			break;
		}
		
		lcd.drawText(0, 15, "TiltSens", OBJECTCOLOR, BACKGROUND, 3);
	
		//drawing checkboxes and text on screen
		
		lcd.drawText(15, 80 , "LOW  :", OBJECTCOLOR, BACKGROUND, 2);
		drawCheckbox(lcd, 177, (87 - 24), 48, &sLow);
		
		lcd.drawText(15, 150, "MEDIUM:", OBJECTCOLOR, BACKGROUND, 2);
		drawCheckbox(lcd, 177, (157 - 24), 48, &sMedium);
		
		lcd.drawText(15, 220, "HIGH  :", OBJECTCOLOR, BACKGROUND, 2);
		drawCheckbox(lcd, 177, (227 - 24), 48, &sHigh);
		
		//logics for only 1 checked per click
		if(sLow && !sStart)
		{
			sStart = 1;
			sUp = 1;
		}
		else if(sMedium && !sStart)
		{
			sStart = 1;
			sUp = 0;
			sDown = 0;
		}
		else if(sHigh && !sStart)
		{
			sStart = 1;
			sDown = 1;
		}
		
		
		if(sLow && sUp){
			if(sMedium){
				sLow = 0;
				sUp = 0;
				sDown = 0;
			}
			
			if(sHigh){
				sLow = 0;
				sUp = 0;
				sDown = 1;
			}
		}
		
		if(sMedium && !sUp && !sDown){
			if(sLow){
				sMedium = 0;
				sUp = 1;
				sDown = 0;
			}
			
			if(sHigh){
				sMedium = 0;
				sUp = 0;
				sDown = 1;
			}
		}
		
		if(sHigh && sDown){
			if(sMedium){
				sHigh = 0;
				sUp = 0;
				sDown = 0;
			}
			
			if(sLow){
				sHigh = 0;
				sUp = 1;
				sDown = 0;
			}
		}
		if(drawButton(lcd,"H", 20,270, 95, 40)){
			returnToMain = 1;
		}
	
		if(drawButton(lcd, "B", 125, 270, 95, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
	}
}
Пример #16
0
//sub menu which contains checkboxes for setting difficulty (easy, medium, hard) including logics to allow only one button to be set
void showDifficulty(MI0283QT9 lcd){
	
	//used to manage one check per set
	uint8_t up = 0;
	uint8_t down = 0;
	uint8_t start = 0;
	
	while(1){
		if(returnToMain){
			break;
		}
		
		//drawing checkboxes and text on screen
		lcd.drawText(0, 15, "Difficulty", OBJECTCOLOR, BACKGROUND, 3);
		
		lcd.drawText(15, 80 , "EASY  :", OBJECTCOLOR, BACKGROUND, 2);
		drawCheckbox(lcd, 177, (87 - 24), 48, &easy);
		
		lcd.drawText(15, 150, "MEDIUM:", OBJECTCOLOR, BACKGROUND, 2);
		drawCheckbox(lcd, 177, (157 - 24), 48, &medium);
		
		lcd.drawText(15, 220, "HARD  :", OBJECTCOLOR, BACKGROUND, 2);
		drawCheckbox(lcd, 177, (227 - 24), 48, &hard);
		
		//logics for only 1 checked per click
		if(easy && !start)
		{
			start = 1;
			up = 1;
		}
		else if(medium && !start)
		{
			start = 1;
			up = 0;
			down = 0;
		}
		else if(hard && !start)
		{
			start = 1;
			down = 1;
		}
		
		
		if(easy && up){
			if(medium){
				easy = 0;
				up = 0;
				down = 0;
			}
			
			if(hard){
				easy = 0;
				up = 0;
				down = 1;
			}
		}
		
		if(medium && !up && !down){
			if(easy){
				medium = 0;
				up = 1;
				down = 0;
			}
			
			if(hard){
				medium = 0;
				up = 0;
				down = 1;
			}
		}
		
		if(hard && down){
			if(medium){
				hard = 0;
				up = 0;
				down = 0;
			}
			
			if(easy){
				hard = 0;
				up = 1;
				down = 0;
			}
		}
		
		
		if(drawButton(lcd,"H", 20,270, 95, 40)){
			returnToMain = 1;
		}
		
		if(drawButton(lcd, "B", 125, 270, 95, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
	}
}
Пример #17
0
void showController(MI0283QT9 lcd){
		uint8_t up = 0;
		uint8_t down = 0;
		uint8_t start = 0;
		
		
		while(1){
			if(returnToMain){
				break;
			}
			char title[] = "NunChuck";
			uint8_t lengthOfString = (strlen(title) * 26);
			uint8_t x = (240 - lengthOfString);
			
			lcd.drawText(x, 15, title, OBJECTCOLOR, BACKGROUND, 3);
			
			lcd.drawText(15, 80 , "Joystick:", OBJECTCOLOR, BACKGROUND, 2);
			drawCheckbox(lcd, 177, (87 - 24), 48, &setY);
			
			lcd.drawText(15, 150, "Tilt    :", OBJECTCOLOR, BACKGROUND, 2);
			drawCheckbox(lcd, 177, (157 - 24), 48, &setT);
			
			
			
			if(setY && !start){
				up = 1;
				down = 0;
				start = 1;
			} else if(setT && !start){
				up = 0;
				down = 1;
				start = 1;
			}
			
			if(setY && up){
				
				if(setT){
					setY = 0;
					up = 0;
					down = 1;
				}
				
			}
			
			if(setT && down){
				if(setY){
					setT = 0;
					up = 1;
					down = 0;
				}
			}
			
			
			if(drawButton(lcd, "TiltSens", 20, 200, 200, 40))
			{
				lcd.fillScreen(BACKGROUND);
				showSensitivity(lcd);
			}
			
			if(drawButton(lcd,"H", 20,270, 95, 40)){
				returnToMain = 1;
			}
			
			if(drawButton(lcd, "B", 125, 270, 95, 40)){
				lcd.fillScreen(BACKGROUND);
				break;
			}
			
			
		}
}
Пример #18
0
//sub menu which contains checkboxes for setting difficulty (easy, medium, hard) including logics to allow only one button to be set
void showDifficulty(MI0283QT9 lcd, MENUOBJECTS obj, MY_USART serial){
	
	//used to manage one check per set
	uint8_t up = 0;
	uint8_t down = 0;
	uint8_t start = 0;
	
	while(1){
		//drawing checkboxes and text on screen
		lcd.drawText(0, 15, "Difficulty", OBJECTCOLOR, BACKGROUND, 3);
		
		lcd.drawText(15, 80 , "EASY  :", OBJECTCOLOR, BACKGROUND, 2);
		obj.drawCheckbox(lcd, 177, (87 - 24), 48, &easy);
		
		lcd.drawText(15, 150, "MEDIUM:", OBJECTCOLOR, BACKGROUND, 2);
		obj.drawCheckbox(lcd, 177, (157 - 24), 48, &medium);
		
		lcd.drawText(15, 220, "HARD  :", OBJECTCOLOR, BACKGROUND, 2);
		obj.drawCheckbox(lcd, 177, (227 - 24), 48, &hard);
		
		//logics for only 1 checked per click
		if(easy && !start)
		{
			start = 1;
			up = 1;
		}
		else if(medium && !start)
		{
			start = 1;
			up = 0;
			down = 0;
		}
		else if(hard && !start)
		{
			start = 1;
			down = 1;
		}
		
		
		if(easy && up){
			//serial.sendString("easy\n");
			if(medium){
				easy = 0;
				up = 0;
				down = 0;
			}
			
			if(hard){
				easy = 0;
				up = 0;
				down = 1;
			}
		}
		
		if(medium && !up && !down){
			//serial.sendString("medium\n");
			if(easy){
				medium = 0;
				up = 1;
				down = 0;
			}
			
			if(hard){
				medium = 0;
				up = 0;
				down = 1;
			}
		}
		
		if(hard && down){
			//serial.sendString("hard\n");
			if(medium){
				hard = 0;
				up = 0;
				down = 0;
			}
			
			if(easy){
				hard = 0;
				up = 1;
				down = 0;
			}
		}
		
		// if(!easy && !medium && !hard){
		// 	serial.sendString("nothing");
		// }
		
		
		if(obj.drawButton(lcd, "Back", 20, 270, 200, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
	}
}
Пример #19
0
void showSensitivity(MI0283QT9 lcd, MENUOBJECTS obj, MY_USART serial){
	
	uint8_t sUp = 0;
	uint8_t sDown = 0;
	uint8_t sStart = 0;
	
	while(1){
		lcd.drawText(0, 15, "Sensitivity", OBJECTCOLOR, BACKGROUND, 3);
	
		//drawing checkboxes and text on screen
		
		lcd.drawText(15, 80 , "LOW  :", OBJECTCOLOR, BACKGROUND, 2);
		obj.drawCheckbox(lcd, 177, (87 - 24), 48, &sLow);
		
		lcd.drawText(15, 150, "MEDIUM:", OBJECTCOLOR, BACKGROUND, 2);
		obj.drawCheckbox(lcd, 177, (157 - 24), 48, &sMedium);
		
		lcd.drawText(15, 220, "HIGH  :", OBJECTCOLOR, BACKGROUND, 2);
		obj.drawCheckbox(lcd, 177, (227 - 24), 48, &sHigh);
		
		//logics for only 1 checked per click
		if(sLow && !sStart)
		{
			sStart = 1;
			sUp = 1;
		}
		else if(sMedium && !sStart)
		{
			sStart = 1;
			sUp = 0;
			sDown = 0;
		}
		else if(sHigh && !sStart)
		{
			sStart = 1;
			sDown = 1;
		}
		
		
		if(sLow && sUp){
			//serial.sendString("easy\n");
			if(sMedium){
				sLow = 0;
				sUp = 0;
				sDown = 0;
			}
			
			if(sHigh){
				sLow = 0;
				sUp = 0;
				sDown = 1;
			}
		}
		
		if(sMedium && !sUp && !sDown){
			//serial.sendString("medium\n");
			if(sLow){
				sMedium = 0;
				sUp = 1;
				sDown = 0;
			}
			
			if(sHigh){
				sMedium = 0;
				sUp = 0;
				sDown = 1;
			}
		}
		
		if(sHigh && sDown){
			//serial.sendString("hard\n");
			if(sMedium){
				sHigh = 0;
				sUp = 0;
				sDown = 0;
			}
			
			if(sLow){
				sHigh = 0;
				sUp = 1;
				sDown = 0;
			}
		}
	
		if(obj.drawButton(lcd, "Back", 20, 270, 200, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
	}
}
Пример #20
0
/*You will see this screen if you made it in the top 3*/	
void showGameOverMenu(MI0283QT9 lcd, uint16_t score){
	char char1 = 'A';
	char char2 = 'A';
	char char3 = 'A';
	
	int EEPROMfilled = 0;
	
	//checks if address 174 is not 0. If you already played the game once it is set to A, so you won't write unnecessary values to eeprom.
	if(EEPROM.read(174) != 0 ){
		EEPROMfilled = 1;
	}
	
	lcd.fillScreen(BACKGROUND);
	if(EEPROMfilled == 0){
		EEPROM.write(171, 0);
		EEPROM.write(174, 'A');
		EEPROM.write(175, 'A');
		EEPROM.write(176, 'A');
		
		EEPROM.write(172, 0);
		EEPROM.write(177, 'A');
		EEPROM.write(178, 'A');
		EEPROM.write(179, 'A');
		
		EEPROM.write(173, 0);
		EEPROM.write(180, 'A');
		EEPROM.write(181, 'A');
		EEPROM.write(182, 'A');
	}
	
	if(hard){
		score = score * 2;
	}
	
	
	while(1){
		
		//we had to check in this menu on restart game and return to main, because if you got an highscore and press accept you will be directed to shownohighscore menu. If you press back to menu or restart game you will be directed to this menu. Now you break again and reach the gameloop.
		if(restartGame){
			restartGame = 1;
			break;
		}
		
		if(returnToMain){
			returnToMain = 1;
			break;
		}
		
		if(EEPROM.read(173) >= score){
			lcd.fillScreen(BACKGROUND);
			showNoHighScore(lcd, score, 0);
		}else if(EEPROM.read(173) < score) {
			
			char title[] = "You DIED!";
			
			lcd.drawText(centerText(title, 3), 15, title, OBJECTCOLOR, BACKGROUND, 3);
			
			lcd.drawText(centerText("Highscore!!!", 2), 40, "Highscore!!!", OBJECTCOLOR, BACKGROUND, 2);
			if(hard){
				lcd.drawText(centerText("Hard Bonus Score ( x 2)!", 1), 65, "Hard Bonus Score ( x 2)!", OBJECTCOLOR, BACKGROUND, 1);
			}
			
			
			lcd.drawInteger(70, 80, score, DEC, OBJECTCOLOR, BACKGROUND, 3);
			
			//you can fill in 3 characters, which will  be your name in the highscore menu.
			char name[] = "Your Name?";
			lcd.drawText(centerText(name, 2), 140, name, OBJECTCOLOR, BACKGROUND, 2);
			
			char1 =	drawCharSelector(lcd, 35, 160, char1);
			char2 =	drawCharSelector(lcd, 95, 160, char2);
			char3 =	drawCharSelector(lcd, 155, 160, char3);
			
			//if you press accept you will write your score to the eeprom ad then you will be directed to the show No highscore menu.
			if(drawButton(lcd, "Accept", 20, 240, 200, 40)){
				if(EEPROM.read(171) < score){
					uint8_t scoreaddress1 = EEPROM.read(171);
					char char1Address1 = EEPROM.read(174);
					char char2Address1 = EEPROM.read(175);
					char char3Address1 = EEPROM.read(176);
					uint8_t scoreaddress2 = EEPROM.read(172);
					char char1Address2 = EEPROM.read(177);
					char char2Address2 = EEPROM.read(178);
					char char3Address2 = EEPROM.read(179);
					
					
					EEPROM.write(171, score);
					EEPROM.write(174, char1);
					EEPROM.write(175, char2);
					EEPROM.write(176, char3);
					
					EEPROM.write(172, scoreaddress1);
					EEPROM.write(177, char1Address1);
					EEPROM.write(178, char2Address1);
					EEPROM.write(179, char3Address1);
					
					EEPROM.write(173, scoreaddress2);
					EEPROM.write(180,char1Address2);
					EEPROM.write(181, char2Address2);
					EEPROM.write(182, char3Address2);
					
				}else if(EEPROM.read(172) < score){
					uint8_t scoreaddress2 = EEPROM.read(172);
					char char1Address2 = EEPROM.read(177);
					char char2Address2 = EEPROM.read(178);
					char char3Address2 = EEPROM.read(179);
					
					EEPROM.write(172, score);
					EEPROM.write(177, char1);
					EEPROM.write(178, char2);
					EEPROM.write(179, char3);
					
					EEPROM.write(173, scoreaddress2);
					EEPROM.write(180, char1Address2);
					EEPROM.write(181, char2Address2);
					EEPROM.write(182, char3Address2);
					
				}else if(EEPROM.read(173) < score){
					EEPROM.write(173, score);
					EEPROM.write(180, char1);
					EEPROM.write(181, char2);
					EEPROM.write(182, char3);
				}
				lcd.fillScreen(BACKGROUND);
				showNoHighScore(lcd, score, 1);
			}

			}
		}
		
	
}