Exemple #1
0
bool DrasculaEngine::confirmExit() {
	byte key = 0;

	color_abc(kColorRed);
	updateRoom();
	centerText(_textsys[1], 160, 87);
	updateScreen();

	delay(100);
	while (!shouldQuit()) {
		key = getScan();
		if (key != 0)
			break;

		// This gives a better feedback to the user when he is asked to
		// confirm whether he wants to quit. It now still updates the room and
		// shows mouse cursor movement. Hopefully it will work in all
		// locations of the game.
		updateRoom();
		color_abc(kColorRed);
		centerText(_textsys[1], 160, 87);
		updateScreen();
	}

	if (key == Common::KEYCODE_ESCAPE || shouldQuit()) {
		stopMusic();
		return false;
	}

	return true;
}
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;
			}
		}
	}
}
Exemple #3
0
void main(void)
{
    CAP_BUTTON keypressed_state;

    int countdownCount;

    State state = STATE_WELCOME;

    // Stop WDT
    WDTCTL = WDTPW | WDTHOLD;		// Stop watchdog timer

    //Perform initializations (see peripherals.c)
    configTouchPadLEDs();
    configDisplay();
    configCapButtons();
    GrClearDisplay(&g_sContext);
    GrStringDrawCentered(&g_sContext, "MSP430 H3R0", AUTO_STRING_LENGTH, 51, 32,
                         TRANSPARENT_TEXT);
    GrFlush(&g_sContext);

    /* Monitor Capacitive Touch Pads in endless "forever" loop */
    while(1)
    {
        switch(state)
        {
        case STATE_WELCOME:
            if(checkButtons() & BUTTON1)
            {
                state = STATE_COUNTDOWN;
            }
            break;

        case STATE_COUNTDOWN:
            centerText("3");
            configLED1_3(BIT3);
            wait(COUNTDOWN_TIMER);

            centerText("2");
            configLED1_3(BIT2);
            wait(COUNTDOWN_TIMER);

            centerText("1");
            configLED1_3(BIT1);
            wait(COUNTDOWN_TIMER);

            centerText("GO!");
            configLED1_3(BIT3 | BIT2 | BIT1);
            wait(COUNTDOWN_TIMER);

            //TODO: next state
            break;
        }
    }
}
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;
			}
		}
	}
}
Exemple #5
0
//指定した座標を中心に文字を描画 文字の間隔を指定可能
void DrawImpl::centerTextSpace(const Vector2& pos, int color, int fontHandle, int space, const std::string &str, int alpha, int blendMode){
	SetDrawBlendMode(blendMode, alpha);
	if ((str.size() % 2) == 0){
		for (int i = 0; i < str.size(); i++){
			double basex = -(double)(str.size() / 2) * space + space / 2;
			centerText(Vector2(pos.x + i * space + basex, pos.y), color, fontHandle, str.substr(i, 1), alpha, blendMode);
		}
	}
	else{
		for (int i = 0; i < str.size(); i++){
			double basex = -(double)(str.size() / 2) * space;
			centerText(Vector2(pos.x + i * space + basex, pos.y), color, fontHandle, str.substr(i, 1), alpha, blendMode);
		}
	}
}
Exemple #6
0
MenuResult ComboBox::handleEvent(sf::Event & newEvent, sf::Vector2f mousePos)
{
	if (_Enabled)
	{
		if (newEvent.type == sf::Event::MouseMoved)
		{
			_HoveringLeft = pointInRectangle(_ButtonLeft.getGlobalBounds(), mousePos);
			_HoveringRight = pointInRectangle(_ButtonRight.getGlobalBounds(), mousePos);

			_Hovering = _HoveringLeft || _HoveringRight;
		}
		if (newEvent.type == sf::Event::MouseButtonPressed)
		{
			if (pointInRectangle(_ButtonLeft.getGlobalBounds(), mousePos))
			{
				_CurrentItem = (_CurrentItem - 1 < 0) ? _Items.size() - 1 : _CurrentItem - 1;
			}
			else if (pointInRectangle(_ButtonRight.getGlobalBounds(), mousePos))
			{
				_CurrentItem = (_CurrentItem + 1 >= _Items.size()) ? 0 : _CurrentItem + 1;	
			}

			_Text.setString(_Items[_CurrentItem]);
			centerText();
		} 

	}

	return MenuResult::Nothing;
}
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;
		}
		
	}
}
Exemple #8
0
void displayLangSelection(char * browseDirectory)
{	
	langSelection = oslLoadImageFilePNG("system/settings/langSelection.png", OSL_IN_RAM, OSL_PF_8888);

	oslSetFont(Roboto);
	
	browseDirectory = langBrowse("system/settings/language"); //For language

	if (!langSelection)
		debugDisplay();
	
	while (!osl_quit)
	{
		LowMemExit();
	
		oslStartDrawing();
		
		oslClearScreen(RGB(0,0,0));
		
		centerText(480/2, 272/2, browseDirectory, 50);
		
		oslEndDrawing(); 
		oslEndFrame(); 
		oslSyncFrame();	
	}
}
Exemple #9
0
// drawMenu - displays the game menu
void drawMenu(void) {
	short int loop;

	// draw the three menu selections
	for (loop = START; loop <= QUIT; loop++) {
		centerText(intro[loop],MENUSTART+(loop*MENUSTEP));
	}
}
Exemple #10
0
 void text_button::create(std::string const & s, int xpos, int ypos)
 {
     *this = text_button();
     m_text.setString(s);
     setPosition(static_cast<float>(xpos), static_cast<float>(ypos));
     updateButtonSizeToFit();
     centerText();
     m_show = true;
 }
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;
		}
	}
	
}
ButtonObject::ButtonObject(float width, float height) :
_shape(sf::Vector2f(width, height)),
_text("", AssetLoader::Instance()->fontFromFile("sansation.ttf")) {
    
    _text.setColor(sf::Color::White);
    
    _shape.setFillColor(sf::Color::Blue);
    _shape.setOutlineColor(sf::Color::Black);
    _shape.setOutlineThickness(4);
    
    centerText();
}
Exemple #13
0
// drawSpeedOption - draws the speed setting (i.e. slow, fast, average)
void drawSpeedOption(short int speed) {
	char speedStr[25];

	// truncate to 0-length
	speedStr[0] = 0;

	// create the speed string
	strcat(speedStr,intro[SPEED]);
	strcat(speedStr,speeds[speed]);

	// display the string
	centerText((const char *)speedStr,MENUSTART);
}
Exemple #14
0
// drawDifficultyOption - draws the difficulty setting (i.e. easy, hard, medium)
void drawDifficultyOption(short int difficulty) {
	char difficultyStr[25];

	// truncate to 0-length
	difficultyStr[0] = 0;

	// create the difficulty string
	strcat(difficultyStr,intro[DIFFICULTY]);
	strcat(difficultyStr,difficulties[difficulty]);

	// display the string
	centerText((const char *)difficultyStr,MENUSTART+MENUSTEP);
}
Exemple #15
0
//文字を描画・位置指定
void DrawImpl::textPlaceSpace(const Vector2& pos, int color, int fontHandle, const std::string &str, int alpha, double space, HorizontalPlace::en fh, VerticalPlace::en fv, int blendMode){
	Vector2 dPos(0, 0);
	if (fv == VerticalPlace::en::center){
		dPos.y -= GetFontSizeToHandle(fontHandle) / 2.0;
	}
	else if (fv == VerticalPlace::en::bottom){
		dPos.y -= GetFontSizeToHandle(fontHandle);
	}

	SetDrawBlendMode(blendMode, alpha);
	if (fh == HorizontalPlace::en::left){
		for (int i = 0; i < str.size(); i++){
			centerText(Vector2(pos.x + i * space, pos.y) + dPos, color, fontHandle, str.substr(i, 1), alpha, blendMode);
		}
	}
	else if (fh == HorizontalPlace::en::center){
		if ((str.size() % 2) == 0){
			for (int i = 0; i < str.size(); i++){
				dPos.x = -(double)(str.size() / 2) * space + space / 2;
				centerText(Vector2(pos.x + i * space, pos.y) + dPos, color, fontHandle, str.substr(i, 1), alpha, blendMode);
			}
		}
		else{
			for (int i = 0; i < str.size(); i++){
				dPos.x = -(double)(str.size() / 2) * space;
				centerText(Vector2(pos.x + i * space, pos.y) + dPos, color, fontHandle, str.substr(i, 1), alpha, blendMode);
			}
		}
	}
	else if (fh == HorizontalPlace::en::right){
		for (int i = 0; i < str.size(); i++){
			dPos.x = -(double)(str.size() - 1) * space;
			centerText(Vector2(pos.x + i * space, pos.y) + dPos, color, fontHandle, str.substr(i, 1), alpha, blendMode);
		}
	}
	textDrawLog.set(pos, color, fontHandle, alpha, blendMode);
}
Exemple #16
0
 text_button::text_button()
   : m_id(menu_item_id::none), m_text(), m_rect()
   , m_hovered_color(menu_button_hovered_outline_color)
   , m_default_color(menu_button_default_outline_color)
 {
     m_text.setColor(menu_text_color);
     m_text.setCharacterSize(menu_font_size);
     m_text.setFont(resource_manager::get()[menu_font_id]);
     
     m_rect.setFillColor(menu_button_fill_color);
     m_rect.setOutlineColor(m_default_color);
     m_rect.setOutlineThickness(menu_button_outline_size);
     m_rect.setSize(sf::Vector2f(menu_button_width, menu_button_height));
     
     updateButtonSizeToFit();
     centerText();
 }
Exemple #17
0
void DrasculaEngine::moveCursor() {
	copyBackground();

	updateRefresh_pre();
	moveCharacters();
	updateRefresh();

	if (!strcmp(textName, "hacker") && _hasName) {
		if (_color != kColorRed && !_menuScreen)
			color_abc(kColorRed);
	} else if (!_menuScreen && _color != kColorLightGreen)
		color_abc(kColorLightGreen);
	if (_hasName && !_menuScreen)
		centerText(textName, _mouseX, _mouseY);
	if (_menuScreen)
		showMenu();
	else if (_menuBar)
		clearMenu();
}
Exemple #18
0
bool DrasculaEngine::confirmExit() {
	byte key;

	color_abc(kColorRed);
	updateRoom();
	centerText(_textsys[1], 160, 87);
	updateScreen();

	delay(100);
	for (;;) {
		key = getScan();
		if (key != 0)
			break;
	}

	if (key == Common::KEYCODE_ESCAPE) {
		stopMusic();
		return false;
	}

	return true;
}
Exemple #19
0
void GameOverState::handleEvents()
{
	sf::Event event;
	while (window->pollEvent(event))
	{
		if (event.type == sf::Event::EventType::Closed)
		{
			window->close();
		}
		if(event.type == sf::Event::EventType::TextEntered && event.text.unicode < 128)
		{
			if (event.text.unicode == '\b' && !name.empty())
			{
				name.pop_back();
			}
			else if (name.size() < 15 && event.text.unicode > 8)
			{
				name += event.text.unicode;
			}
			nameField.setString(name);
			centerText(nameField, 250.f);
		}
		if (event.type == sf::Event::EventType::MouseButtonReleased && event.mouseButton.button == sf::Mouse::Left)
		{
			if (confirmButton.getGlobalBounds().contains(event.mouseButton.x, event.mouseButton.y))
			{
				postScore();
				game->changeState(Game::States::HIGHSCORES);
				break;
			}
			if (cancelButton.getGlobalBounds().contains(event.mouseButton.x, event.mouseButton.y))
			{
				game->changeState(Game::States::MAIN_MENU);
				break;
			}
		}
	}

}
Exemple #20
0
ComboBox::ComboBox(sf::Vector2f pos, std::vector<std::string> &Items, MenuResult Action, int width, int height) : MenuItem(MenuItemType::MCombobox, Action),
	_Items(Items), _Position(pos),
	_CurrentItem(0), _Height(height), _BodyWidth(width - 40), _ButtonWidth(20), _TextSize(40),
	_BgColorEnabled(sf::Color(0, 0, 0, 175)), _BgColorHovering(sf::Color(50, 50, 50, 100)), _BgColorDisabled(sf::Color(0, 0, 0, 175)), 
	_FgColorEnabled(sf::Color(255, 255, 255, 255)), _FgColorDisabled(sf::Color(150, 150, 150, 255))
{
	_Body.setPosition(pos + sf::Vector2f(_ButtonWidth, 0));
	_Body.setSize(sf::Vector2f(_BodyWidth, _Height));
	_Body.setOutlineThickness(1);
	_Body.setOutlineColor(sf::Color::Black);

	_ButtonLeft.setPosition(pos);
	_ButtonLeft.setSize(sf::Vector2f(_ButtonWidth, _Height));
	_ButtonLeft.setOutlineThickness(1);
	_ButtonLeft.setOutlineColor(sf::Color::Black);

	_ButtonRight.setPosition(pos + sf::Vector2f(_ButtonWidth + _BodyWidth, 0));
	_ButtonRight.setSize(sf::Vector2f(_ButtonWidth, _Height));
	_ButtonRight.setOutlineThickness(1);
	_ButtonRight.setOutlineColor(sf::Color::Black);

	if (_ArrowTexture.loadFromFile("Resources/Texture/MainMenu/ComboboxArrow.png"))
	{
		_LeftArrowSprite.setTexture(_ArrowTexture);
		_RightArrowSprite.setTexture(_ArrowTexture);

		_LeftArrowSprite.setTextureRect(sf::IntRect(_ArrowTexture.getSize().x, 0, -1 * _ArrowTexture.getSize().x, _ArrowTexture.getSize().y));

		_LeftArrowSprite.setPosition(pos + sf::Vector2f(0.5f * _ButtonWidth - 0.5f * _ArrowTexture.getSize().x, 0.5f * _Height - 0.5f * _ArrowTexture.getSize().y));
		_RightArrowSprite.setPosition(pos + sf::Vector2f(_BodyWidth + _ButtonWidth + 0.5f * _ButtonWidth - 0.5f * _ArrowTexture.getSize().x, 0.5f * _Height - 0.5f * _ArrowTexture.getSize().y));
	}
	
	_Text.setFont(_Font);
	_Text.setColor(sf::Color::White);
	_Text.setCharacterSize(_TextSize);
	_Text.setString(_Items[_CurrentItem]);
	centerText();
}
Exemple #21
0
int mp3View(char * browseDirectory)
{	
	mp3bg = oslLoadImageFilePNG(apolloBgPath, OSL_IN_RAM, OSL_PF_8888);
	mp3_select = oslLoadImageFilePNG(apolloSelectorPath, OSL_IN_RAM, OSL_PF_8888);

	oslSetFont(Roboto);

	char * Directory = mp3Browse(browseDirectory);

	while (!osl_quit)
	{		
		LowMemExit();
	
		oslStartDrawing();
		oslClearScreen(RGB(0,0,0));	
		
		centerText(480/2, 272/2, Directory, 50);	// Shows the path that 'Directory' was supposed to receive from mp3Browse();
	 
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
	}	
	return 0;
}
Exemple #22
0
void Button::setFont(const sf::Font &font)
{
    text.setFont(font);
    centerText();
}
Exemple #23
0
void Button::setTexture(const sf::Texture &texture)
{
    sprite.setTexture(texture);
    changeTexture(Type::Normal);
    centerText();
}
void ButtonObject::update(float dt) {
    if (_needsLayout) {
        centerText();
    }
}
Exemple #25
0
void ComboBox::setValue(float x)
{
	_CurrentItem = ((int)x % _Items.size());
	_Text.setString(_Items[_CurrentItem]);
	centerText();
}
//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);
			
		}
	}
}
Exemple #27
0
// drawOptionsMenu - draws the options menu items
inline void drawOptionsMenu(short int speed, short int difficulty) {
	drawSpeedOption(speed);
	drawDifficultyOption(difficulty);

	centerText(intro[QUITOPTIONS],MENUSTART+(2*MENUSTEP));
}
Exemple #28
0
void Button::setText(const std::string &text)
{
    this->text.setString(text);
    centerText();
}
/*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);
			}

			}
		}
		
	
}
Exemple #30
0
//指定した座標を中心に文字を描画 文字の間隔を指定可能
void DrawImpl::textSpace(const Vector2& pos, int color, int fontHandle, int space, const std::string &str, int alpha, int blendMode){
	SetDrawBlendMode(blendMode, alpha);
	for (int i = 0; i < str.size(); i++){
		centerText(Vector2(pos.x + i * space, pos.y), color, fontHandle, str.substr(i, 1), alpha, blendMode);
	}
}