Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuria Lamonja @needlesslord committed Jun 15, 2020
2 parents e22beca + 3f4e49b commit c14ca43
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 52 deletions.
6 changes: 6 additions & 0 deletions Source/Motor2D/GameLogoScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ bool GameLogoScene::Update(float dt)
// App->scenes->SwitchScene(SCENES::MENU_SCENE);
//}
App->player->Mouse_Cursor();


if (App->input->GetKey(SDL_SCANCODE_X) == KEY_DOWN)
{
Mix_FreeChunk(App->audio->logo_2_sound);
}



Expand Down
51 changes: 47 additions & 4 deletions Source/Motor2D/GameScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ bool GameScene::Start()
upgradePaintExtractorButton = App->gui->AddElement(TypeOfUI::GUI_BUTTON, nullptr, { 80, 485 }, { 0,0 }, true, false, { 1985, 1966, 65, 82 }, nullptr, App->scenes, TEXTURE::ATLAS, FONT::FONT_SMALL, 6);
upgradePaintExtractorButton->hover_rect = { 0, 1966, 65, 82 };
upgradePaintExtractorButton->click_rect = { 65, 1966, 65, 82 };
tagLabel = App->gui->AddElement(TypeOfUI::GUI_LABEL, nullptr, { 80, 485 }, { 0,0 }, true, false, { 0, 0, 0, 0 }, "-20M", nullptr, TEXTURE::ATLAS, FONT::FONT_SMALL, 6);


////
Expand Down Expand Up @@ -437,9 +438,9 @@ bool GameScene::Start()
PaintRollerAnimation = App->gui->AddElement(TypeOfUI::GUI_BUTTON, nullptr, { 400, -600 }, { 0,0 }, false, false, { 1493, 1275, 552, 770 }, nullptr, App->scenes, TEXTURE::ATLAS, FONT::FONT_SMALL, 6);
//PaintRollerAnimation->enabled = false;

BackgroundForest = App->gui->AddElement(TypeOfUI::GUI_IMAGE, nullptr, { 15 , 5 }, { 0 , 0 }, false, true, { 0, 1353, 1250, 35 }, nullptr, nullptr, TEXTURE::BACKGROUND_FOREST);
BackgroundSnow = App->gui->AddElement(TypeOfUI::GUI_IMAGE, nullptr, { 15 , 5 }, { 0 , 0 }, false, true, { 0, 1353, 1250, 35 }, nullptr, nullptr, TEXTURE::BACKGROUND_SNOW);
BackgroundVolcano = App->gui->AddElement(TypeOfUI::GUI_IMAGE, nullptr, { 15 , 5 }, { 0 , 0 }, false, true, { 0, 1353, 1250, 35 }, nullptr, nullptr, TEXTURE::BACKGROUND_VOLCANO);
BackgroundForest = App->gui->AddElement(TypeOfUI::GUI_IMAGE, nullptr, { 15 , 5 }, { 0 , 0 }, false, false, { 0, 1353, 1250, 35 }, nullptr, nullptr, TEXTURE::BACKGROUND_FOREST, FONT::FONT_MEDIUM, 1);
BackgroundSnow = App->gui->AddElement(TypeOfUI::GUI_IMAGE, nullptr, { 15 , 5 }, { 0 , 0 }, false, false, { 0, 1353, 1250, 35 }, nullptr, nullptr, TEXTURE::BACKGROUND_SNOW, FONT::FONT_MEDIUM, 1);
BackgroundVolcano = App->gui->AddElement(TypeOfUI::GUI_IMAGE, nullptr, { 15 , 5 }, { 0 , 0 }, false, false, { 0, 1353, 1250, 35 }, nullptr, nullptr, TEXTURE::BACKGROUND_VOLCANO, FONT::FONT_MEDIUM, 1);
//////////////////
// RESOURCES //
//////////////////
Expand Down Expand Up @@ -500,16 +501,19 @@ bool GameScene::PreUpdate()
miniMapMINI_forest->enabled = true;
miniMapMINI_snow->enabled = false;
miniMapMINI_volcano->enabled = false;
BackgroundForest->enabled = true;
}
else if (App->scenes->Map_Snow_Active) {
miniMapMINI_snow->enabled = true;
miniMapMINI_volcano->enabled = false;
miniMapMINI_forest->enabled = false;
BackgroundSnow->enabled = true;
}
else if (App->scenes->Map_Volcano_Active) {
miniMapMINI_volcano->enabled = true;
miniMapMINI_snow->enabled = false;
miniMapMINI_forest->enabled = false;
BackgroundVolcano->enabled = true;
}
//PaintRollerAnimation->enabled = false;

Expand Down Expand Up @@ -796,6 +800,24 @@ bool GameScene::Update(float dt)
// App->entities->AddEntity(ENTITY_TYPE_SLIME, { 45, 40 }, App->entities, nullptr, 0, true);
//}

if (App->entities->bought == true)
{

tagTimer++;

if (tagTimer == 0)
{
App->input->GetMousePosition(tagLabel->map_position.x, tagLabel->map_position.y);
tagLabel->enabled = true;
}
else if (tagTimer > 100)
{
tagTimer = 0;
tagLabel->enabled = false;
App->entities->bought = false;
}
}


return ret;
}
Expand Down Expand Up @@ -1313,61 +1335,75 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1UIElement* element)
if (element == buyPaintExtractorButton && type == GUI_Event::EVENT_HOVER) {

shopHoverPrice->text = "-20P PAINT EXTRACTOR";
tagLabel->text = "-20P";
shopHoverPrice->enabled = true;
}
else if (element == buyWoodProducerButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-20P WOOD PRODUCER";
tagLabel->text = "-20P";
shopHoverPrice->enabled = true;
}
else if (element == buyMetalGathererButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-20M WOOD PRODUCER";
tagLabel->text = "-20M";
shopHoverPrice->enabled = true;
}
else if (element == buyBarrackButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-50W BARRACKS";
tagLabel->text = "-50W";
shopHoverPrice->enabled = true;
}
else if (element == buyHouseButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-20W HOUSE";
tagLabel->text = "-20W";
shopHoverPrice->enabled = true;
}
else if (element == buyPainterButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-25P PAINTER";
tagLabel->text = "-25P";
shopHoverPrice->enabled = true;
//shopHoverPrice->map_position;
}
else if (element == buyExplorerButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-25P EXPLORER";
tagLabel->text = "-25P";
shopHoverPrice->enabled = true;
//shopHoverPrice->map_position;
}
else if (element == buyWarriorButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-20P WARRIOR";
tagLabel->text = "-20P";
shopHoverPrice->enabled = true;
}
else if (element == buyKnightButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-100P";
shopHoverPrice->text = "-100P KNIGHT";
tagLabel->text = "-100P";
shopHoverPrice->enabled = true;
}
else if (element == buyRangerButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-50P RANGER";
tagLabel->text = "-50P";
shopHoverPrice->enabled = true;
}
else if (element == upgradeWarriorButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-200P UP-WARRIOR";
tagLabel->text = "-200P";
shopHoverPrice->enabled = true;

}
else if (element == upgradePainterButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-200P UP-PAINTER";
tagLabel->text = "-200P";
shopHoverPrice->enabled = true;
}
else if (element == upgradePaintExtractorButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-200M UP-PAINT";
tagLabel->text = "-200M";
shopHoverPrice->enabled = true;
}
else if (element == upgradeWoodProducerButton && type == GUI_Event::EVENT_HOVER) {
shopHoverPrice->text = "-200M UP-WOOD";
tagLabel->text = "-200M";
shopHoverPrice->enabled = true;
}
else {
Expand All @@ -1386,6 +1422,7 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1UIElement* element)
{
PaintersQuestCompleted = true;
}
App->entities->bought = true;
}
else if (element == upgradePainterButton && type == GUI_Event::EVENT_ONCLICK) {

Expand All @@ -1397,6 +1434,7 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1UIElement* element)

(*upgradeAllPainters)->extractionRate *= 1.33f;
upgradeAllPainters++;
App->entities->bought = true;
}
App->entities->paintersUpgraded = true;
}
Expand All @@ -1405,13 +1443,15 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1UIElement* element)
else if (element == buyExplorerButton && type == GUI_Event::EVENT_ONCLICK) {
list<Entity*>::iterator onlyTownhallSelected = App->entities->buildingsSelected.begin();
(*onlyTownhallSelected)->SpawnEntity(ENTITY_TYPE::ENTITY_TYPE_EXPLORER);
App->entities->bought = true;
}

//Barracks shop

if (element == buyWarriorButton && type == GUI_Event::EVENT_ONCLICK) {
list<Entity*>::iterator onlyBarracksSelected = App->entities->buildingsSelected.begin();
(*onlyBarracksSelected)->SpawnEntity(ENTITY_TYPE::ENTITY_TYPE_WARRIOR);
App->entities->bought = true;
}
else if (element == upgradeWarriorButton && type == GUI_Event::EVENT_ONCLICK) {

Expand All @@ -1426,15 +1466,18 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1UIElement* element)
}
App->entities->warriorsUpgraded = true;
UpgradeWarriorQuestCompleted = true;
App->entities->bought = true;
}
}
else if (element == buyKnightButton && type == GUI_Event::EVENT_ONCLICK) {
list<Entity*>::iterator onlyBarracksSelected = App->entities->buildingsSelected.begin();
(*onlyBarracksSelected)->SpawnEntity(ENTITY_TYPE::ENTITY_TYPE_KNIGHT);
App->entities->bought = true;
}
else if (element == buyRangerButton && type == GUI_Event::EVENT_ONCLICK) {
list<Entity*>::iterator onlyBarracksSelected = App->entities->buildingsSelected.begin();
(*onlyBarracksSelected)->SpawnEntity(ENTITY_TYPE::ENTITY_TYPE_RANGER);
App->entities->bought = true;
}


Expand Down
3 changes: 2 additions & 1 deletion Source/Motor2D/GameScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ class GameScene : public Scene
j1UIElement* shopHoverUpgradeExtractor = nullptr;
j1UIElement* shopHoverUpgradeWoodProducer = nullptr;*/

// int priceTimer = 0;
int tagTimer = 0;
j1UIElement* tagLabel = nullptr;


// Buildings
Expand Down
23 changes: 7 additions & 16 deletions Source/Motor2D/MenuScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ bool MenuScene::PreUpdate()
scoreButton->map_position.x = -300;
creditsButton->map_position.x = 1300;
exitButton->map_position.x = -300;
playButton->label->map_position.x = -225;
settingsButton->label->map_position.x = 1305;
scoreButton->label->map_position.x = -255;
creditsButton->label->map_position.x = 1325;
exitButton->label->map_position.x = -250;
playButton->label->map_position.x = -292;
settingsButton->label->map_position.x = 1304;
scoreButton->label->map_position.x = -295;
creditsButton->label->map_position.x = 1300;
exitButton->label->map_position.x = -295;
ResetPosition = false;
}

Expand All @@ -116,39 +116,30 @@ bool MenuScene::Update(float dt)

if (playButton->map_position.x < 475 && App->transition_manager->is_transitioning == false) {
playButton->map_position = playButton->map_position = { playButton->map_position.x + 7,playButton->map_position.y };
}
if (playButton->label->map_position.x < 475 && App->transition_manager->is_transitioning == false) {
playButton->label->map_position = playButton->label->map_position = { playButton->label->map_position.x + 7,playButton->label->map_position.y };
}
//--
if (settingsButton->map_position.x > 490 && App->transition_manager->is_transitioning == false) {
settingsButton->map_position = settingsButton->map_position = { settingsButton->map_position.x - 7,settingsButton->map_position.y };
}
if (settingsButton->label->map_position.x > 490 && App->transition_manager->is_transitioning == false) {
settingsButton->label->map_position = settingsButton->label->map_position = { settingsButton->label->map_position.x - 7,settingsButton->label->map_position.y };
}

if (scoreButton->map_position.x < 490 && App->transition_manager->is_transitioning == false) {
scoreButton->map_position = scoreButton->map_position = { scoreButton->map_position.x + 7,scoreButton->map_position.y };
}
if (scoreButton->label->map_position.x < 490 && App->transition_manager->is_transitioning == false) {
scoreButton->label->map_position = scoreButton->label->map_position = { scoreButton->label->map_position.x + 7,scoreButton->label->map_position.y };
}

//--
if (creditsButton->map_position.x > 490 && App->transition_manager->is_transitioning == false) {
creditsButton->map_position = creditsButton->map_position = { creditsButton->map_position.x - 7,creditsButton->map_position.y };
}
if (creditsButton->label->map_position.x > 495 && App->transition_manager->is_transitioning == false) {
creditsButton->label->map_position = creditsButton->label->map_position = { creditsButton->label->map_position.x - 7,creditsButton->label->map_position.y };
}

if (exitButton->map_position.x < 505 && App->transition_manager->is_transitioning == false) {
exitButton->map_position = exitButton->map_position = { exitButton->map_position.x + 7,exitButton->map_position.y };
}
if (exitButton->label->map_position.x < 505 && App->transition_manager->is_transitioning == false) {
exitButton->label->map_position = exitButton->label->map_position = { exitButton->label->map_position.x + 7,exitButton->label->map_position.y };

}

else if( App->transition_manager->is_transitioning == false) {
FinishedPosition = true; //ONLY ONE CHANGE TO TRUE IS NEEDED BECAUSE ALL BUTTONS GET TO THEIR POSITION AT THE SAME MOMENT
}
Expand Down
11 changes: 5 additions & 6 deletions Source/Motor2D/SettingsScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ bool SettingsScene::PreUpdate()
vfxLabel->map_position.x = -300;
fullscreenLabel->map_position.x = -300;
mutelabel->map_position.x = -300;
resetButton->label->map_position.x = -300;
resetButton->label->map_position.x = 1305;
fxBar->map_position.x = 1300;
musicBar->map_position.x = 1300;
fxSlider->map_position.x = 1300;
musicSlider->map_position.x = 1300;
backButton->map_position.x = 1300;
backButton->label->map_position.x = 1305;
fullscreenButton->map_position.x = 1300;
mutebutton->map_position.x = 1300;
resetButton->map_position.x = 1300;
backButton->map_position.x = 1300;

ResetPosition = false;
}
Expand Down Expand Up @@ -181,16 +181,15 @@ bool SettingsScene::Update(float dt)

if (resetButton->map_position.x > 500 && App->transition_manager->is_transitioning == false) {
resetButton->map_position = resetButton->map_position = { resetButton->map_position.x - 7,resetButton->map_position.y };
resetButton->label->map_position = resetButton->label->map_position = { resetButton->label->map_position.x - 7,resetButton->label->map_position.y };

}
if (backButton->map_position.x > 900 && App->transition_manager->is_transitioning == false) {
backButton->map_position = backButton->map_position = { backButton->map_position.x - 7,backButton->map_position.y };
backButton->label->map_position = backButton->label->map_position = { backButton->label->map_position.x - 7,backButton->label->map_position.y };

}
if (resetButton->label->map_position.x < 500 && App->transition_manager->is_transitioning == false) {
resetButton->label->map_position = resetButton->label->map_position = { resetButton->label->map_position.x + 7,resetButton->label->map_position.y };
}
else if (App->transition_manager->is_transitioning == false) {
else if (App->transition_manager->is_transitioning == false && musicBar->map_position.x <= 621) {
FinishedPosition = true; //ONLY ONE CHANGE TO TRUE IS NEEDED BECAUSE ALL BUTTONS GET TO THEIR POSITION AT THE SAME MOMENT
}
}
Expand Down
23 changes: 7 additions & 16 deletions Source/Motor2D/StartScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ bool StartScene::PreUpdate()

if (ResetPosition == true) {
continueButton->map_position.x = -300;
continueButton->label->map_position.x = -275;
continueButton->label->map_position.x = -297;
forestButton->map_position.x = 1300;
forestButton->label->map_position.x = 1335;
forestButton->label->map_position.x = 1285;
snowButton->map_position.x = -300;
snowButton->label->map_position.x = -245;
snowButton->label->map_position.x = -292;
volcanoButton->map_position.x = 1300;
volcanoButton->label->map_position.x = 1300;
volcanoButton->label->map_position.x = 1302;
backButton->map_position.x = -300;
backButton->label->map_position.x = -250;
backButton->label->map_position.x = -292;
ResetPosition = false;
}

Expand Down Expand Up @@ -124,39 +124,30 @@ bool StartScene::Update(float dt)

if (continueButton->map_position.x < 475 && App->transition_manager->is_transitioning == false) {
continueButton->map_position = continueButton->map_position = { continueButton->map_position.x + 7,continueButton->map_position.y };
}
if (continueButton->label->map_position.x < 475 && App->transition_manager->is_transitioning == false) {
continueButton->label->map_position = continueButton->label->map_position = { continueButton->label->map_position.x + 7,continueButton->label->map_position.y };
}
//--
if (forestButton->map_position.x > 490 && App->transition_manager->is_transitioning == false) {
forestButton->map_position = forestButton->map_position = { forestButton->map_position.x - 7,forestButton->map_position.y };
}
if (forestButton->label->map_position.x > 490 && App->transition_manager->is_transitioning == false) {
forestButton->label->map_position = forestButton->label->map_position = { forestButton->label->map_position.x - 7,forestButton->label->map_position.y };
}

if (snowButton->map_position.x < 490 && App->transition_manager->is_transitioning == false) {
snowButton->map_position = snowButton->map_position = { snowButton->map_position.x + 7,snowButton->map_position.y };
}
if (snowButton->label->map_position.x < 490 && App->transition_manager->is_transitioning == false) {
snowButton->label->map_position = snowButton->label->map_position = { snowButton->label->map_position.x + 7,snowButton->label->map_position.y };
}

//--
if (volcanoButton->map_position.x > 490 && App->transition_manager->is_transitioning == false) {
volcanoButton->map_position = volcanoButton->map_position = { volcanoButton->map_position.x - 7,volcanoButton->map_position.y };
}
if (volcanoButton->label->map_position.x > 490 && App->transition_manager->is_transitioning == false) {
volcanoButton->label->map_position = volcanoButton->label->map_position = { volcanoButton->label->map_position.x - 7,volcanoButton->label->map_position.y };
}

if (backButton->map_position.x < 505 && App->transition_manager->is_transitioning == false) {
backButton->map_position = backButton->map_position = { backButton->map_position.x + 7,backButton->map_position.y };
}
if (backButton->label->map_position.x < 505 && App->transition_manager->is_transitioning == false) {
backButton->label->map_position = backButton->label->map_position = { backButton->label->map_position.x + 7,backButton->label->map_position.y };

}

else if (App->transition_manager->is_transitioning == false) {
FinishedPosition = true; //ONLY ONE CHANGE TO TRUE IS NEEDED BECAUSE ALL BUTTONS GET TO THEIR POSITION AT THE SAME MOMENT
}
Expand Down
5 changes: 4 additions & 1 deletion Source/Motor2D/TeamLogoScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ bool TeamLogoScene::Update(float dt)
// App->scenes->SwitchScene(SCENES::MENU_SCENE);
//}


if (App->input->GetKey(SDL_SCANCODE_X) == KEY_DOWN)
{
Mix_FreeChunk(App->audio->logo_1_sound);
}

return ret;
}
Expand Down
Loading

0 comments on commit c14ca43

Please sign in to comment.