void Button::draw() { // Rect principal bouton drawSquare(Vector2(mFirstRect.x, mFirstRect.y), static_cast<int>(mFirstRect.w), static_cast<int>(mFirstRect.h), mBackgroundColor, { 1.0f, 0.0f, 0.0f, 0.0f }); // Effet 3D ColorStruct secondSquare(mBackgroundColor.r - 0.2f, mBackgroundColor.g - 0.2f, mBackgroundColor.b - 0.2f, mBackgroundColor.a); drawSquare(Vector2(mSecondRect.x, mSecondRect.y), static_cast<int>(mSecondRect.w), static_cast<int>(mSecondRect.h), secondSquare, { 1.0f, 0.0f, 0.0f, 0.0f }); // Survol => ombre if (mIsHightlighted) drawStringCentered(mLabel, Vector2(mFirstRect.x + 1, mFirstRect.y + 1), Vector2(mFirstRect.w, mFirstRect.h), { 0.0f, 0.0f, 0.0f, 0.0f }, true, true); // Label du texte drawStringCentered(mLabel, Vector2(mFirstRect.x, mFirstRect.y), Vector2(mFirstRect.w, mFirstRect.h), mLabelColor, true, true); }
void gameOverScreen() { drawImage3(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH, (const u16*) img_game_over); sprintf(strBuffer, "Score: %d", score); drawStringCentered(SCREEN_HEIGHT / 2 + 14, SCREEN_WIDTH / 2, strBuffer, WHITE); int keysPressed = 0; //game over screen loop while (1) { //test button release for all buttons for (int i = 0; i < 10; i++) { if (KEY_DOWN_NOW(1 << i)) { keysPressed |= (1 << i); } if ((keysPressed & (1 << i)) && !KEY_DOWN_NOW(1 << i)) { titleScreen(); } } } }
bool SceneGame :: draw() { if(!Scene::draw()) return false; float centreX = APP_WIDTH/2; float centreY = APP_HEIGHT/2; ofPushStyle(); if(currentGame == GAME_INVADERS) { for(int i = 0; i<invaders.size(); i++) { Invader& invader = *invaders[i]; if(!invader.enabled) continue; invader.draw(); activeInvaders++; } ofSetColor(255); if((gameState == STATE_PREINTRO)&&(playing)) { if(timeSinceLastStateChange<8) { String s = "READY TO PLAY INVADERS?"; drawStringCentered(s, centreX, centreY-50); float flashspeed = 1.0f; if(modff(timeSinceLastStateChange,&flashspeed)<0.7) { drawStringCentered("YES / NO", centreX, centreY+50); } } else if((timeSinceLastStateChange>9) && (timeSinceLastStateChange<18)) { String s = "I SAID"; drawStringCentered(s, centreX, centreY-100); if(timeSinceLastStateChange>11) { drawStringCentered("ARE YOU READY TO PLAY?", centreX, centreY); float flashspeed = 1.0f; if(modff(timeSinceLastStateChange,&flashspeed)<0.7) { drawStringCentered("YES OR NO", centreX, centreY+100); } } } } else if(gameState == STATE_INTRO) { String s = "PLAYERS GET READY"; drawStringCentered(s, centreX, centreY-50); int secondsToGo = 5-ceil(timeSinceLastStateChange); if(secondsToGo<=3) { s= ofToString(secondsToGo); drawStringCentered(s, centreX, centreY+50); } } else if(gameState == STATE_WAITING) { String s = "LEVEL "+ofToString(level)+" CLEARED!"; drawStringCentered(s, centreX, centreY-50); int secondsToGo = 5-ceil(timeSinceLastStateChange); if(secondsToGo<=3) { s= "NEXT LEVEL IN "+ ofToString(secondsToGo); drawStringCentered(s, centreX, centreY+50); } } else if(gameState == STATE_GAMEOVER) { ofSetColor(255); drawStringCentered("GAME OVER", centreX, centreY); } } else if(currentGame == GAME_ASTEROIDS) { for(int i = 0; i<asteroids.size(); i++) { Asteroid& asteroid = *asteroids[i]; if(!asteroid.enabled) continue; asteroid.draw(); } if(gameState == STATE_INTRO) { String s = "PLAYERS GET READY"; drawStringCentered(s, centreX, centreY-50); int secondsToGo = 5-ceil(timeSinceLastStateChange); if(secondsToGo<=3) { s= ofToString(secondsToGo); drawStringCentered(s, centreX, centreY+50); } } else if(gameState == STATE_WAITING) { String s = "LEVEL "+ofToString(level)+" CLEARED!"; drawStringCentered(s, centreX, centreY-50); int secondsToGo = 5-ceil(timeSinceLastStateChange); if(secondsToGo<=3) { s= "NEXT LEVEL IN "+ ofToString(secondsToGo); drawStringCentered(s, centreX, centreY+50); } //ofDrawBitmapString("LEVEL "+ofToString(level)+" CLEARED " + ofToString(ofGetElapsedTimef()-lastStateChangeTime), 500,500); } else if(gameState == STATE_GAMEOVER) { ofSetColor(255); //ofDrawBitmapString("GAME OVER" + ofToString(ofGetElapsedTimef()-lastStateChangeTime), 500,500); drawStringCentered("GAME OVER", centreX, centreY); } } // ofDrawBitmapString("GAME: " + ofToString(currentGame), 10,500); // ofDrawBitmapString("STATE: " + ofToString(gameState), 10,550); // ofDrawBitmapString("TIME SINCE CHANGE: " + ofToString(timeSinceLastStateChange), 10,600); ofPopStyle(); }