void redraw(unsigned int* framePointer) { drawAliens(); drawHUD(); drawBullets(0x00FF0000); draw_bunker(0x0000FF00); draw_tank(0x0000FF00); drawAliens(); drawHUD(); drawBullets(0x00FF0000); draw_bunker(0x0000FF00); draw_tank(0x0000FF00); }
void drawGame(void) { GLint i; polycount = 0; clearScreen(); glShadeModel( GL_SMOOTH ); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); for(i = 0; i < vp_max[gViewportType]; i++) { Player *p = game->player + viewport_content[i]; PlayerVisual *pV = gPlayerVisuals + viewport_content[i]; Visual *d = & pV->display; if(d->onScreen == 1) { glViewport(d->vp_x, d->vp_y, d->vp_w, d->vp_h); drawCam(p, pV); /* hud stuff for every player */ drawHUD(p, pV); } } /* printf("%d polys\n", polycount); */ }
void testApp::draw(){ ofBackgroundGradient(ofColor(65,62,50),ofColor(25,22,10) ); ofSetColor(255); ofPushMatrix(); ofTranslate(200,0); glEnable(GL_DEPTH_TEST); // Manually enable for controlpanel camera.begin(); //Create mesh if(panel.getValueB("manualCamera")) { camera.setPosition(ofVec3f(panel.getValueF("lightx"),panel.getValueF("lighty"),panel.getValueF("lightz"))); } ofRotateZ(152.0f); ofRotateX(panel.getValueF("rotate")); //Draw loop graph.bind(); if(panel.getValueB("wireframe")) { mesh.drawWireframe(); } else { mesh.draw(); } graph.unbind(); camera.end(); ofPopMatrix(); glDisable(GL_DEPTH_TEST); // Manually disable, then draw text + ofxACP drawHUD(); }
void IngameState::draw(GameRenderer* r) { if( !getWorld()->state->isCinematic && getWorld()->isCutsceneDone() ) { drawHUD(_look, game->getPlayer(), getWorld(), r); } State::draw(r); }
void draw2D(){ glPushMatrix(); // TRANSLATE & SCALE: (0,0) to center, screen width to 1.0 glTranslatef(WIDTH*0.5, HEIGHT*0.75, 0.0f); glScalef(WIDTH, WIDTH, WIDTH); // NOW: dimensions are 1.0 = width of screen drawGround(); glScalef(INTERVAL*INTERVAL, INTERVAL*INTERVAL, INTERVAL*INTERVAL); glPushMatrix(); // SCALE: zoom cycle glScalef(zoomCycleScale, zoomCycleScale, zoomCycleScale); for(int i = LVL_LOW; i < LVL_HIGH; i++){ glPushMatrix(); // with each zoom level we also calculate the fmodf of the translation float lvlWidth = 1.0/powf(INTERVAL, i); int lvlTransWhole = -transExp / lvlWidth; float lvlTransPart = modf(-(transExp)/lvlWidth, &unused); // int lvlTransWhole_OFF = -transExp / lvlWidth - 0.5; // float lvlTransPart_OFF = modf(-(transExp)/lvlWidth - 0.5, &unused); // glTranslatef(-transExp - lvlTransWhole_OFF * lvlWidth, 0, 0); int lvlTransWhole_OFF = -transExp / lvlWidth - 0.5*(INTERVAL_IS_ODD); float lvlTransPart_OFF = modf(-(transExp)/lvlWidth - 0.5*(INTERVAL_IS_ODD), &unused); glTranslatef(-transExp - (lvlTransWhole_OFF - 0.5*(!INTERVAL_IS_ODD)) * lvlWidth, 0, 0); float scale = powf(INTERVAL, i); float color = (i-zoom) / (LVL_HIGH-LVL_LOW); glScalef(1.0/scale, 1.0/scale, 1.0/scale); sprintf(zoomReports[i], "%f : (%d) %f : [(%d) %f]", lvlWidth, lvlTransWhole, lvlTransPart, lvlTransWhole_OFF, lvlTransPart_OFF); unsigned char highlight = 0; for(int i = 1; i <= INTERVAL; i++){ float seg = (float)i / INTERVAL; if(fabs(lvlTransPart_OFF) < seg){ highlight = i; break; } } repeating2DScene(color, highlight); glPopMatrix(); } glPopMatrix(); // SCALE: zoom cycle glPopMatrix(); // TRANSLATE & SCALE: (0,0) to center, screen width to 1.0 if(showHUD) drawHUD(); }
/* gameVisuals() Draws the map, people, HUD, and mouse, in that order. */ void gameVisuals() { drawGrid (); //Draws map and people if (mouseGridX >= 0 && mouseGridY >= 0) { //Draw the map highlighter draw_sprite(screenBuffer, selector, placeOnGridX(mouseGridX, mouseGridY),placeOnGridY(mouseGridX, mouseGridY)); } drawHUD(); draw_sprite(screenBuffer, mousePic, mouseX, mouseY); blit(screenBuffer, screen, 0,0,0,0,1024,768); //Blit the buffer clear_bitmap(screenBuffer); }
void Player::draw() { glColor4f( 1.0f, 1.0f, 1.0f, 0.0f); GLfloat xtrans = -xpos; //Used For Player Translation On The X Axis GLfloat ztrans = -zpos; //Used For Player Translation On The Z Axis GLfloat ytrans = -walkbias-0.25f; //Used For Bouncing Motion Up And Down GLfloat sceneroty = 360.0f-yrot; //360 Degree Angle For Player Direction glRotatef(0.0f, 1.0f, 0.0f , 0.0f); //Rotate Up And Down To Look Up And Down glRotatef(sceneroty, 0.0f, 1.0f , 0.0f); //Rotate Depending On Direction Player Is Facing glTranslatef(xtrans, ytrans, ztrans); //Translate The Scene Based On Player Position drawHUD(); check(); }
void display() { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); assert( g_executable_simulation != NULL ); g_executable_simulation->renderSceneOpenGL(); drawHUD(); glutSwapBuffers(); assert( renderingutils::checkGLErrors() ); }
void Renderer::display(void) { //clear window glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //draw splash screen if(splash){ glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, textureID[3]); glPushMatrix(); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1, 1, -2); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1, -1, -2); glTexCoord2f(1.0f, 0.0f); glVertex3f(1, -1, -2); glTexCoord2f(1.0f, 1.0f); glVertex3f(1, 1, -2); glEnd(); glPopMatrix(); glDisable(GL_TEXTURE_2D); } else { if(lighting){ glEnable(GL_LIGHTING); } glPushMatrix(); //Push -- camera glLoadMatrixd(camera->getModelViewMatrix()); glPushMatrix(); //Push -- draw world drawRoom(); glPopMatrix(); //Pop -- draw world drawTreasures(); glPopMatrix(); //Pop -- camera if(lighting){ glDisable(GL_LIGHTING); } drawHUD(); frameCount++; } glutSwapBuffers(); }
// functia de display void display(void) { // de fiecare data cand desenam, la inceput resetam toate bufferurile a.i // ele sa aiba valorile initiale definite de functiile: // glClearColor ... va seta culoarea backgroundului, vezi init // glClearDepth ... va seta valoarea cea mai indepartata a adancimii (adica 1), pentru // ca suntem in coordonate fereastra glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Deseneaza scena drawScene(); drawHUD(); //Schimba bufferele glutSwapBuffers(); }
void Manager::draw() const { kungfuback.draw(); for (unsigned i = 1; i < sprites.size(); ++i){ sprites[i]->draw(); } kungfu.draw(); std::list<ExplodingSprite*>::const_iterator itr = explodingSprite.begin(); while(itr != explodingSprite.end() ){ (*itr)->draw(); ++itr; } if(healthLeft) sprites[0]->draw(); io.printMessageAt(title, 10, 460); if(!healthLeft) { clock.pause(); io.printMessageValueAt("Your final score is ", score, 290, 200); } viewport.draw(); io.printMessageValueAt("Your score is ", score , 10 , 440); drawHUD(); SDL_Flip(screen); }
void drawGame(void) { GLint i; clearScreen(); glShadeModel( GL_SMOOTH ); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); for(i = 0; i < vp_max[gViewportType]; i++) { Visual *d = &gPlayerVisuals[viewport_content[i]].display; if(d->onScreen == 1) { glViewport(d->vp_x, d->vp_y, d->vp_w, d->vp_h); drawCam(viewport_content[i]); /* hud stuff for every player */ drawHUD(game->player + viewport_content[i], gPlayerVisuals + viewport_content[i]); } } }
int main(){ bool fin = false; int STEP_WAIT = 100; Mat HUD = Mat::zeros(Y_RESOLUTION, X_RESOLUTION, CV_8UC3); int step = 0; if(initWriter()) return -1; while(!fin){ step ++; int c = waitKey(10); if( (char)c == 27 ) { fin = true; } //Esc key if( (char)c == '+') { STEP_WAIT = STEP_WAIT + 2; } if( (char)c == '-') { STEP_WAIT = STEP_WAIT - 2; } if( (char)c == '0') { checkBlink(0); } if( (char)c == '1') { checkBlink(1); } if( (char)c == '2') { checkBlink(2); } if( (char)c == '3') { checkBlink(3); } if( (char)c == '4') { checkBlink(4); } drawHUD(&HUD); std::cout<<"Tasto: "<<c<<std::endl; if(step >= STEP_WAIT){ step = 0; stepWriter(); } imshow("Writer",HUD); } return 0; }
void draw(Level lvl) { //Clear color buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //handleCamera(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(FoV, WINDOW_WIDTH / WINDOW_HEIGHT, 0.1, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Render Camera camera.render(); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColour); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColour); glLightfv(GL_LIGHT0, GL_SPECULAR, specularColour); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_emission); glPushMatrix(); // Draw Level lvl.draw(); glPopMatrix(); // Draw HUD drawHUD(lvl); SDL_GL_SwapWindow(gWindow); }
void HUD::drawGameOver(int score, int multiplier, int timeRemaining, int sizeX, int sizeY) { drawHUD(score, multiplier, timeRemaining); //Draw a transparent grey quad over the screen to dim for pausing //Set colour glColor4f(0.4f,0.4f,0.4f,0.9f); glBegin(GL_QUADS); glVertex2f(0,0); glVertex2f(0,sizeY); glVertex2f(sizeX, sizeY); glVertex2f(sizeX, 0); glEnd(); //set the colour back to normal glColor4fv(scoreTextColour); //write "TIME OVER" printWithColour(pauseFont, (sizeX/2)-(pauseFont.h*3),sizeY/2+(sizeY/3),scoreTextColour,"TIME OVER"); if(GO_scoreTimer > 0)GO_scoreTimer--;//count down until we should show the score if(GO_scoreTimer == 0) //once our artificial interval is over { //If the scoretimer has hit zero we can display the score //ticking up to the score the player has reached char scoreAstext[10]; sprintf(scoreAstext,"%.0f",GO_score); //We want to align the score RIGHT, as is the tradition with scores. So that the text moves //LEFT as the number of digits increases. float offset = getStringWidth(GO_scoreFont,0,0,scoreAstext); //UPDATE: SKIPPING FUNCTIONALITY BE HERE //by way of a skipping flag that is waved by the mainclass via a public if(skipGO_flag)//false by default { GO_score = score;//auto-meet the conditions to end the "ticking-up" loop } if(GO_score<score) {//If GO_score is less than score, //print the score white as it is clocking up printWithColour(scoreTextFont,(sizeX/2)-100, (sizeY/2)+(sizeY/3)-((GO_scoreFont.h*2)-5),GO_scoreColour, "SCORE:"); printWithColour(GO_scoreFont, (sizeX/2)+(sizeX/3)-offset,(sizeY/2)+(sizeY/3)-((GO_scoreFont.h*2)-5),GO_scoreColour,scoreAstext); float scorePerFrame = score/120;//continue adding to GO_score GO_score += scorePerFrame;//divided by the number of frames we want it to take }else{ //if the GO_score has reached its destination, still draw it, //but start pulsating //ALSO throughout the 'clocking up', GO_Score can become //distorted slightly through rounding up and whatnot. //So once we're up here, let's just draw the ACTUAL score. char actualScoreAsText[10]; _itoa(score, actualScoreAsText, 10); printWithColour(scoreTextFont,(sizeX/2)-100, (sizeY/2)+(sizeY/3)-((GO_scoreFont.h*2)-5),GO_scoreColour, "SCORE:"); printWithColour(GO_scoreFont, (sizeX/2)+(sizeX/3)-offset,(sizeY/2)+(sizeY/3)-((GO_scoreFont.h*2)-5),GO_scoreColour,actualScoreAsText); pulsateColour(white,blue, GO_scoreColour, CS_GO_score, 20); //retry float retryOffset = getStringWidth(GO_retryFont,0,0,"Press 'r' to retry")/2; float quitOffset = getStringWidth(GO_retryFont,0,0,"Press 'q' to return to the menu")/2; printWithColour(GO_retryFont, (sizeX/2) - retryOffset,100, white,"Press 'r' to retry"); printWithColour(GO_retryFont, (sizeX/2) - quitOffset,100-(GO_retryFont.h+3), white,"Press 'q' to return to the menu"); } } }
void RenderingCoreAnaglyph::drawAll() { renderBothImages(); drawPostFx(); drawHUD(); }
void RenderingCoreInterlaced::drawAll() { renderBothImages(); merge(); drawHUD(); }
void PlaySpace::draw() { RenderTarget* oldTarget = Renderer.Context.renderTarget(); if(oldTarget->size() != HDRTarget->size()) { delete HDRTarget; HDRTarget = new Framebuffer(oldTarget->size().X, oldTarget->size().Y, 16); } Renderer.Context.setRenderTarget(HDRTarget); float alphaMult = Max(Renderer.Context.Camera.Zoom.length()+0.2f, 0.0f); alphaMult *= alphaMult; alphaMult = Min(alphaMult-0.1f, 1.0f); Renderer.clear(Colors::Dawnbringer::Clay[0] / 1.5f * (1-alphaMult)); auto& r = Renderer; if(alphaMult > 0.05f) { r.drawRepeatedInf(gAssets.BG.Stars, 0, 1.00f, 0.05f, Vec4F(Colors::White, 0.75f * alphaMult)); r.drawRepeatedInf(gAssets.BG.Fog2, 0, 4.20f, 0.15f, Vec4F(0.22f, 0.15f, 0.14f, 0.5f * alphaMult)); r.drawRepeatedInf(gAssets.BG.Stars, 0, 1.20f, 0.25f, Vec4F(Colors::White, 0.75f * alphaMult)); r.drawRepeatedInf(gAssets.BG.Fog1, 0, 3.90f, 0.40f, Vec4F(0.22f, 0.15f, 0.14f, alphaMult)); r.drawRepeatedInf(gAssets.BG.Stars, 0, 1.60f, 0.58f, Vec4F(Colors::White, alphaMult)); r.drawRepeatedInf(gAssets.BG.Fog2, 0, 2.75f, 0.80f, Vec4F(0.32f, 0.20f, 0.14f, alphaMult)); } for(GravitySource& src : GravitySources) src.draw(r); for(Bullet& obj : Bullets) obj.draw(r); for(PhysicsObject* obj : Objects) obj->draw(r); for(Particle& particle : Particles) particle.draw(r); for(GravitySource& src : GravitySources) src.drawTop(r); for(Bullet& obj : Bullets) obj.drawTop(r); r.flush(); Renderer.Context.setRenderTarget(oldTarget); Renderer.clear(Colors::Black); Renderer.Context.setShader(gAssets.ToneMapping); Renderer.drawRenderpass(*HDRTarget); Renderer.Context.setShader(ShaderProgram::GetDefaultShader()); if(Player) drawHUD(); float sizeMult = 1.f + (1.f / Renderer.Context.Camera.Zoom.length()); if(sizeMult > 3) { for(PhysicsObject* obj : Objects) obj->drawPictogram(r, sizeMult); } r.flush(); }
int main( int argc, char* args[] ) { bool quit = false; if ( init() == false ){ return 1; } if ( load_files() == false ) { return 1; } messageString = "Jewel Matcher"; message = TTF_RenderText_Solid( font, messageString.c_str(), textColor ); if ( message == NULL ) { return 1; } //Apply image to screen apply_surface( 0, 0, backgroundImage, screen ); // Construct Grid of Sockets and Jewels // Based on arbitary grid width provided, determine grid starting coordinates Grid* gameGrid = new Grid(GRID_SIZE, GRID_CENTRE_X, GRID_CENTRE_Y, CELL_W, CELL_H); // Pausing prevents game behaviours, stops timer, stops interaction other than unpausing, but continues draw calls bool isPaused = false; // Flag indicating whether game has finished bool gameOver = false; // Game score counts points player has earned during current game int gameScore = 0; // If the game is animating someting, interaction is prevented bool gridReady = true; // To prevent continuous searching for color groups when the grid has not changed, false flag indicates no need to search bool gridChanged = false; // Track whether (and where) an upClick has occurred bool upClickOccurred = false; int mUpClickX = 0; int mUpClickY = 0; // Track whether the player has moved a jewel bool moveMade = false; // If an illegal move is made (no color groups formed), flag indicates they must be switched back bool legalMove = true; // Game start time int gameStartTime = SDL_GetTicks(); int totalTimeElapsed = 0; int currentTime = gameStartTime; // Track time from previous iteration, for calculating delta-time int prevTime = gameStartTime; // Change in time since last tick int deltaTime = 0; // Increase counter 'accumulatedTime' until it reaches threshold of fixedTimeStep, prompting movements/animations to be performed int accumulatedTime = 0; // Used to instill regularity in animation int fixedTimeStep = 1000; // Controls whether functions are fed 0 or fixedTimeStep as their deltaTime int animationTime = 0; // Illegal moves incur a momentary pause before jewels are switched back // A counter will accumulate animationTime until int switchBackTimeTarget = 11000; int switchBackTimeCounter = 0; //Pause while( quit == false ) { // Event handling while( SDL_PollEvent( &event ) ) { // When exiting the program if( event.type == SDL_QUIT ) { //Exit quit = true; } // Track mouse coordinates if( event.type == SDL_MOUSEMOTION ) { mouseX = event.motion.x; mouseY = event.motion.y; } // On key-up of 'p' key, pause the game if ( event.type == SDL_KEYUP ) { if( event.key.keysym.sym == SDLK_p ) { // Toggling pause isPaused = !isPaused; } } // User Game interaction - EVENTS WHICH OCCUR WHEN BOARD IS STATIC if ( event.type == SDL_MOUSEBUTTONUP ) { // Click-down's don't matter as much as click-ups if( event.button.button == SDL_BUTTON_LEFT ) { upClickOccurred = true; mUpClickX = event.button.x; mUpClickY = event.button.y; } } } // End of poll event clearing // Update timer information if( !gameOver && !isPaused ) { // Determine how much time has elapsed since last iteration currentTime = SDL_GetTicks(); // Time elapsed is totalTimeElapsed = currentTime - gameStartTime; deltaTime = currentTime - prevTime; accumulatedTime += deltaTime; animationTime = 0; if( accumulatedTime >= fixedTimeStep ) { animationTime = fixedTimeStep; // Accumulation variable can keep remainder after fixedTimeStep is taken away from it, as long as remainder is less than fixedTimeStep accumulatedTime = accumulatedTime % fixedTimeStep; } } // Pause inhibits user input and animation if( isPaused && !gameOver ) { // Set message so user understands what state game is in and why interaction is halted. messageString = "Paused - 'p' to Continue"; // Up-Clicks occuring during paused game state are rejected upClickOccurred = false; } else { messageString = "Jewel Matcher"; // Reset flag before checking conditions gridReady = false; // Check if sockets are full gridReady = gameGrid->socketsAreFull( animationTime ); // Check if jewels are moving gridReady = gameGrid->jewelsAreStatic( animationTime ); if( !gridReady ) { // Grid has undergone change from sockets being filled or jewels moving gridChanged = true; } else { // To protect against repeated searched of an un-changed grid, check if the last search set if( gridChanged ) { // Reset the flag to show that gridChanged = false; if( searchForScoringGroups( gameGrid, gameScore ) ) { // Groups were found and scored. Sockets will no longer be full. gridReady = false; if( moveMade ) { // Reset the flag moveMade = false; // Player switched jewels, but no resulting groups have been found legalMove = true; } } else { if( moveMade ) { // Reset the flag moveMade = false; // Player switched jewels, but no resulting groups have been found legalMove = false; } } } } // Check if the game timer has run out yet if( totalTimeElapsed < totalGameLength ) { // Only allow user mouse interaction if game is not handling grid animation etc if( !gridReady ) { // If grid is not ready... // - prompt empty sockets to steal/generate jewels // - prompt jewels to move towards their destinations } else { // Animations have been resolved, grid is ready for input // Illegal moves require jewels to be switched back before the game can continue if( !legalMove ) { switchBackTimeCounter += animationTime; if( switchBackTimeCounter >= switchBackTimeTarget ) { // Reset switchback delay variable switchBackTimeCounter = 0; // Jewel exchange reversal can only occur if two sockets are selected if( selectedSockets.size() == 2 ) { // Invalid move by those currently in selection must be reversed gameGrid->attemptJewelExchange( selectedSockets.at(0), selectedSockets.at(1) ); } // Indicate switchback has been completed legalMove = true; // Deselect sockets involved in switch back selectedSockets.clear(); } } else { // If an upClick occurred, check if it was within grid if( upClickOccurred ) { if( gameGrid->withinBound( mUpClickX, mUpClickY ) ) { // Reset the flag for the next upclick upClickOccurred = false; // Execute behaviour for selecting sockets at coordinates moveMade = performSocketSelection( mUpClickX, mUpClickY, gameGrid ); } else { // Clicking outside of the grid is used for deselection selectedSockets.clear(); } } } } // End of gridReady/!gridReady statement } else { // Full game length has elapsed gameOver = true; } } // End of pause/!pause statement // Draw background and game visuals apply_surface( 0, 0, backgroundImage, screen ); drawGrid( gameGrid ); drawHUD( totalTimeElapsed, gameScore ); if( gameOver ) { // Draw score messageString = "Game Over"; } // Refresh message renderCentredText( 410, 55, messageString ); //Update screen if ( SDL_Flip( screen ) == -1 ) { return 1; } } // Free-up surfaces, destroy objects and quit SDL clean_up( gameGrid ); return 0; }