void CScores::Render() { if (m_loaded) { Iw2DSetColour(0xffffffff); int32 dw = Iw2DGetSurfaceWidth(); int32 dh = Iw2DGetSurfaceHeight(); Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2((int16)dw, (int16)dh)); for (uint32 i = 0; i < m_guicontrols.size(); i++) m_guicontrols[i]->Render(); if (m_closing) { int32 clr = 255 * (MAX_CLOSETIME - m_closetime) / MAX_CLOSETIME; clr = clr << 24; //clr += 0xffffff; Iw2DSetColour(clr); Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2((int16)dw, (int16)dh)); } if (m_showing) { int32 clr = 255 * (m_showtime) / MAX_SHOWTIME; clr = clr << 24; // clr += 0xffffff; Iw2DSetColour(clr); Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2((int16)dw, (int16)dh)); } } }
void TextSprite::RenderImage(uint32 gameTime) { if(textColorSource != null) textColor = textColorSource->GetColor(gameTime); if(borderColorSource != null) borderColor = borderColorSource->GetColor(gameTime); if(backgroundColorSource != null) backgroundColor = backgroundColorSource->GetColor(gameTime); if(marginXSource != null) margin = SCREEN_TO_SUBPIXEL(CIwVec2(marginXSource->GetInt(gameTime), marginYSource->GetInt(gameTime))); if(paddingXSource != null) padding = SCREEN_TO_SUBPIXEL(CIwVec2(paddingXSource->GetInt(gameTime), paddingYSource->GetInt(gameTime))); if(borderXSource != null) borderThickness = SCREEN_TO_SUBPIXEL(CIwVec2(borderXSource->GetInt(gameTime), borderYSource->GetInt(gameTime))); if(marginXSource != null || paddingXSource != null || borderXSource != null) { UpdatePositionData(); } CIw2DFont *prevFont = null; CIwColour prevColor = Iw2DGetColour(); if(textFont != null) { prevFont = Iw2DGetFont(); Iw2DSetFont(textFont); } if(backgroundColor.a > 0) { Iw2DSetColour(backgroundColor); Iw2DFillRect(CIwSVec2(backgroundPosition), CIwSVec2(backgroundSize)); } if(borderColor.a > 0) { Iw2DSetColour(borderColor); Iw2DFillRect(CIwSVec2(borderPosition), CIwSVec2(borderSize)); Iw2DSetColour(backgroundColor); Iw2DFillRect(CIwSVec2(innerBorderPosition), CIwSVec2(innerBorderSize)); } Iw2DSetColour(textColor); const char *textPtr = text.c_str(); Iw2DDrawString(textPtr, CIwSVec2(textPosition), CIwSVec2(textSize), horizontalAlignment, IW_2D_FONT_ALIGN_TOP); Iw2DSetColour(prevColor); if(prevFont != null) { Iw2DSetFont(prevFont); } }
void Button::Render() { if(btn_type==IMAGE) Iw2DDrawImage(_image, m_ImgPos); else { Iw2DSetColour(bg_color); if(btn_type==RECT||btn_type==TEXT) Iw2DFillRect(m_BGPos,m_BGSize); else if(btn_type==SPHERE) Iw2DFillArc(m_BGPos+CIwSVec2(m_BGSize.x/2,m_BGSize.y/2), m_BGSize, iwangle(0), iwangle(0x1600), 40); if(btn_type==TEXT) { uint8 rgb[4]; rgb[0]=(text_color & 0x000000ff);//A rgb[1]=(text_color & 0x0000ff00) >>8;//B rgb[2]=(text_color & 0x00ff0000) >>16;//G rgb[3]=(text_color & 0xff000000) >>24;//R IwGxPrintSetColour(rgb[3], rgb[2], rgb[1]); IwGxPrintSetScale(2); IwGxPrintString(m_TextPos.x, m_TextPos.y, m_text); } Iw2DSetColour(C_WHITE); }
void DrawGameOverScreen() { int border = 10; CIwFVec2 dialogDim(480.f, 120.f); CIwFVec2 outerTopLeft((screen.x - dialogDim.x)/2, (screen.y - dialogDim.y)/2); CIwFVec2 innerTopLeft((screen.x - dialogDim.x)/2 + border, (screen.y - dialogDim.y)/2 + border); Iw2DSetColour(0xffffffff); Iw2DFillRect(outerTopLeft, dialogDim); Iw2DSetColour(0xff000000); Iw2DFillRect(innerTopLeft, CIwFVec2(dialogDim.x - 2 * border, dialogDim.y - 2 * border)); Iw2DSetColour(0xffffffff); Iw2DSetFont(fontLarge); Iw2DDrawString("G A M E O V E R", outerTopLeft, dialogDim, IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE); }
void DrawGround() { for (int i = 0; i < NUM_BUILDINGS; i++) { Iw2DSetColour(0xff000000); Iw2DFillRect(CIwFVec2(GAME_WIDTH - buildings_pos[i].x, GAME_HEIGHT - buildings_pos[i].y), CIwFVec2(buildings_dim[i].x, buildings_dim[i].y)); Iw2DSetColour(0xffffffff); Iw2DDrawRect(CIwFVec2(GAME_WIDTH - buildings_pos[i].x, GAME_HEIGHT - buildings_pos[i].y), CIwFVec2(buildings_dim[i].x, buildings_dim[i].y)); } }
void DrawTitleScreen(TitleScreen *title) { int border = 10; Iw2DSetColour(0xffffffff); Iw2DFillRect(title->btnTopLeft, title->btnDim); Iw2DSetColour(0xff000000); Iw2DFillRect(CIwFVec2(title->btnTopLeft.x + border, title->btnTopLeft.y + border), CIwFVec2(title->btnDim.x - 2 * border, title->btnDim.y - 2 * border)); Iw2DSetFont(fontLarge); int fh = fontLarge->GetHeight(); int sw = Iw2DGetStringWidth("P L A Y"); Iw2DSetColour(0xffffffff); Iw2DDrawString("P L A Y", CIwFVec2(title->btnTopLeft.x + border, title->btnTopLeft.y + border), CIwFVec2(title->btnDim.x - 2 * border, title->btnDim.y - 2 * border), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_TOP); Iw2DDrawString("Patriot Missile Defense", CIwFVec2(0.f, 0.f), CIwFVec2(screen.x, screen.y / 2), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE); }
void Character::Render(CIwFVec2 mapPos) { //character Iw2DDrawImage(_image, CIwSVec2(iwsfixed(m_ScreenCenter.x-_Size.x/2.0f), iwsfixed(m_ScreenCenter.y-_Size.y/2.0f-_Size.y/4.0f))); //target Iw2DSetColour(C_GREEN); Iw2DFillRect(CIwSVec2(iwsfixed(m_TargetOnScreen.x),iwsfixed(m_TargetOnScreen.y)) - CIwSVec2(2,2), CIwSVec2(4,4)); //character collision box //Iw2DSetColour(C_BLACK); //Iw2DDrawRect(CIwSVec2(iwsfixed(m_Position.x-mapPos.x), iwsfixed(m_Position.y-mapPos.y)) - m_CollisionBox/IW_FIXED(2), m_CollisionBox); Iw2DSetColour(C_WHITE); }
void Scene::drawBackgroundBox(int x, int y, int width, int height){ //Most awful method in whole game :D //Draws many rectangles, each of them is smaller than previous, that is how frame is faked. int cyanWidth = 5; int orangeWidth = 8; int borderWidth = 2; int offsetCord = cyanWidth + borderWidth*2 + orangeWidth; int offsetSize = cyanWidth*2 + borderWidth*4 + orangeWidth*2; Iw2DSetColour(g_ColorManager.getBorderColor()); //border Iw2DFillRect(CIwSVec2(x - offsetCord, y - offsetCord), CIwSVec2(width + offsetSize, height + offsetSize)); offsetCord-=borderWidth; offsetSize-=borderWidth*2; Iw2DSetColour(g_ColorManager.getOrangeColor()); //orange Iw2DFillRect(CIwSVec2(x - offsetCord, y - offsetCord), CIwSVec2(width + offsetSize, height + offsetSize)); offsetCord-=orangeWidth; offsetSize-=orangeWidth*2; Iw2DSetColour(g_ColorManager.getBorderColor()); //border Iw2DFillRect(CIwSVec2(x - cyanWidth - borderWidth, y - cyanWidth - borderWidth), CIwSVec2(width + cyanWidth*2 + borderWidth*2, height + cyanWidth*2 + borderWidth*2)); offsetCord-=borderWidth; offsetSize-=borderWidth*2; Iw2DSetColour(g_ColorManager.getCyanColor()); //cyan Iw2DFillRect(CIwSVec2(x - cyanWidth, y - cyanWidth), CIwSVec2(width + cyanWidth*2, height + cyanWidth*2)); offsetCord-=cyanWidth; offsetSize-=cyanWidth*2; Iw2DSetColour(g_ColorManager.getGeneralBackgroundColor()); Iw2DFillRect(CIwSVec2(x, y), CIwSVec2(width, height)); }
void CGame::Render() { if (m_loaded) { int16 dw = (int16)Iw2DGetSurfaceWidth(); int16 dh = (int16)Iw2DGetSurfaceHeight(); Iw2DSetColour(0xff000000); Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2(dw, dh)); Iw2DSetColour(0xffffffff); for (uint32 i = 0; i < m_guicontrols.size(); i++) m_guicontrols[i]->Render(); if (m_lvlFinishDialog->Get_Visible()) m_lvlFinishDialog->Render(); if (m_keyboard->GetVisible()) m_keyboard->Render(); if (m_closing) { int32 clr = 255 * (MAX_CLOSETIME - m_closetime) / MAX_CLOSETIME; clr = clr << 24; //clr += 0xffffff; Iw2DSetColour(clr); Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2(dw, dh)); } if (m_showing) { int32 clr = 255 * (m_showtime) / MAX_SHOWTIME; clr = clr << 24; // clr += 0xffffff; Iw2DSetColour(clr); Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2((int16)dw, (int16)dh)); } } }
void CGame::Render() { // game render goes here // for example, clear to black (the order of components is ABGR) Iw2DSurfaceClear(0xff000000); // draw a red square Iw2DSetColour(0xff0000ff); // note conversion to pixel coordinates Iw2DFillRect(CIwSVec2((iwsfixed)m_Position.x, (iwsfixed)m_Position.y) - m_Size/IW_FIXED(2), m_Size); // show the surface Iw2DSurfaceShow(); }
// Main entry point for the application int main() { // Initialise Iw2D Iw2DInit(); // Get surface width and height int surface_width = Iw2DGetSurfaceWidth(); int surface_height = Iw2DGetSurfaceHeight(); // Rotation angle of rectangle float angle = 0; // Wait for a quit request from the host OS while (!s3eDeviceCheckQuitRequest()) { // Clear background to blue Iw2DSurfaceClear(0xff8080); // Set up a transform CIwFMat2D mat; mat.SetRot(angle); mat.ScaleRot(2.0f); mat.SetTrans(CIwFVec2((float)surface_width / 2, (float)surface_height / 2)); Iw2DSetTransformMatrix(mat); angle += 0.01f; // Render filled rectangle Iw2DSetColour(0xff00ffff); Iw2DFillRect(CIwFVec2(-50.0f, -100.0f), CIwFVec2(100.0f, 200.0f)); // Render filled arc Iw2DSetColour(0xffff00ff); Iw2DFillArc(CIwFVec2(0, 0), CIwFVec2(100.0f, 100.0f), 0, 1.8 * PI); // Flip the surface buffer to screen Iw2DSurfaceShow(); // Sleep to allow the OS to process events etc. s3eDeviceYield(0); } // Shut down Iw2D Iw2DTerminate(); return 0; }
void Panel::Render() { if(isDisplay){ if(m_images.size()>0) { Iw2DDrawImage(m_images[m_images.size()-1], m_BGPos); } else { Iw2DSetColour(bg_color); Iw2DFillRect(m_BGPos,m_BGSize); Iw2DSetColour(0xffffffff); } if(m_text!="") { IwGxPrintSetColour(text_color[3], text_color[2], text_color[1]); IwGxPrintSetScale(m_TextScale); IwGxPrintString(m_TextPos.x, m_TextPos.y, m_text); } for(int i=m_btns.size()-1;i!=-1;i--) m_btns[i]->Render(); } }
int main(int argc, char* argv[]) { g_pointerdown = false; FillDefaultLocalScores(); // Initialisation of Airplay Studio modules Iw2DInit(); // Initialise support for rendering with the standard SW renderer IwGxLightingOff(); IwResManagerInit(); Load(); int16 sw = (int16)Iw2DGetSurfaceWidth(); int16 sh = (int16)Iw2DGetSurfaceHeight(); PAL_InitData_t palInitData; SC_Error_t retCode = SC_Client_New(&g_client, &palInitData, SC_TEST_GAME_ID, SC_TEST_GAME_SECRET, "AIW"); if (retCode != SC_OK) s3eDebugAssertShow(S3E_MESSAGE_CONTINUE_STOP, "Failed to create SC_Client"); IwGetResManager()->LoadGroup("fonts.group"); LoadGlobalImages(); LoadMainControls(); game = new CGame(); mainmenu = new CMainMenu(); profile = new CProfile(); scores = new CScores(); mainmenu->Load(); game->Load(); profile->Load(); scores->Load(); CBaseScene *curscene = (CBaseScene *)mainmenu; g_curSceneType = stMainMenu; uint32 timer = (uint32)s3eTimerGetMs(); g_AccelerometerEnabled = (s3eAccelerometerStart() == S3E_RESULT_SUCCESS); while(curscene) { s3eDeviceYield(0); //// Check for user quit if (s3eDeviceCheckQuitRequest()) break; int delta = uint32(s3eTimerGetMs()) - timer; timer += delta; // Make sure the delta-time value is safe if (delta < 0) delta = 0; if (delta > 100) delta = 100; if (g_AccelerometerEnabled) { if (!g_waiting) { if (g_errorDialog->Get_Visible()) { if (UpdatePointer() == petDown) CloseErrorDlg(); else g_errorDialog->Update(delta); } else { switch (UpdatePointer()) { case petNone: break; case petDown: curscene->PointerDown(g_pointerx, g_pointery); break; case petUp: curscene->PointerUp(g_pointerx, g_pointery); break; case petMove: curscene->PointerMove(g_pointerx, g_pointery); break; } curscene->Update(delta); } } curscene->Render(); if (g_waiting) { Iw2DSetColour(0xeeffffff); Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2(sw, sh)); Iw2DSetColour(0xff000000); Iw2DSetFont(g_font); Iw2DDrawString(g_waitcaption, CIwSVec2(0, 0), CIwSVec2(sw, sh), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE); } if (g_errorDialog->Get_Visible()) { g_errorDialog->Render(); } } Iw2DSurfaceShow(); switch (g_curSceneType) { case stNone: curscene = 0; break; case stMainMenu: { if (curscene != (CBaseScene *)mainmenu) { curscene = (CBaseScene *)mainmenu; curscene->Show(); } } break; case stGame: { if (curscene != (CBaseScene *)game) { curscene = (CBaseScene *)game; curscene->Show(); } }break; case stProfile: { if (curscene != (CBaseScene *)profile) { curscene = (CBaseScene *)profile; curscene->Show(); } }break; case stScores: { if (curscene != (CBaseScene *)scores) { curscene = (CBaseScene *)scores; curscene->Show(); } }break; } } Save(); delete game; delete mainmenu; delete profile; delete scores; SC_Client_Release(g_client); UnloadGlobalImages(); UnloadMainControls(); if (g_AccelerometerEnabled) s3eAccelerometerStop(); // Terminate system modules IwResManagerTerminate(); Iw2DTerminate(); return 0; }