void Game::InitialiseHadoken(CSprite* previous, bool isAI) { Hadoken* temp = new Hadoken(); temp->m_X = previous->m_X; temp->m_Y = previous->m_Y; temp->SetImage(g_pResources->getSettingsButton()); temp->m_AnchorX = previous->m_AnchorX; temp->m_AnchorY = previous->m_AnchorY; // Fit player to Device size temp->m_ScaleX = (float)(ScreenWidth / 8) / temp->GetImage()->GetWidth(); temp->m_ScaleY = temp->m_ScaleX; temp->setWidth(ScreenWidth / 8); projectiles[isAI].push_back(temp); CSprite* tempLine = new CSprite(); tempLine->m_X = player[isAI]->m_X + (temp->getWidth() / 2); tempLine->m_Y = player[isAI]->m_Y; tempLine->m_AnchorX = 0.5; tempLine->m_AnchorY = (float)(isAI); /*1.0 for AI, 0.0 fir player*/ tempLine->SetImage(g_pResources->getGreenImage()); tempLine->m_ScaleX = (float)(ScreenWidth / 50) / lifeBars[isAI]->GetImage()->GetWidth(); projectileLines[isAI].push_back(tempLine); AddChild(projectileLines[isAI].back()); ResizeLine(tempLine, isAI, projectiles[isAI].back()->m_Y); //we add teh hadoken after to remove overlap AddChild(projectiles[isAI].back()); }
void MainMenu::Init() { Scene::Init(); // Create menu background int w = IwGxGetScreenWidth(); int h = IwGxGetScreenHeight(); if (w > h) { int temp = w; w = h; h = temp; } CSprite* background = new CSprite(); background->m_X = (float)w / 2; background->m_Y = (float)h / 2; background->SetImage(g_pResources->getMenuBG()); background->m_W = background->GetImage()->GetWidth(); background->m_H = background->GetImage()->GetHeight(); background->m_AnchorX = 0.5; background->m_AnchorY = 0.5; // Fit background to screen size background->m_ScaleX = (float)w / background->GetImage()->GetWidth(); background->m_ScaleY = (float)h / background->GetImage()->GetHeight(); AddChild(background); playButton = new CSprite(); playButton->SetImage(g_pResources->getPlayButton()); playButton->m_X = w / 2.0f; playButton->m_Y = h / 2.0f; playButton->m_W = playButton->GetImage()->GetWidth(); playButton->m_H = playButton->GetImage()->GetHeight(); playButton->m_AnchorX = 0.5f; playButton->m_AnchorY = 0.5f; playButton->m_ScaleX = (float)(w * 0.4) / playButton->GetImage()->GetWidth(); playButton->m_ScaleY = playButton->m_ScaleX; AddChild(playButton); // Create pause menu sprite (docked to top of screen) optionsSprite = new CSprite(); optionsSprite->SetImage(g_pResources->getSettingsButton()); optionsSprite->m_X = (int)IwGxGetDeviceWidth() * 0.9; optionsSprite->m_Y = (int)IwGxGetDeviceHeight() * 0.9; optionsSprite->m_W = optionsSprite->GetImage()->GetWidth(); optionsSprite->m_H = optionsSprite->GetImage()->GetHeight(); optionsSprite->m_AnchorX = 0.5; optionsSprite->m_ScaleX = (float)(IwGxGetDeviceWidth() * 0.13) / optionsSprite->GetImage()->GetWidth(); optionsSprite->m_ScaleY = optionsSprite->m_ScaleX; AddChild(optionsSprite); // Start menu music //Audio::PlayMusic("audio/frontend.mp3"); }
void MainMenu::Init() { Scene::Init(); Game* game = (Game*)g_pSceneManager->Find("game"); // Create menu background CSprite* background = new CSprite(); background->m_X = (float)IwGxGetScreenWidth() / 2; background->m_Y = (float)IwGxGetScreenHeight() / 2; background->SetImage(g_pResources->getMenuBG()); background->m_W = background->GetImage()->GetWidth(); background->m_H = background->GetImage()->GetHeight(); background->m_AnchorX = 0.5; background->m_AnchorY = 0.5; // Fit background to screen size background->m_ScaleX = (float)IwGxGetScreenWidth() / background->GetImage()->GetWidth(); background->m_ScaleY = (float)IwGxGetScreenHeight() / background->GetImage()->GetHeight(); AddChild(background); // Create Start Game button float y_pos = (float)IwGxGetScreenHeight() * 0.66f; playButton = new CSprite(); playButton->SetImage(g_pResources->getPlacard()); playButton->m_X = IwGxGetScreenWidth() / 2.0f; playButton->m_Y = y_pos; playButton->m_W = playButton->GetImage()->GetWidth(); playButton->m_H = playButton->GetImage()->GetHeight(); playButton->m_AnchorX = 0.5f; playButton->m_AnchorY = 0.5f; playButton->m_ScaleX = game->getGraphicsScale() * 1.5f; playButton->m_ScaleY = game->getGraphicsScale() * 1.5f; AddChild(playButton); // Create Start Game button text playText = new CSprite(); playText->SetImage(g_pResources->getPlayButton()); playText->m_X = (float)IwGxGetScreenWidth() / 2; playText->m_Y = y_pos; playText->m_W = playText->GetImage()->GetWidth(); playText->m_H = playText->GetImage()->GetHeight(); playText->m_AnchorX = 0.5f; playText->m_AnchorY = 0.5f; playText->m_ScaleX = game->getGraphicsScale(); playText->m_ScaleY = game->getGraphicsScale(); AddChild(playText); // Start menu music Audio::PlayMusic("audio/frontend.mp3"); }
void PauseMenu::Init() { Game* game = (Game*)g_pSceneManager->Find("game"); add = false; int width = IwGxGetScreenWidth(); int height = IwGxGetScreenHeight(); // Create menu background CSprite* background = new CSprite(); background->m_X = (float) width / 2; background->m_Y = (float) height / 2; background->SetImage(g_pResources->getGameBGB()); background->m_AnchorX = 0.5; background->m_AnchorY = 0.5; // Fit background to screen size background->m_ScaleX = (float)width / background->GetImage()->GetWidth(); background->m_ScaleY = (float)height / background->GetImage()->GetHeight(); AddChild(background); shown = false; // Create New Game button infoButton = new CSprite(); infoButton->SetImage(g_pResources->getInfoButton()); infoButton->m_X = (float)(width * 0.15) + (width / (1.5 * 2)); infoButton->m_Y = (float)height / 50; infoButton->m_W = infoButton->GetImage()->GetWidth(); infoButton->m_H = infoButton->GetImage()->GetHeight(); infoButton->m_AnchorX = 0.5f; infoButton->m_AnchorY = 0; infoButton->m_ScaleX = (float)width / infoButton->GetImage()->GetWidth() / 1.5; infoButton->m_ScaleY = infoButton->m_ScaleX; AddChild(infoButton); // Create New Game button infoText = new CSprite(); infoText->SetImage(g_pResources->getInfoText()); infoText->m_X = (float)(width * 0.15) + ((width / (1.4 * 2))); infoText->m_W = infoText->GetImage()->GetWidth(); infoText->m_H = infoText->GetImage()->GetHeight(); infoText->m_AnchorX = 0.5f; infoText->m_AnchorY = 0.5f; infoText->m_ScaleX = (float)(width / infoText->GetImage()->GetWidth()) / 1.4; infoText->m_ScaleY = infoText->m_ScaleX; infoText->m_Y = (float)(infoText->GetImage()->GetHeight() * infoText->m_ScaleX)/ 2 + (height / 6); AddChild(infoText); }
void EventsScene::Init() { Scene::Init(); // Create menu background CSprite* background = new CSprite(); background->m_X = (float)IwGxGetScreenWidth() / 2; background->m_Y = (float)IwGxGetScreenHeight() / 2; background->SetImage(g_pResources->getbackground()); background->m_W = background->GetImage()->GetWidth(); background->m_H = background->GetImage()->GetHeight(); background->m_AnchorX = 0.5; background->m_AnchorY = 0.5; // Fit background to screen size background->m_ScaleX = (float)IwGxGetScreenWidth() / background->GetImage()->GetWidth(); background->m_ScaleY = (float)IwGxGetScreenHeight() / background->GetImage()->GetHeight(); AddChild(background); hasFeed = false; }
// Initialise the games user interface void Game::initUI() { CSprite* background = new CSprite(); background->m_X = (float)(ScreenWidth / 2); background->m_Y = (float)(ScreenHeight / 2); background->SetImage(g_pResources->getMenuBG()); background->m_AnchorX = 0.5f; background->m_AnchorY = 0.5f; // Fit background to Device size background->m_ScaleX = (float)(ScreenWidth) / background->GetImage()->GetWidth(); background->m_ScaleY = (float)ScreenHeight / background->GetImage()->GetHeight(); AddChild(background); CSprite* FloorSprite = new CSprite(); FloorSprite->m_X = (float)(background->m_X / 4); FloorSprite->m_Y = (float)(ScreenHeight / 2); FloorSprite->SetImage(g_pResources->getFloorImage()); FloorSprite->m_AnchorX = 0.5f; FloorSprite->m_AnchorY = 0.5f; // Fit FloorSprite to Device size FloorSprite->m_ScaleX = (float)(ScreenWidth / 4) / FloorSprite->GetImage()->GetWidth(); FloorSprite->m_ScaleY = (float)ScreenHeight / FloorSprite->GetImage()->GetHeight(); AddChild(FloorSprite); player = new Fighter*[2]; lifeBars = new CSprite*[2]; CreateFighter(PLAYER_ONE, (float)(ScreenHeight / 3)); CreateFighter(PLAYER_TWO, (float)(player[PLAYER_ONE]->m_Y * 2)); CreateLifeBar(PLAYER_ONE, 0); CreateLifeBar(PLAYER_TWO, ScreenHeight); //2 special buttons buttons = new CSprite*[NUM_BUTTONS + 2]; int i; for (i = 0; i < NUM_BUTTONS; i++) { CreateButton(i, FloorSprite->m_X, (float)(ScreenHeight / 5) * (i + 1)); } CreateButton(i, FloorSprite->m_X + (ScreenWidth / 8), buttons[i - 2]->m_Y + (float)(ScreenHeight / 8)); i++; CreateButton(i, buttons[i - 1]->m_X, buttons[i - 2]->m_Y + (float)(ScreenHeight / 8)); //flip the first button as it is the same as the second buttons[0]->m_Angle += 180.0f; float fontScale = (float)IwGxGetScreenWidth() / FONT_DESIGN_WIDTH; float actualFontHeight = FONT_HEIGHT * fontScale; MessageLabel = new CLabel(); MessageLabel->m_X = IwGxGetDisplayWidth() / 2; MessageLabel->m_Y = ScreenHeight / 2; MessageLabel->m_W = FONT_DESIGN_WIDTH; MessageLabel->m_H = actualFontHeight; MessageLabel->m_AlignHor = IW_2D_FONT_ALIGN_LEFT; MessageLabel->m_AlignVer = IW_2D_FONT_ALIGN_TOP; MessageLabel->m_Font = g_pResources->getFont(); MessageLabel->m_ScaleX = fontScale; MessageLabel->m_ScaleY = fontScale; MessageLabel->m_Angle = 270.0f; AddChild(MessageLabel); MessageLabel->m_Alpha = 0.0f; }
void PauseMenu::Init() { Game* game = (Game*)g_pSceneManager->Find("game"); // Create menu background CSprite* background = new CSprite(); background->m_X = (float)IwGxGetScreenWidth() / 2; background->m_Y = (float)IwGxGetScreenHeight() / 2; background->SetImage(g_pResources->getMenuBG()); background->m_AnchorX = 0.5; background->m_AnchorY = 0.5; // Fit background to screen size background->m_ScaleX = (float)IwGxGetScreenWidth() / background->GetImage()->GetWidth(); background->m_ScaleY = (float)IwGxGetScreenHeight() / background->GetImage()->GetHeight(); AddChild(background); // Create Continue Game button continueGameButton = new CSprite(); continueGameButton->SetImage(g_pResources->getMenuButton()); int button_height = (int)(continueGameButton->GetImage()->GetHeight() * game->getGraphicsScale()); int y_pos = button_height * 2; continueGameButton->m_X = (float)IwGxGetScreenWidth() / 2; continueGameButton->m_Y = (float)y_pos; continueGameButton->m_AnchorX = 0.5f; continueGameButton->m_AnchorY = 0; continueGameButton->m_ScaleX = game->getGraphicsScale(); continueGameButton->m_ScaleY = game->getGraphicsScale(); AddChild(continueGameButton); // Create Continue Game button text CLabel* label = new CLabel(); label->m_X = continueGameButton->m_W / 2; label->m_Y = continueGameButton->m_H / 2; label->m_W = continueGameButton->m_W; label->m_H = continueGameButton->m_H; label->m_AnchorX = 0.5f; label->m_AnchorY = 0.5f; label->m_ScaleX = game->getFontScale() / game->getGraphicsScale(); // Compound scaling factors as label ie child of button label->m_ScaleY = label->m_ScaleX; label->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE; label->m_AlignVer = IW_2D_FONT_ALIGN_CENTRE; label->m_Font = g_pResources->getFont(); label->m_Text = "Continue", label->m_Color = CColor(0xff, 0xff, 0xff, 0xff); continueGameButton->AddChild(label); y_pos += button_height; // Create New Game button newGameButton = new CSprite(); newGameButton->SetImage(g_pResources->getMenuButton()); newGameButton->m_X = (float)IwGxGetScreenWidth() / 2; newGameButton->m_Y = (float)y_pos; newGameButton->m_W = newGameButton->GetImage()->GetWidth(); newGameButton->m_H = newGameButton->GetImage()->GetHeight(); newGameButton->m_AnchorX = 0.5f; newGameButton->m_AnchorY = 0; newGameButton->m_ScaleX = game->getGraphicsScale(); newGameButton->m_ScaleY = game->getGraphicsScale(); AddChild(newGameButton); // Create Continue Game button text label = new CLabel(); label->m_X = newGameButton->m_W / 2; label->m_Y = newGameButton->m_H / 2; label->m_W = newGameButton->m_W; label->m_H = newGameButton->m_H; label->m_AnchorX = 0.5f; label->m_AnchorY = 0.5f; label->m_ScaleX = game->getFontScale() / game->getGraphicsScale(); // Compound scaling factors as label ie child of button label->m_ScaleY = label->m_ScaleX; label->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE; label->m_AlignVer = IW_2D_FONT_ALIGN_CENTRE; label->m_Font = g_pResources->getFont(); label->m_Text = "New Game", label->m_Color = CColor(0xff, 0xff, 0xff, 0xff); newGameButton->AddChild(label); y_pos += button_height; /*if (g_pAds->IsEnabled()) { // Create NoAds button noAdsButton = new CSprite(); noAdsButton->SetImage(g_pResources->getMenuButton()); noAdsButton->m_X = (float)IwGxGetScreenWidth() / 2; noAdsButton->m_Y = (float)y_pos; noAdsButton->m_W = noAdsButton->GetImage()->GetWidth(); noAdsButton->m_H = noAdsButton->GetImage()->GetHeight(); noAdsButton->m_AnchorX = 0.5f; noAdsButton->m_AnchorY = 0; noAdsButton->m_ScaleX = game->getGraphicsScale(); noAdsButton->m_ScaleY = game->getGraphicsScale(); AddChild(noAdsButton); // Create Continue Game button text label = new CLabel(); label->m_X = noAdsButton->m_W / 2; label->m_Y = noAdsButton->m_H / 2; label->m_W = noAdsButton->m_W; label->m_H = noAdsButton->m_H; label->m_AnchorX = 0.5f; label->m_AnchorY = 0.5f; label->m_ScaleX = game->getFontScale() / game->getGraphicsScale(); // Compound scaling factors as label ie child of button label->m_ScaleY = label->m_ScaleX; label->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE; label->m_AlignVer = IW_2D_FONT_ALIGN_CENTRE; label->m_Font = g_pResources->getFont(); label->m_Text = "Remove Ads", label->m_Color = CColor(0xff, 0xff, 0xff, 0xff); noAdsButton->AddChild(label); }*/ }
// Initialise the games user interface void Game::initUI() { // Create background CSprite* background = new CSprite(); background->m_X = (float)IwGxGetScreenWidth() / 2; background->m_Y = (float)IwGxGetScreenHeight() / 2; background->SetImage(g_pResources->getGameBG()); background->m_W = background->GetImage()->GetWidth(); background->m_H = background->GetImage()->GetHeight(); background->m_AnchorX = 0.5; background->m_AnchorY = 0.5; // Fit background to screen size background->m_ScaleX = (float)IwGxGetScreenWidth() / background->GetImage()->GetWidth(); background->m_ScaleY = (float)IwGxGetScreenHeight() / background->GetImage()->GetHeight(); AddChild(background); // Create grid background sprite gridSprite = new CSprite(); gridSprite->m_X = 0; gridSprite->m_Y = IwGxGetScreenHeight() - g_pResources->getGrid()->GetHeight() * graphicsScale; gridSprite->m_ScaleX = graphicsScale; gridSprite->m_ScaleY = graphicsScale; gridSprite->SetImage(g_pResources->getGrid()); AddChild(gridSprite); // Create left placard leftPlacard = new CSprite(); leftPlacard->SetImage(g_pResources->getPlacard()); leftPlacard->m_X = 0; leftPlacard->m_Y = (float)uiYPosition; leftPlacard->m_ScaleX = graphicsScale; leftPlacard->m_ScaleY = graphicsScale; AddChild(leftPlacard); // Create right placard rightPlacard = new CSprite(); rightPlacard->SetImage(g_pResources->getPlacard()); rightPlacard->m_X = (float)IwGxGetScreenWidth() - rightPlacard->GetImage()->GetWidth() * graphicsScale; rightPlacard->m_Y = (float)uiYPosition; rightPlacard->m_ScaleX = graphicsScale; rightPlacard->m_ScaleY = graphicsScale; AddChild(rightPlacard); // Create score label text scoreLabelText = new CLabel(); scoreLabelText->m_X = 30 * fontScale; scoreLabelText->m_Y = uiYPosition + 10 * fontScale; scoreLabelText->m_W = FONT_DESIGN_WIDTH; scoreLabelText->m_H = actualFontHeight; scoreLabelText->m_Text = "Score:"; scoreLabelText->m_AlignHor = IW_2D_FONT_ALIGN_LEFT; scoreLabelText->m_AlignVer = IW_2D_FONT_ALIGN_TOP; scoreLabelText->m_Font = g_pResources->getFont(); scoreLabelText->m_ScaleX = fontScale; scoreLabelText->m_ScaleY = fontScale; scoreLabelText->m_Color = CColor(0xff, 0xff, 0x30, 0xff); AddChild(scoreLabelText); // Create score label (displays actual score) scoreLabel = new CLabel(); scoreLabel->m_X = 80 * fontScale; scoreLabel->m_Y = uiYPosition + 10 * fontScale; scoreLabel->m_W = FONT_DESIGN_WIDTH; scoreLabel->m_H = actualFontHeight; scoreLabel->m_Text = "0"; scoreLabel->m_AlignHor = IW_2D_FONT_ALIGN_LEFT; scoreLabel->m_AlignVer = IW_2D_FONT_ALIGN_TOP; scoreLabel->m_Font = g_pResources->getFont(); scoreLabel->m_ScaleX = fontScale; scoreLabel->m_ScaleY = fontScale; AddChild(scoreLabel); // Create target score label text targetScoreLabelText = new CLabel(); targetScoreLabelText->m_X = 30 * fontScale; targetScoreLabelText->m_Y = uiYPosition + 30 * fontScale; targetScoreLabelText->m_W = FONT_DESIGN_WIDTH; targetScoreLabelText->m_H = actualFontHeight; targetScoreLabelText->m_Text = "Target:"; targetScoreLabelText->m_AlignHor = IW_2D_FONT_ALIGN_LEFT; targetScoreLabelText->m_AlignVer = IW_2D_FONT_ALIGN_TOP; targetScoreLabelText->m_Font = g_pResources->getFont(); targetScoreLabelText->m_ScaleX = fontScale; targetScoreLabelText->m_ScaleY = fontScale; targetScoreLabelText->m_Color = CColor(0xff, 0xff, 0x30, 0xff); AddChild(targetScoreLabelText); //- Create target score label (displays target score) targetScoreLabel = new CLabel(); targetScoreLabel->m_X = 80 * fontScale; targetScoreLabel->m_Y = uiYPosition + 30 * fontScale; targetScoreLabel->m_W = FONT_DESIGN_WIDTH; targetScoreLabel->m_H = actualFontHeight; targetScoreLabel->m_Text = "0"; targetScoreLabel->m_AlignHor = IW_2D_FONT_ALIGN_LEFT; targetScoreLabel->m_AlignVer = IW_2D_FONT_ALIGN_TOP; targetScoreLabel->m_Font = g_pResources->getFont(); targetScoreLabel->m_ScaleX = fontScale; targetScoreLabel->m_ScaleY = fontScale; AddChild(targetScoreLabel); // Create round label text roundLabelText = new CLabel(); roundLabelText->m_X = IwGxGetScreenWidth() - 100 * fontScale; roundLabelText->m_Y = uiYPosition + 10 * fontScale; roundLabelText->m_W = FONT_DESIGN_WIDTH; roundLabelText->m_H = actualFontHeight; roundLabelText->m_Text = "Round:"; roundLabelText->m_AlignHor = IW_2D_FONT_ALIGN_LEFT; roundLabelText->m_AlignVer = IW_2D_FONT_ALIGN_TOP; roundLabelText->m_Font = g_pResources->getFont(); roundLabelText->m_ScaleX = fontScale; roundLabelText->m_ScaleY = fontScale; roundLabelText->m_Color = CColor(0xff, 0xff, 0x30, 0xff); AddChild(roundLabelText); // Create round label roundLabel = new CLabel(); roundLabel->m_X = -30 * fontScale; roundLabel->m_Y = uiYPosition + 10 * fontScale; roundLabel->m_W = FONT_DESIGN_WIDTH; roundLabel->m_H = actualFontHeight; roundLabel->m_Text = "0"; roundLabel->m_AlignHor = IW_2D_FONT_ALIGN_RIGHT; roundLabel->m_AlignVer = IW_2D_FONT_ALIGN_TOP; roundLabel->m_Font = g_pResources->getFont(); roundLabel->m_ScaleX = fontScale; roundLabel->m_ScaleY = fontScale; AddChild(roundLabel); // Create timer label text timerLabelText = new CLabel(); timerLabelText->m_X = IwGxGetScreenWidth() - 100 * fontScale; timerLabelText->m_Y = uiYPosition + 30 * fontScale; timerLabelText->m_W = FONT_DESIGN_WIDTH; timerLabelText->m_H = actualFontHeight; timerLabelText->m_Text = "Time:"; timerLabelText->m_AlignHor = IW_2D_FONT_ALIGN_LEFT; timerLabelText->m_AlignVer = IW_2D_FONT_ALIGN_TOP; timerLabelText->m_Font = g_pResources->getFont(); timerLabelText->m_ScaleX = fontScale; timerLabelText->m_ScaleY = fontScale; timerLabelText->m_Color = CColor(0xff, 0xff, 0x30, 0xff); AddChild(timerLabelText); // Create timer label timerLabel = new CLabel(); timerLabel->m_X = -30 * fontScale; timerLabel->m_Y = uiYPosition + 30 * fontScale; timerLabel->m_W = FONT_DESIGN_WIDTH; timerLabel->m_H = actualFontHeight; timerLabel->m_Text = "0"; timerLabel->m_AlignHor = IW_2D_FONT_ALIGN_RIGHT; timerLabel->m_AlignVer = IW_2D_FONT_ALIGN_TOP; timerLabel->m_Font = g_pResources->getFont(); timerLabel->m_ScaleX = fontScale; timerLabel->m_ScaleY = fontScale; AddChild(timerLabel); // Create pause menu sprite (docked to top of screen) pauseSprite = new CSprite(); pauseSprite->SetImage(g_pResources->getPauseIcon()); pauseSprite->m_X = (float)IwGxGetScreenWidth() / 2; pauseSprite->m_Y = 0; pauseSprite->m_W = pauseSprite->GetImage()->GetWidth(); pauseSprite->m_H = pauseSprite->GetImage()->GetHeight(); pauseSprite->m_AnchorX = 0.5; pauseSprite->m_ScaleX = graphicsScale; pauseSprite->m_ScaleY = graphicsScale; AddChild(pauseSprite); // Create target gem sprite targetGemSprite = new CSprite(); targetGemSprite->SetAtlas(g_pResources->getGemAtlas(0)); targetGemSprite->SetAnimDuration(2); targetGemSprite->m_X = (float)IwGxGetScreenWidth() / 2; targetGemSprite->m_Y = 0; targetGemSprite->m_AnchorX = 0.5; targetGemSprite->m_ScaleX = graphicsScale; targetGemSprite->m_ScaleY = graphicsScale; targetGemSprite->m_IsVisible = false; AddChild(targetGemSprite); }
void Streamer::Init() { //Game* game = (Game*)g_pSceneManager->Find("game"); initAudio("128.198.85.100", 8000); s3eDeviceRegister(S3E_DEVICE_EXIT, &exitCB, 0); facebook = new CSprite(); facebook->SetImage(g_pResources->getFacebook()); facebook->m_X = (float)IwGxGetScreenWidth() / 1.4; facebook->m_Y = (float)IwGxGetScreenHeight() / 16; facebook->m_W = facebook->GetImage()->GetWidth(); facebook->m_H = facebook->GetImage()->GetHeight(); facebook->m_AnchorX = 0.5; facebook->m_AnchorY = 0.5; facebook->m_ScaleX = (float)IwGxGetScreenWidth() / facebook->GetImage()->GetWidth() / 8; facebook->m_ScaleY = (float)IwGxGetScreenHeight() / facebook->GetImage()->GetHeight() / 12; twitter = new CSprite(); twitter->SetImage(g_pResources->getTwitter()); twitter->m_X = (float)IwGxGetScreenWidth() / 1.1; twitter->m_Y = (float)IwGxGetScreenHeight() / 16; twitter->m_W = twitter->GetImage()->GetWidth(); twitter->m_H = twitter->GetImage()->GetHeight(); twitter->m_AnchorX = 0.5; twitter->m_AnchorY = 0.5; twitter->m_ScaleX = (float)IwGxGetScreenWidth() / twitter->GetImage()->GetWidth() / 8; twitter->m_ScaleY = (float)IwGxGetScreenHeight() / twitter->GetImage()->GetHeight() / 12; // Create menu background header = new CSprite(); header->SetImage(g_pResources->getHeader()); header->m_X = (float)IwGxGetScreenWidth() / 3; header->m_Y = (float)IwGxGetScreenHeight() / 17; header->m_W = header->GetImage()->GetWidth(); header->m_H = header->GetImage()->GetHeight(); header->m_AnchorX = 0.5; header->m_AnchorY = 0.5; // Fit background to screen size header->m_ScaleX = (float)IwGxGetScreenWidth() / header->GetImage()->GetWidth() / 1.5; header->m_ScaleY = (float)IwGxGetScreenHeight() / header->GetImage()->GetHeight() / 5; // Create menu background CSprite* whiteBanner = new CSprite(); whiteBanner->SetImage(g_pResources->getWhiteBanner()); whiteBanner->m_X = (float)IwGxGetScreenWidth() / 2; whiteBanner->m_Y = (float)IwGxGetScreenHeight() / 17; whiteBanner->m_W = whiteBanner->GetImage()->GetWidth(); whiteBanner->m_H = whiteBanner->GetImage()->GetHeight(); whiteBanner->m_AnchorX = 0.5; whiteBanner->m_AnchorY = 0.5; // Fit background to screen size whiteBanner->m_ScaleX = (float)IwGxGetScreenWidth() / whiteBanner->GetImage()->GetWidth() / 1; whiteBanner->m_ScaleY = (float)IwGxGetScreenHeight() / whiteBanner->GetImage()->GetHeight() / 5; // Create menu background playWrapper = new CSprite(); playWrapper->SetImage(g_pResources->getPlayWrapper()); playWrapper->m_X = (float)IwGxGetScreenWidth() / 2; playWrapper->m_Y = (float)IwGxGetScreenHeight() / 1.09; playWrapper->m_W = playWrapper->GetImage()->GetWidth(); playWrapper->m_H = playWrapper->GetImage()->GetHeight(); playWrapper->m_AnchorX = 0.5; playWrapper->m_AnchorY = 0.5; //playWrapper->m_Alpha = 0.9; // Fit background to screen size playWrapper->m_ScaleX = (float)IwGxGetScreenWidth() / playWrapper->GetImage()->GetWidth() / 1; playWrapper->m_ScaleY = (float)IwGxGetScreenHeight() / playWrapper->GetImage()->GetHeight() / 6; playButton = new CSprite(); playButton->SetImage(g_pResources->getPlayButton()); playButton->m_X = (float)IwGxGetScreenWidth() / 2; playButton->m_Y = (float)IwGxGetScreenHeight() / 1.13; //buttonTop = (float)IwGxGetScreenHeight() / 1.14 - (playButton->GetImage()->GetHeight() / 8); playButton->m_W = playButton->GetImage()->GetWidth(); playButton->m_H = playButton->GetImage()->GetHeight(); playButton->m_AnchorX = 0.5; playButton->m_AnchorY = 0.5; // Fit background to screen size playButton->m_ScaleX = (float)IwGxGetScreenWidth() / playButton->GetImage()->GetWidth() / 3.2; playButton->m_ScaleY = (float)IwGxGetScreenHeight() / playButton->GetImage()->GetHeight() / 4.5; //buttonTop = ((float)IwGxGetScreenHeight() / 1.14) - (playButton->GetImage()->GetHeight() / 3.7); stopButton = new CSprite(); stopButton->SetImage(g_pResources->getStopButton()); stopButton->m_X = (float)IwGxGetScreenWidth() / 2; stopButton->m_Y = (float)IwGxGetScreenHeight() / 1.13; stopButton->m_W = stopButton->GetImage()->GetWidth(); stopButton->m_H = stopButton->GetImage()->GetHeight(); stopButton->m_AnchorX = 0.5; stopButton->m_AnchorY = 0.5; // Fit background to screen size stopButton->m_ScaleX = (float)IwGxGetScreenWidth() / stopButton->GetImage()->GetWidth() / 3.2; stopButton->m_ScaleY = (float)IwGxGetScreenHeight() / stopButton->GetImage()->GetHeight() / 4.5; banner = new CSprite(); banner->SetImage(g_pResources->getGreyBanner()); banner->m_X = (float)IwGxGetScreenWidth() / 2; banner->m_Y = (float)IwGxGetScreenHeight() /6; banner->m_W = banner->GetImage()->GetWidth(); banner->m_H = banner->GetImage()->GetHeight(); banner->m_AnchorX = 0.5; banner->m_AnchorY = 0.5; // Fit background to screen size banner->m_ScaleX = (float)IwGxGetScreenWidth() / banner->GetImage()->GetWidth() / 1; banner->m_ScaleY = (float)IwGxGetScreenHeight() / banner->GetImage()->GetHeight() / 8; buttonTop = IwGxGetScreenHeight() / 4; labelLeft = new CLabel(); labelLeft->m_Font = g_pResources->getBannerFontSmall(); labelLeft->m_Text = "Cal."; labelLeft->m_Y = IwGxGetDisplayHeight() / 6.5; labelLeft->m_W = IwGxGetDisplayWidth() / 2; labelLeft->m_ScaleX = 1.0; labelLeft->m_AlignHor = IW_2D_FONT_ALIGN_LEFT; labelLeft->m_X += 10; labelLeft->m_Color = CColor(114, 114, 114, 0xff); labelRight = new CLabel(); labelRight->m_Font = g_pResources->getBannerFontSmall(); labelRight->m_Text = "Events"; labelRight->m_Y = IwGxGetDisplayHeight() / 6.5; labelRight->m_W = IwGxGetDisplayWidth() / 2; labelRight->m_AlignHor = IW_2D_FONT_ALIGN_RIGHT; labelRight->m_X += (IwGxGetDisplayWidth() / 2.0) -10; labelRight->m_Color = CColor(114, 114, 114, 0xff); labelMain = new CLabel(); labelMain->m_Font = g_pResources->getBannerFontLarge(); labelMain->m_Text = "News"; labelMain->m_Y = IwGxGetDisplayHeight() / 7.5; labelMain->m_W = IwGxGetDisplayWidth(); labelMain->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE; AddChild(banner); AddChild(whiteBanner); AddChild(header); AddChild(labelRight); AddChild(labelLeft); AddChild(playWrapper); AddChild(playButton); AddChild(stopButton); AddChild(labelMain); AddChild(facebook); AddChild(twitter); stopButton->m_X = IwGxGetScreenWidth() * 2.0; currentPage = 0; }
Tenant::Tenant(int* roomx, int* roomy, aux::type t) : id(newID++) { room_x = *roomx; room_y = *roomy; CSprite* s = new CSprite; CSprite* b = new CSprite; CAtlas* a = new CAtlas; stress = 100; damage = 0; type = t; neighbors.upleft_x = room_x - 1; neighbors.upleft_y = room_y + 1; neighbors.up_x = room_x; neighbors.up_y = room_y + 1; neighbors.upright_x = room_x + 1; neighbors.upright_y = room_y + 1; neighbors.right_x = room_x + 1; neighbors.right_y = room_y; neighbors.downright_x = room_x + 1; neighbors.downright_y = room_y - 1; neighbors.down_x = room_x; neighbors.down_y = room_y - 1; neighbors.downleft_x = room_x - 1; neighbors.downleft_y = room_y - 1; neighbors.left_x = room_x - 1; neighbors.left_y = room_y; //criar barra de stress stressBar = new CSprite; stressBar->SetImage(g_pResources->getStressBar0()); stressBar->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (stressBar->GetImage()->GetWidth() / 2)); stressBar->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (4 + stressBar->GetImage()->GetHeight()); stressLabel = new CLabel(); stressLabel->m_W = stressBar->m_W; stressLabel->m_H = stressBar->m_H; stressLabel->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (stressBar->GetImage()->GetWidth() / 2));; stressLabel->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (4 + stressBar->GetImage()->GetHeight());; stressLabel->m_Text = "100/100"; stressLabel->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE; stressLabel->m_AlignVer = IW_2D_FONT_ALIGN_CENTRE; stressLabel->m_Font = g_pResources->getFont(); stressLabel->m_Color = CColor(0, 0, 0, 255); switch (t) { using namespace aux; case MODEL: // se for o personagem model, carregue os sprites, e stats desse personagem behavior.upleft = VOID; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = VOID; behavior.upright = VOID; behavior.right = TRUE; behavior.downright = VOID; behavior.down = FALSE; behavior.downleft = VOID; behavior.left = TRUE; s->SetImage(g_pResources->getModel()); b->SetImage(g_pResources->getModelSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case SINGER: behavior.upleft = VOID; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = TRUE; behavior.upright = VOID; behavior.right = TRUE; behavior.downright = VOID; behavior.down = TRUE; behavior.downleft = VOID; behavior.left = TRUE; s->SetImage(g_pResources->getSinger()); b->SetImage(g_pResources->getSingerSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case MUCHALUCHA: behavior.upleft = VOID; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = FALSE; behavior.upright = VOID; behavior.right = FALSE; behavior.downright = VOID; behavior.down = FALSE; behavior.downleft = VOID; behavior.left = FALSE; s->SetImage(g_pResources->getMuchaLucha()); b->SetImage(g_pResources->getMuchaLuchaSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case BOLEIRO: behavior.upleft = FALSE; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = VOID; behavior.upright = FALSE; behavior.right = VOID; behavior.downright = FALSE; behavior.down = VOID; behavior.downleft = FALSE; behavior.left = VOID; s->SetImage(g_pResources->getBoleiro()); b->SetImage(g_pResources->getBoleiroSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case JUMPMAN: behavior.upleft = VOID; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = TRUE; behavior.upright = VOID; behavior.right = VOID; behavior.downright = VOID; behavior.down = FALSE; behavior.downleft = VOID; behavior.left = VOID; s->SetImage(g_pResources->getJumpMan()); b->SetImage(g_pResources->getJumpManSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case FLORIST: behavior.upleft = TRUE; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = TRUE; behavior.upright = TRUE; behavior.right = TRUE; behavior.downright = TRUE; behavior.down = TRUE; behavior.downleft = TRUE; behavior.left = TRUE; s->SetImage(g_pResources->getFlorist()); b->SetImage(g_pResources->getFloristSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case DOG: behavior.upleft = VOID; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = VOID; behavior.upright = VOID; behavior.right = FALSE; behavior.downright = VOID; behavior.down = VOID; behavior.downleft = VOID; behavior.left = VOID; s->SetImage(g_pResources->getDog()); b->SetImage(g_pResources->getDogSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case CAT: behavior.upleft = VOID; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = VOID; behavior.upright = VOID; behavior.right = VOID; behavior.downright = VOID; behavior.down = VOID; behavior.downleft = VOID; behavior.left = FALSE; s->SetImage(g_pResources->getCat()); b->SetImage(g_pResources->getCatSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case LATINO: behavior.upleft = FALSE; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = FALSE; behavior.upright = FALSE; behavior.right = FALSE; behavior.downright = FALSE; behavior.down = FALSE; behavior.downleft = FALSE; behavior.left = FALSE; s->SetImage(g_pResources->getLatino()); b->SetImage(g_pResources->getLatinoSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case BOSSKID: behavior.upleft = FALSE; // VOID = 0, TRUE = +hp, FALSE = -hp behavior.up = FALSE; behavior.upright = FALSE; behavior.right = VOID; behavior.downright = FALSE; behavior.down = FALSE; behavior.downleft = FALSE; behavior.left = VOID; s->SetImage(g_pResources->getBosskid()); b->SetImage(g_pResources->getBosskidSet()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (24 + s->GetImage()->GetHeight()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; case PROPRIETOR: behavior.upleft = VOID; behavior.up = VOID; behavior.upright = VOID; behavior.right = VOID; behavior.downright = VOID; behavior.down = VOID; behavior.downleft = VOID; behavior.left = VOID; s->SetImage(g_pResources->getProprietor()); s->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (s->GetImage()->GetWidth() / 2)); s->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (g_pResources->getAp()->GetHeight()/2 + s->GetImage()->GetHeight()/2); b->SetImage(g_pResources->getBosskidSet()); b->m_X = (room_x * g_pResources->getAp()->GetWidth()) + ((g_pResources->getAp()->GetWidth() / 2) - (b->GetImage()->GetWidth() / 2)); b->m_Y = Iw2DGetSurfaceHeight() - (room_y * g_pResources->getAp()->GetHeight()) - (b->GetImage()->GetHeight()); sprite = s; behavior_set = b; break; default: break; } }