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 endOfGame() { SplashInit(); SplashUpdate("continue"); SplashRender(); IwGxLightingOn(); gameFinalRender(); IwGxFlush(); IwGxSwapBuffers(); while(!s3eDeviceCheckQuitRequest()) { int64 start = s3eTimerGetMs(); while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } if (g_Input.getTouchCount() != 0) { s3eResult g_result = s3eOSExecExecute("http://www.facebook.com/Baconbb10", true); } } }
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 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 N2F::Iw3D::Iw2DHelper::Init() { Iw2DInit(); IwGxInit(); IwGxFontInit(); IwGxLightingOn(); IwGxSetColClear(0, 0, 0, 0xff); return; }
void ciclo() { if (g_Input.getSound()) g_Input.playSong(); while (!s3eDeviceCheckQuitRequest()) { if (g_Input.getLifes()<1) { gameOver(); } if (menuB) break; s3eDeviceBacklightOn(); g_Input.updateSound(); s3eDeviceYield(0); int64 start = s3eTimerGetMs(); bool result = BaconUpdate(); bool result2 = FondoUpdate(); IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); IwGxLightingOff(); FondoRender(); LifeStatusRender(); BaconRender(); insertaObstaculos(); spriteManager->render(); chuletas->render(); tank->render(); IwGxLightingOn(); FontLifeRender(); FontCoinsRender(); IwGxFlush(); IwGxSwapBuffers(); //g_Input.setScore(g_Input.getScore()+1); // Attempt frame rate /*while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); }*/ } }
void CEndGameState::Render() { IW_CALLSTACK("CEndGameState::Render"); IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); GetWorld().Render(); IwGxLightingOff(); IwGxSetScreenSpaceOrg( &CIwSVec2::g_Zero ); CIwColour* cols = IW_GX_ALLOC(CIwColour, 4); memset(cols, 255, sizeof(CIwColour) * 4 ); if (GetWorld().GetUICar()->GetPosition() == 1 ) { CIwMaterial* mat = (CIwMaterial *)IwGetResManager()->GetGroupNamed("ui")->GetResNamed("youwin", IW_GX_RESTYPE_MATERIAL); IwGxSetMaterial(mat); } else { CIwMaterial* mat = (CIwMaterial *)IwGetResManager()->GetGroupNamed("ui")->GetResNamed("youlose", IW_GX_RESTYPE_MATERIAL); IwGxSetMaterial(mat); } const uint32 imageWidth = 128; const uint32 imageHeight = 32; CIwSVec2 XY( (int16)((IwGxGetScreenWidth()/2) - (imageWidth/2)), (int16)(IwGxGetScreenHeight()/4) ), dXY( (int16)imageWidth, (int16)imageHeight ); IwGxDrawRectScreenSpace(&XY, &dXY, cols); IwGxLightingOn(); IwGxFlush(); IwGxSwapBuffers(); #ifdef IW_DEBUG // Reset metrics for next frame IwGxMetricsReset(); #endif }
void gameOver() { initMenu = false; if (g_Input.getSound()) g_Input.stopSong(); SplashInit(); SplashUpdate("go"); SplashRender(); IwGxLightingOn(); gameOverRender(); IwGxFlush(); IwGxSwapBuffers(); while(!s3eDeviceCheckQuitRequest()) { int64 start = s3eTimerGetMs(); while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } if (g_Input.getTouchCount() != 0) { int x = g_Input.getTouch(0)->x; int y = g_Input.getTouch(0)->y; if (x <= 380 && x >= 70 && y <= 730 && y >= 650) { g_Input.setCoins(0); g_Input.setLifes(5); corazon->setX(-400); for (int i=0; i<10; i++) { garras[i]->setX(-400); } maxiCoin->setX(-400); for (int j=0; j<20; j++) { miniCoins[j]->setX(-400); } for (int i=0; i<10; i++) { tnts[i]->setX(-400); } tank->setX(-600); chuletas->setX(-800); g_Input.part =1; g_Input.velAdvance = 10; chuletasStep = 2; tankStep = 2; g_Input.initTimer(); g_Input.setTotalTime(); g_Input.part = 1; g_Input.setVelocity(10000); //SplashShutDown(); //SplashInit(); if (g_Input.getSound()) g_Input.playSong(); SplashShutDown(); break; } else if (x <= 1215 && x >= 650 && y <= 730 && y >= 650) { g_Input.setCoins(0); g_Input.setLifes(5); corazon->setX(-400); for (int i=0; i<10; i++) { garras[i]->setX(-400); } maxiCoin->setX(-400); for (int j=0; j<20; j++) { miniCoins[j]->setX(-400); } for (int i=0; i<10; i++) { tnts[i]->setX(-400); } tank->setX(-600); chuletas->setX(-800); g_Input.part =1; g_Input.velAdvance = 10; chuletasStep = 2; tankStep = 2; g_Input.initTimer(); g_Input.setTotalTime(); g_Input.part = 1; g_Input.setVelocity(10000); //------------------------------------------ //------------------------------------------ /*spriteManager->removeSprite(corazon); delete corazon; for (int i=0; i<15; i++) { spriteManager->removeSprite(garras[i]); delete garras[i]; spriteManager->removeSprite(tnts[i]); delete tnts[i]; } for (int i=0; i<25; i++) { spriteManager->removeSprite(miniCoins[i]); delete miniCoins[i]; } delete tank; spriteManager->removeSprite(maxiCoin); delete maxiCoin; delete chuletas;*/ menuB = true; SplashShutDown(); break; } } } }
void CzPlatformRender::DrawText(CzFontPreparedText prepared_text, CzFont* font, CzMatrix3* transform, const CzColour& colour, CzVec4& skew, bool filter, eCzAlphaMode alpha_mode) { CIwMaterial::AlphaMode am = (CIwMaterial::AlphaMode)alpha_mode; // TODO Add proper method map Marmalade Alpha mode to Marmalade // Cache the transform float m00 = transform->m[0][0]; float m01 = transform->m[0][1]; float m10 = transform->m[1][0]; float m11 = transform->m[1][1]; float tx = transform->getX(); float ty = transform->getY(); float sx1 = (float)skew.x; float sx2 = (float)skew.y; float sy1 = (float)skew.z; float sy2 = (float)skew.w; /* CzIRect clip = ScreenClipRect; clip.x <<= 3; clip.y <<= 3; clip.w = clip.x + (clip.w << 3); clip.h = clip.y + (clip.h << 3);*/ IwGxLightingOn(); IwGxSetColStream(NULL); IwGxSetNormStream(NULL); CIwGxFont* mfont = static_cast<CIwGxFont*>(font->getFontHandle()); CIwGxFontPreparedData* prep_text = static_cast<CIwGxFontPreparedData*>(prepared_text); // A font can consist of multiple materials so we need to process all of them for (int t = 0; t < mfont->GetNumberMaterials(); t++) { // Set UV stream uint32* char_ids; int num_chars = IwGxFontSetUVs(*prep_text, -1, t, &char_ids); // Generate transformed vertices from glyphs int nv = num_chars << 2; CzVec2* pVerts = IW_GX_ALLOC(CzVec2, nv); CzVec2* pVert = pVerts; if (m01 == 0 && m10 == 0) { // No rotation optimisation for (int t2 = 0; t2 < num_chars; t2++) { CIwRect rc = prep_text->GetCharacterArea(char_ids[t2]); float x1 = (float)rc.x; float y1 = (float)rc.y; float x2 = x1 + (float)rc.w; float y2 = y1 + (float)rc.h; float ax = (m00 * x1) + tx; float ay = (m11 * y1) + ty; float bx = (m00 * x2) + tx; float by = (m11 * y2) + ty; // if ((ax < clip.w && bx >= clip.x) && (ay < clip.h && by >= clip.y)) // { pVert->x = ax + sx1; pVert->y = ay + sy1; pVert++; pVert->x = ax - sx1; pVert->y = by + sy2; pVert++; pVert->x = bx - sx2; pVert->y = by - sy2; pVert++; pVert->x = bx + sx2; pVert->y = ay - sy1; pVert++; // } } } else { for (int t2 = 0; t2 < num_chars; t2++) { CIwRect rc = prep_text->GetCharacterArea(char_ids[t2]); float x1 = (float)rc.x; float y1 = (float)rc.y; float x2 = x1 + (float)rc.w; float y2 = y1 + (float)rc.h; pVert->x = (m00 * x1 + m10 * y1 + tx + sx1); pVert->y = (m01 * x1 + m11 * y1 + ty + sy1); pVert++; pVert->x = (m00 * x1 + m10 * y2 + tx - sx1); pVert->y = (m01 * x1 + m11 * y2 + ty + sy2); pVert++; pVert->x = (m00 * x2 + m10 * y2 + tx - sx2); pVert->y = (m01 * x2 + m11 * y2 + ty - sy2); pVert++; pVert->x = (m00 * x2 + m10 * y1 + tx + sx2); pVert->y = (m01 * x2 + m11 * y1 + ty - sy1); pVert++; } } if (nv > 0) { // Set vertex stream IwGxSetVertStreamScreenSpace((CIwFVec2*)pVerts, nv); // Create a material CIwMaterial* mat = IW_GX_ALLOC_MATERIAL(); mat->Copy(*IwGxFontGetFont()->GetMaterial(t)); mat->SetDepthWriteMode(CIwMaterial::DEPTH_WRITE_DISABLED); mat->SetColEmissive(colour.get()); mat->SetClamping(true); mat->SetFiltering(filter); mat->SetAlphaMode(am); mat->SetCullMode(CIwMaterial::CULL_BACK); // mat->SetCullMode(CIwMaterial::CULL_NONE); IwGxSetMaterial(mat); // Finally draw the glyphs IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, nv); CurrentAlphaMode = alpha_mode; } } IwGxLightingOff(); CurrentTexture = NULL; }
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(); }