void PatteRunGameEngine::RenderStatus(CIwUIRect& bounds) { IwGxLightingOn(); IwGxFontSetFont(g_pFont); IwGxFontSetCol(0xffffffff); IwGxFontSetAlignmentVer(IW_GX_FONT_ALIGN_MIDDLE); IwGxFontSetAlignmentHor(IW_GX_FONT_ALIGN_LEFT); CIwRect rect((int16)(bounds.x+5), (int16)bounds.y, (int16)(bounds.w-5), (int16)bounds.h); IwGxFontSetRect(rect); sprintf(g_szStatus, "%06d", g_iDisplayedScore); IwGxFontDrawText(g_szStatus); IwGxFontSetAlignmentHor(IW_GX_FONT_ALIGN_RIGHT); IwGxFontSetFont(g_pFontSmall); rect.w = 80; rect.x = bounds.w - 85; IwGxFontSetRect(rect); sprintf(g_szStatus, "%02d | %02d", g_iGameCounter, g_iLevel+1); IwGxFontDrawText(g_szStatus); IwGxLightingOff(); CIwSVec2 locFly(bounds.w - 85, (bounds.h - g_pTile->GetWidth()) / 2); Utils::AlphaRenderImage(g_pTile, locFly, 255); }
void CRenderer::RenderText( CIwGxFont * font, const CIwRect & rect, const CIwColour & color, const CIwStringS & txt, IwGxFontAlignHor hAlign, IwGxFontAlignVer vAlign ) { iwsfixed scale = IW_SFIXED(mDeviceParams.scale); iwsfixed offX = mDeviceParams.offsetX; iwsfixed offY = mDeviceParams.offsetY; CIwRect r; r.x = IW_FIXED_MUL(rect.x, scale) + offX; r.y = IW_FIXED_MUL(rect.y, scale) + offY; r.w = IW_FIXED_MUL(rect.w, scale); r.h = IW_FIXED_MUL(rect.h, scale); Flush(); DefaultMaterial(); IwGxFontClearFlags(0xffffffff); IwGxLightingOn(); IwGxFontSetFont( font ); IwGxFontSetCol( color ); //IwGxFontSetScale( scale ); //Set the formatting rect - this controls where the text appears and what it is formatted against IwGxFontSetRect(r); IwGxFontSetAlignmentVer(vAlign); IwGxFontSetAlignmentHor(hAlign); //Draw the text IwGxFontDrawText(txt.c_str()); IwGxLightingOff(); IwGxFontFreeBuffers(); Flush(); }
void PatteRunGameEngine::Render2D() { std::list<CGridTile*>::iterator iter = g_pTiles.begin(); while (iter != g_pTiles.end()) { (*iter)->Render(); iter++; } Iw2DFinishDrawing(); if (g_iCounter < g_iLevel) { } else { g_pUser->Render(); if (g_bDisplayCorrect) { IwGxLightingOn(); IwGxFontSetFont(g_pFontHuge); IwGxFontSetCol(0xffffffff); IwGxFontSetAlignmentVer(IW_GX_FONT_ALIGN_MIDDLE); IwGxFontSetAlignmentHor(IW_GX_FONT_ALIGN_CENTRE); CIwRect rect(0, 0, Iw2DGetSurfaceWidth(), Iw2DGetSurfaceHeight()); IwGxFontSetRect(rect); strcpy(g_szStatus, "CORRECT!"); IwGxFontDrawText(g_szStatus); } } }
void PatteRunGameEngine::RenderPause() { int width = Iw2DGetSurfaceWidth(); int height = Iw2DGetSurfaceHeight(); int iconWidth = 40; int iconHeight = 40; CIwRect bounds(15, height - 170, width - 30, iconHeight); IwGxLightingOn(); IwGxFontSetFont(g_pFont); IwGxFontSetCol(0xffffffff); CIwRect rect(0, 0, width, bounds.y); IwGxFontSetRect(rect); IwGxFontAlignHor alignH = IwGxFontGetAlignmentHor(); IwGxFontAlignVer alignV = IwGxFontGetAlignmentVer(); IwGxFontSetAlignmentVer(IW_GX_FONT_ALIGN_MIDDLE); IwGxFontSetAlignmentHor(IW_GX_FONT_ALIGN_CENTRE); IwGxFontDrawText("Tap the screen to resume..."); /* CIwTexture* pCurrLevel = g_pTextureLevel1; switch (g_iLevel) { case 0 : { pCurrLevel = g_pTextureLevel1; } break; case 1 : { pCurrLevel = g_pTextureLevel2; } break; case 2 : { pCurrLevel = g_pTextureLevel3; } break; case 3 : { pCurrLevel = g_pTextureLevel4; } break; } int totalWidth = g_pTextureLevel->GetWidth() + pCurrLevel->GetWidth() + 10; int totalHeight = g_pTextureLevel->GetHeight(); CIwSVec2 locLevel((width - totalWidth) / 2, rect.h - totalHeight); Utils::AlphaRenderImage(g_pTextureLevel, locLevel, 255); locLevel.x += (int16)(g_pTextureLevel->GetWidth() + 10); Utils::AlphaRenderImage(pCurrLevel, locLevel, 255); Iw2DSetAlphaMode(IW_2D_ALPHA_HALF); Iw2DFillRect(CIwSVec2(10, height - 170), CIwSVec2(width - 20, 160)); Iw2DSetAlphaMode(IW_2D_ALPHA_NONE); IwGxFontSetAlignmentVer(IW_GX_FONT_ALIGN_MIDDLE); IwGxFontSetAlignmentHor(IW_GX_FONT_ALIGN_LEFT); IwGxFontSetFont(g_pFontSmall); CIwRect fontBounds(15 + iconWidth + 10, height - 170, width - 40 - iconWidth, iconHeight); CIwSVec2 loc1(bounds.x + (iconWidth - g_pTextureFirefly->GetWidth()) / 2, bounds.y + (iconHeight - g_pTextureFirefly->GetHeight()) / 2); Utils::AlphaRenderImage(g_pTextureFirefly, loc1, 255); IwGxFontSetRect(fontBounds); IwGxFontDrawText("Capture firelfies to gain points"); bounds.y += 40; fontBounds.y += 40; CIwSVec2 loc2(bounds.x + (iconWidth - g_pTextureDragon->GetWidth()) / 2, bounds.y + (iconHeight - g_pTextureDragon->GetHeight()) / 2); Utils::AlphaRenderImage(g_pTextureDragon, loc2, 255); IwGxFontSetRect(fontBounds); IwGxFontDrawText("Dragonflies capture fireflies"); bounds.y += 40; fontBounds.y += 40; CIwSVec2 loc3(bounds.x + (iconWidth - g_pTextureMine->GetWidth()) / 2, bounds.y + (iconHeight - g_pTextureMine->GetHeight()) / 2); Utils::AlphaRenderImage(g_pTextureMine, loc3, 255); IwGxFontSetRect(fontBounds); IwGxFontDrawText("Mines take away your points"); bounds.y += 40; fontBounds.y += 40; CIwSVec2 loc4(bounds.x + (iconWidth - g_pTextureBolt->GetWidth()) / 2, bounds.y + (iconHeight - g_pTextureBolt->GetHeight()) / 2); Utils::AlphaRenderImage(g_pTextureBolt, loc4, 255); IwGxFontSetRect(fontBounds); IwGxFontDrawText("Shake your phone to stun fireflies"); */ IwGxLightingOff(); }
void MenuScreen::Render() { sprite.Render(); if( type == MENU ) { for( int i = 0; i < buttonCount; i++ ) { switch( i ) { case 0: //button[i].setLocation( sprite.position.x - 75, sprite.position.y + 122 ); button[i].setLocation( sprite.position.x, sprite.position.y); // The sprite is the center of the image break; case 1: //button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .031, sprite.position.y + IwGxGetScreenHeight() * .381 ); button[i].setLocation( sprite.position.x, sprite.position.y + IwGxGetScreenHeight() * .381 ); break; } button[i].Render(); } } else if( type == CHALLENGE ) { int row = 1; int column = 1; for( int i = 0; i < buttonCount; i++ ) { button[i].setLocation( (column*buttonSprite[i].size.x + 30*(column) + 35) + (sprite.position.x - IwGxGetScreenWidth()/2), (row*buttonSprite[i].size.y + 15*(row) + 5) + (sprite.position.y - IwGxGetScreenHeight()/2) ); button[i].Render(); // increment the rows/columns column++; if( column >= 6 ) { column = 1; row++; } } } else if( type == HIGH_SCORE ) { if( s3eDeviceGetInt( S3E_DEVICE_OS ) == S3E_OS_ID_IPHONE ) { for( int i = 0; i < buttonCount; i++ ) { switch( i ) { case 0: //button[i].setLocation( sprite.position.x - 75, sprite.position.y + 122 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .156, sprite.position.y + IwGxGetScreenHeight() * .381 ); button[i].Render(); break; case 1: //button[i].setLocation( sprite.position.x + 97, sprite.position.y + 122 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .202, sprite.position.y + IwGxGetScreenHeight() * .381); button[i].Render(); break; case 2: // render black trophies //button[i].setLocation( sprite.position.x - 190, sprite.position.y - 75 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .396, sprite.position.y - IwGxGetScreenHeight() * .234); if( trophies[0] == false ) { button[i].Render(); } break; case 3: //button[i].setLocation( sprite.position.x + 183, sprite.position.y - 80 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .381, sprite.position.y - IwGxGetScreenHeight() * .25 ); if( trophies[1] == false ) { button[i].Render(); } break; case 4: //button[i].setLocation( sprite.position.x - 190, sprite.position.y + 50 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .396, sprite.position.y + IwGxGetScreenHeight() * .156); if( trophies[2] == false ) { button[i].Render(); } break; case 5: //button[i].setLocation( sprite.position.x + 12, sprite.position.y + 63 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .025, sprite.position.y + IwGxGetScreenHeight() * .197); if( trophies[3] == false ) { button[i].Render(); } break; case 6: //button[i].setLocation( sprite.position.x + 187, sprite.position.y + 45 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .390, sprite.position.y + IwGxGetScreenHeight() * .141); if( trophies[4] == false ) { button[i].Render(); } break; case 7: //button[i].setLocation( sprite.position.x - 190, sprite.position.y - 75 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .396, sprite.position.y - IwGxGetScreenHeight() * .234); if( trophies[0] == true ) { button[i].Render(); } break; case 8: //button[i].setLocation( sprite.position.x + 183, sprite.position.y - 80 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .381, sprite.position.y - IwGxGetScreenHeight() * .25); if( trophies[1] == true ) { button[i].Render(); } break; case 9: //button[i].setLocation( sprite.position.x - 190, sprite.position.y + 50 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .396, sprite.position.y + IwGxGetScreenHeight() * .156); if( trophies[2] == true ) { button[i].Render(); } break; case 10: //button[i].setLocation( sprite.position.x + 12, sprite.position.y + 63 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .025, sprite.position.y + IwGxGetScreenHeight() * .197); if( trophies[3] == true ) { button[i].Render(); } break; case 11: //button[i].setLocation( sprite.position.x + 187, sprite.position.y + 45 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .390, sprite.position.y + IwGxGetScreenHeight() * .141); if( trophies[4] == true ) { button[i].Render(); } break; case 12: //button[i].setLocation( sprite.position.x + 187, sprite.position.y + 45 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * 0, sprite.position.y + IwGxGetScreenHeight() * .381); button[i].Render(); break; } } } // end of if OS is iphone, and rendering trophies else // if OS is NOT iphone, do not render rate trophy, or rate button. In fact, just move them off the screen. { for( int i = 0; i < buttonCount; i++ ) { switch( i ) { case 0: // RATE BUTTON OFFSET OFF SCREEN //button[i].setLocation( sprite.position.x - 75, sprite.position.y + 122 ); //button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .156, sprite.position.y + IwGxGetScreenHeight() * .381 ); button[i].setLocation( -IwGxGetScreenWidth() * 2, IwGxGetScreenHeight() ); button[i].Render(); break; case 1: // BACK button //button[i].setLocation( sprite.position.x + 97, sprite.position.y + 122 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .202, sprite.position.y + IwGxGetScreenHeight() * .381); button[i].Render(); break; case 2: // render black trophies //button[i].setLocation( sprite.position.x - 190, sprite.position.y - 75 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .396, sprite.position.y - IwGxGetScreenHeight() * .234); if( trophies[0] == false ) { button[i].Render(); } break; case 3: //button[i].setLocation( sprite.position.x + 183, sprite.position.y - 80 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .381, sprite.position.y - IwGxGetScreenHeight() * .25 ); if( trophies[1] == false ) { button[i].Render(); } break; case 4: // Fuzzy Reviewer Trophy OFFSET OFF SCREEN //button[i].setLocation( sprite.position.x - 190, sprite.position.y + 50 ); //button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .396, sprite.position.y + IwGxGetScreenHeight() * .156); button[i].setLocation( -IwGxGetScreenWidth() * 2, IwGxGetScreenHeight() ); if( trophies[2] == false ) { button[i].Render(); } break; case 5: // Fuzzy 1 mill points shifted to reviewer spot //button[i].setLocation( sprite.position.x + 12, sprite.position.y + 63 ); //button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .025, sprite.position.y + IwGxGetScreenHeight() * .197); button[i].setLocation( sprite.position.x - 190, sprite.position.y + 50 ); if( trophies[3] == false ) { button[i].Render(); } break; case 6: //button[i].setLocation( sprite.position.x + 187, sprite.position.y + 45 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .390, sprite.position.y + IwGxGetScreenHeight() * .141); if( trophies[4] == false ) { button[i].Render(); } break; case 7: //button[i].setLocation( sprite.position.x - 190, sprite.position.y - 75 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .396, sprite.position.y - IwGxGetScreenHeight() * .234); if( trophies[0] == true ) { button[i].Render(); } break; case 8: //button[i].setLocation( sprite.position.x + 183, sprite.position.y - 80 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .381, sprite.position.y - IwGxGetScreenHeight() * .25); if( trophies[1] == true ) { button[i].Render(); } break; case 9: // Fuzzy Reviewer Trophy OFFSET OFF SCREEN //button[i].setLocation( sprite.position.x - 190, sprite.position.y + 50 ); //button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .396, sprite.position.y + IwGxGetScreenHeight() * .156); button[i].setLocation( -IwGxGetScreenWidth() * 2, IwGxGetScreenHeight() ); if( trophies[2] == true ) { button[i].Render(); } break; case 10: // Fuzzy 1 mill points shifted to reviewer spot //button[i].setLocation( sprite.position.x + 12, sprite.position.y + 63 ); //button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .025, sprite.position.y + IwGxGetScreenHeight() * .197); button[i].setLocation( sprite.position.x - 190, sprite.position.y + 50 ); if( trophies[3] == true ) { button[i].Render(); } break; case 11: //button[i].setLocation( sprite.position.x + 187, sprite.position.y + 45 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .390, sprite.position.y + IwGxGetScreenHeight() * .141); if( trophies[4] == true ) { button[i].Render(); } break; case 12: //button[i].setLocation( sprite.position.x + 187, sprite.position.y + 45 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * 0, sprite.position.y + IwGxGetScreenHeight()*.381); button[i].Render(); break; } } } // end of rendering non-iOS versions for trophies and buttons // need to render the current images because fonts are automatically displayed underneath them. IwGxFlush(); // the high score CIwGxFontPreparedData scoreData; char scoreChar[100] = ""; std::ostringstream scoreStringStream; scoreStringStream << highScore; string scoreString = scoreStringStream.str(); strcat( scoreChar, scoreString.c_str() ); // draw the shadow //IwGxFontSetCol(0xffaaffff); IwGxFontSetCol(0xff330000); //IwGxFontSetRect( CIwRect( sprite.position.x - (scoreString.length()/2 * 10), sprite.position.y - 100, 500, 300 ) ); // major glitch here. the size of score affects size of time. vice versa IwGxFontSetRect( CIwRect( sprite.position.x - (scoreString.length()/2 * 10), sprite.position.y - IwGxGetScreenHeight() * .312, 500, 300 ) ); // major glitch here. the size of score affects size of time. vice versa IwGxFontPrepareText( scoreData, scoreChar ); IwGxFontDrawText( scoreData ); // draw the text IwGxFontSetCol(0xff66ffff); //IwGxFontSetRect( CIwRect( sprite.position.x - (scoreString.length()/2 * 10) - 1, sprite.position.y - 100 - 2, 500, 300 ) ); // major glitch here. the size of score affects size of time. vice versa IwGxFontSetRect( CIwRect( sprite.position.x - (scoreString.length()/2 * 10) - IwGxGetScreenWidth()*.002, sprite.position.y - IwGxGetScreenHeight() * .319, 500, 300 ) ); // major glitch here. the size of score affects size of time. vice versa IwGxFontPrepareText( scoreData, scoreChar ); IwGxFontDrawText( scoreData ); // the time played // the high score CIwGxFontPreparedData timeData; char timeChar[100] = ""; std::ostringstream timeStringStream; timeStringStream << timeHours << " hours " << timeMinutes << " minutes " << timeSeconds << " seconds"; string timeString = timeStringStream.str(); strcat( timeChar, timeString.c_str() ); // draw the shadow //IwGxFontSetCol(0xffaaffff); IwGxFontSetCol(0xff330000); //IwGxFontSetRect( CIwRect( sprite.position.x - (timeString.length()/2 * 10), sprite.position.y - 15, 400, 300 ) ); if( IwGxGetScreenHeight() >= 640 ) { IwGxFontSetRect( CIwRect( sprite.position.x - (timeString.length()/2 * 20), sprite.position.y - IwGxGetScreenHeight() * .047, IwGxGetScreenWidth(), IwGxGetScreenHeight() ) ); } else if( IwGxGetScreenHeight() >= 480 ) { IwGxFontSetRect( CIwRect( sprite.position.x - (timeString.length()/2 * 15), sprite.position.y - IwGxGetScreenHeight() * .047, IwGxGetScreenWidth(), IwGxGetScreenHeight() ) ); } else //if( IwGxGetScreenHeight() >= 320 ) { IwGxFontSetRect( CIwRect( sprite.position.x - (timeString.length()/2 * 10), sprite.position.y - IwGxGetScreenHeight() * .047, IwGxGetScreenWidth(), IwGxGetScreenHeight() ) ); } IwGxFontPrepareText( timeData, timeChar ); IwGxFontDrawText( timeData ); // draw the text IwGxFontSetCol(0xff66ffff); //IwGxFontSetRect( CIwRect( sprite.position.x - (timeString.length()/2 * 10) - 1, sprite.position.y - 15 - 2, 400, 300 ) ); if( IwGxGetScreenHeight() >= 640 ) { IwGxFontSetRect( CIwRect( sprite.position.x - (timeString.length()/2 * 20) - IwGxGetScreenWidth()*.002, sprite.position.y - IwGxGetScreenHeight() * .053, IwGxGetScreenWidth(), IwGxGetScreenHeight() ) ); } else if( IwGxGetScreenHeight() >= 480 ) { IwGxFontSetRect( CIwRect( sprite.position.x - (timeString.length()/2 * 15) - IwGxGetScreenWidth()*.002, sprite.position.y - IwGxGetScreenHeight() * .053, IwGxGetScreenWidth(), IwGxGetScreenHeight() ) ); } else //if( IwGxGetScreenHeight() >= 320 ) { IwGxFontSetRect( CIwRect( sprite.position.x - (timeString.length()/2 * 10) - IwGxGetScreenWidth()*.002, sprite.position.y - IwGxGetScreenHeight() * .053, IwGxGetScreenWidth(), IwGxGetScreenHeight() ) ); } IwGxFontPrepareText( timeData, timeChar ); IwGxFontDrawText( timeData ); } else if( type == CREDITS ) { for( int i = 0; i < buttonCount; i++ ) { switch( i ) { case 0: //button[i].setLocation( sprite.position.x - 75, sprite.position.y + 122 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .156, sprite.position.y + IwGxGetScreenHeight() * .381 ); break; case 1: //button[i].setLocation( sprite.position.x + 15, sprite.position.y + 122 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .031, sprite.position.y + IwGxGetScreenHeight() * .381 ); button[i].Render(); // only render back button break; } } } else if( type == TUTORIAL ) { for( int i = 0; i < buttonCount; i++ ) { switch( i ) { case 0: // the back button //button[i].setLocation( sprite.position.x + 180, sprite.position.y + 122 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .375, sprite.position.y + IwGxGetScreenHeight() * .381); break; case 1: //button[i].setLocation( sprite.position.x - 60, sprite.position.y + 125 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .125, sprite.position.y + IwGxGetScreenHeight() * .390 ); break; case 2: //button[i].setLocation( sprite.position.x + 0, sprite.position.y + 125 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * 0, sprite.position.y + IwGxGetScreenHeight() * .390); break; case 3: //button[i].setLocation( sprite.position.x + 60, sprite.position.y + 125 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .125, sprite.position.y + IwGxGetScreenHeight() * .390); break; } button[i].Render(); } } else if( type == QUIT_CONFIRMATION ) { for( int i = 0; i < buttonCount; i++ ) { switch( i ) { case 0: // the back button //button[i].setLocation( sprite.position.x - 60, sprite.position.y + 45 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .125, sprite.position.y + IwGxGetScreenHeight() * .140 ); break; case 1: //button[i].setLocation( sprite.position.x + 60, sprite.position.y + 45 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .125, sprite.position.y + IwGxGetScreenHeight() * .140 ); break; } button[i].Render(); } } else if( type == NEW_STORY_CONFIRMATION ) { for( int i = 0; i < buttonCount; i++ ) { switch( i ) { case 0: // the back button //button[i].setLocation( sprite.position.x - 60, sprite.position.y + 50 ); button[i].setLocation( sprite.position.x - IwGxGetScreenWidth() * .125, sprite.position.y + IwGxGetScreenHeight() * .156 ); break; case 1: //button[i].setLocation( sprite.position.x + 60, sprite.position.y + 50 ); button[i].setLocation( sprite.position.x + IwGxGetScreenWidth() * .125, sprite.position.y + IwGxGetScreenHeight() * .156 ); break; } button[i].Render(); } } }