void EggDropGameEngine::Render(CIwRect& bounds) { CIwSVec2 drawGrass(bounds.x + (bounds.w - g_pGrass->GetWidth()) / 2, bounds.y); Utils::AlphaRenderImage(g_pGrass, drawGrass, 0xff); if (g_bBroken) { if (g_iCrackIter < 40) { int yOffset = (g_pSpoon->GetHeight() - g_pEgg->GetHeight()) * g_iCrackIter / 40.0; CIwRect bounds2(bounds.x + (bounds.w - g_pEgg->GetWidth()) / 2, bounds.y + yOffset, g_pEgg->GetWidth(), g_pEgg->GetHeight()); double fallRot = fallingRot + (g_iCrackIter * 2 / 40.0); Utils::AlphaRenderAndRotateImage(g_pEgg, bounds2, 0xff, fallRot); g_iCrackIter++; } else { CIwSVec2 draw(bounds.x + (bounds.w - g_pCrackedEgg->GetWidth()) / 2, bounds.y + (bounds.h - g_pCrackedEgg->GetHeight())); Utils::AlphaRenderImage(g_pCrackedEgg, draw, 0xff); } } else { CIwSVec2 draw(bounds.x + (bounds.w - g_pSpoon->GetWidth()) / 2, bounds.y); Utils::AlphaRenderImage(g_pSpoon, draw, 0xff); IwGxFlush(); CIwRect bounds2(bounds.x + (bounds.w - g_pEgg->GetWidth()) / 2, bounds.y, g_pEgg->GetWidth(), g_pEgg->GetHeight()); Utils::AlphaRenderAndRotateImage(g_pEgg, bounds2, 0xff, rot); } }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // „Ƕ„Ç£„É≥„Éâ„Ƕ„ÅÆËÉåÊôØ„Çí°ó„Çä„ŧ„Å∂„Å? & Èö†Èù¢Âá¶ÁêÅEÇíÂèØËÉΩ„Å´„Åô„Çã glEnable(GL_DEPTH_TEST); // Èö†Èù¢Âá¶ÁêÅEñãÂß? glEnable(GL_NORMALIZE); glEnable(GL_LIGHTING); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glPushMatrix(); glTranslatef(0.0, 1.0, 0.0); polarview(); // „Éù„ÅE„É©„ɺ„Éì„É•„ɺ„Å∏„ÅÆ„Éì„É•„ɺ„ǧ„É≥„Ç∞§âÊèõ glPushMatrix(); glLightfv(GL_LIGHT0, GL_POSITION, light0); glPopMatrix(); shading(5); drawGround2D(); shading(6); glDisable(GL_LIGHTING); drawGrass(); glEnable(GL_LIGHTING); shading(5); drawPlant(); if (rainFlag == GL_TRUE) drawRain(); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); drawCloud(); if (thunderFlag == GL_TRUE && rainFlag == GL_TRUE) { if (lightningnum == 0 || lightningnum == 4) lightning(); lightningnum++; if (lightningnum == 5) { lightningnum = 0; thunderFlag = GL_FALSE; } if (rand() % 10 == 4) fallFlag = GL_TRUE; } else thunderFlag = GL_FALSE; glPopMatrix(); glutSwapBuffers(); }
void gameloop(int randTiles[]) { float frame = 0.0; int dir = 0; //game_input->clearKeys(); while (gameIsRunning) { game_timer.start(); /** game_input->readInput(); if (game_input->windowClosed()) { gameIsRunning = false; } **/ while( SDL_PollEvent( &game_event ) ) { //Handle events for the dot handleKeyboardInput(); //If the user has Xed out the window if( game_event.type == SDL_QUIT ) { //Quit the program gameIsRunning = false; } } p1.moveChar(); dir = p1.getDir() * 32; if (p1.isWalk()) { frame += 0.05; if (frame > 3.0) { frame = 0.0; } } else { frame = 0.0; } game_graphics->beginScene(); drawGrass(randTiles); drawOverlay(); game_graphics->drawSprite(p1.playerBMP, (int)frame * 32, dir, p1.getX(), p1.getY(), 32, 32); //showXY(); game_graphics->drawSprite(sepBar, 0, 0, 640, 0, 7, 480); drawStats(); game_graphics->endScene(); if (inMenu) { gameMenu->displayMenu(); } //Cap the frame rate if( game_timer.get_ticks() < 1000 / FRAMES_PER_SECOND ) { SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - game_timer.get_ticks() ); } } }
void drawScene(void) { mvstack.push(model_view); drawHcube(); drawLoveHeart(); model_view = mvstack.pop(); // Draw Ground mvstack.push(model_view); set_colour(0.5,1,0.5); model_view *= Translate(0.0f, -4.75f, 0.0f); model_view *= Scale(100.0f, 1.0f, 100.0f); drawCube(); model_view = mvstack.pop(); //Draw Tree mvstack.push(model_view); model_view *= Translate(5.0f, -4.75f, -5.0f); drawPineTree(); model_view = mvstack.pop(); // Draw Grass mvstack.push(model_view); model_view *= Translate(10.0f, -4.0f, 0.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(12.0f, -4.0f, 3.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(-11.0f, -4.0f, 4.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(-9.0f, -4.0f, -2.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(-4.0f, -4.0f, 5.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(-3.0f, -4.0f, 9.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(-5.0f, -4.0f, -15.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(6.0f, -4.0f, -14.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(7.0f, -4.0f, -25.0f); drawGrass(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(-8.0f, -4.0f, -18.0f); drawGrass(); model_view = mvstack.pop(); // Draw Walls mvstack.push(model_view); set_colour(0.9,0.9,1); mvstack.push(model_view); model_view *= RotateX(90); model_view *= RotateY(90); model_view *= Translate(20.0f, -50.0f, 0.0f); model_view *= Scale(50.0f, 1.0f, 100.0f); drawWall(); model_view *= Translate(0.0f, 100.0f, 0.0f); drawWall(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= Translate(50.0f, 20.0f, 0.0f); model_view *= Scale(1.0f, 50.0f, 100.0f); drawWall(); model_view *= Translate(-100.0f, 0.0f, 0.0f); drawWall(); model_view = mvstack.pop(); model_view = mvstack.pop(); // Draw Bench mvstack.push(model_view); model_view *= Translate(0.0f, -2.0f, 0.0f); drawBench(); model_view = mvstack.pop(); }