Skip to content

Commit

Permalink
credits
Browse files Browse the repository at this point in the history
  • Loading branch information
joanmarquesbesses committed Jun 2, 2024
1 parent f09afe2 commit 6c60a66
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 34 deletions.
56 changes: 56 additions & 0 deletions Game/Source/Credits.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
#include "Credits.h"

#include "App.h"
#include "Textures.h"
#include "Render.h"
#include "Window.h"

Credits::Credits() : Scene()
{
name.Create("credits");
}

Credits::~Credits()
{
}

bool Credits::Awake(pugi::xml_node config)
{
sceneconfig = config;
return true;
}

bool Credits::Start()
{
img = app->tex->Load(sceneconfig.attribute("texturePath").as_string());
app->tex->GetSize(img, texW, texH);
app->render->camera.x = 0;
app->render->camera.y = 0;
app->win->GetWindowSize(windowW, windowH);
return true;
}

bool Credits::PreUpdate()
{
return true;
}

bool Credits::Update(float dt)
{
app->render->DrawTexture(img, windowW / 2 - texW / 2, windowH / 2 - texH / 2, NULL);
return true;
}

bool Credits::PostUpdate()
{

if (app->input->GetKey(SDL_SCANCODE_SPACE) == KEY_DOWN || app->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_UP || app->input->GetKey(SDL_SCANCODE_ESCAPE) == KEY_DOWN)
app->sceneManager->ChangeScane((Scene*)app->sceneManager->menu);

return true;
}

bool Credits::CleanUp()
{
app->tex->UnLoad(img);
return true;
}
58 changes: 29 additions & 29 deletions Game/Source/Credits.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ class Credits : public Scene
{
public:

// Intro();
//
// // Destructor
// virtual ~Intro();
//
// // Called before render is available
// bool Awake(pugi::xml_node config);
//
// // Called before the first frame
// bool Start();
//
// // Called before all Updates
// bool PreUpdate();
//
// // Called each loop iteration
// bool Update(float dt);
//
// // Called before all Updates
// bool PostUpdate();
//
// // Called before quitting
// bool CleanUp();
//
// uint windowW, windowH;
//
//private:
// SDL_Texture* img;
// float textPosX, textPosY = 0;
// uint texW, texH;
Credits();

// Destructor
virtual ~Credits();

// Called before render is available
bool Awake(pugi::xml_node config);

// Called before the first frame
bool Start();

// Called before all Updates
bool PreUpdate();

// Called each loop iteration
bool Update(float dt);

// Called before all Updates
bool PostUpdate();

// Called before quitting
bool CleanUp();

uint windowW, windowH;

private:
SDL_Texture* img;
float textPosX, textPosY = 0;
uint texW, texH;
};

#endif __CREDITS__
6 changes: 1 addition & 5 deletions Game/Source/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ bool Menu::Update(float dt)
{
app->render->DrawTexture(img, windowW / 2 - texW / 2, windowH / 2 - texH / 2, NULL);

if (app->input->GetKey(SDL_SCANCODE_B) == KEY_DOWN)
app->sceneManager->ChangeScane((Scene*)app->sceneManager->intro);

return true;
}

Expand Down Expand Up @@ -110,8 +107,7 @@ bool Menu::OnGuiMouseClickEvent(GuiControl* control)
app->sceneManager->OpenSettings();
}
if (control->id == 4) {
/*app->sceneManager->level1->reset = false;
settings = true;*/
app->sceneManager->ChangeScane((Scene*)app->sceneManager->credits);
}
if (control->id == 5) {
quit = true;
Expand Down
1 change: 1 addition & 0 deletions Game/Source/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum SceneType
LEVEL4,
WIN_SCREEN,
LOSE_SCREEN,
CREDITS,
NONE
};

Expand Down
4 changes: 4 additions & 0 deletions Game/Source/SceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "WinScreen.h"
#include "LoseScreen.h"
#include "InventoryMenu.h"
#include "Credits.h"
#include "Map.h"


Expand All @@ -28,6 +29,8 @@ SceneManager::SceneManager()
gameTitle->sceneType = SceneType::GAME_TITLE;
menu = new Menu();
menu->sceneType = SceneType::MENU;
credits = new Credits();
credits->sceneType = SceneType::CREDITS;
winScreen = new WinScreen();
winScreen->sceneType = SceneType::WIN_SCREEN;
loseScreen = new LoseScreen();
Expand All @@ -47,6 +50,7 @@ SceneManager::SceneManager()
scenes.Add(intro);
scenes.Add(gameTitle);
scenes.Add(menu);
scenes.Add(credits);
scenes.Add(winScreen);
scenes.Add(loseScreen);
scenes.Add(level1);
Expand Down
2 changes: 2 additions & 0 deletions Game/Source/SceneManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class GamePause;
class WinScreen;
class LoseScreen;
class InventoryMenu;
class Credits;

enum Fade_Step
{
Expand Down Expand Up @@ -93,6 +94,7 @@ class SceneManager : public Module
WinScreen* winScreen;
LoseScreen* loseScreen;
InventoryMenu* inventoryMenu;
Credits* credits;

uint windowW, windowH;

Expand Down
1 change: 1 addition & 0 deletions Output/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<intro texturePath="Assets/Textures/BGG_Anim.png" audio="Assets/Audio/Fx/logo.wav"/>
<gameTitle texturePath="Assets/Textures/gameTitle.png" audio="Assets/Audio/Fx/Flute Sound Effect.wav"/>
<menu texturePath="Assets/Textures/Menu Piramide.jpeg" audio="Assets\Audio\Music\Main_Menu.ogg"/>
<credits texturePath="Assets/Textures/Game Credits.png"/>
<inventory texturePath="Assets/Textures/inventory.png" exitButton="Assets/Textures/check.png"/>
<win_screen texturePath="Assets/Textures/Win Menu.png"/>
<lose_screen texturePath="Assets/Textures/You died Menu.png" audio="Assets\Audio\Music\GameOver.ogg"/>
Expand Down

0 comments on commit 6c60a66

Please sign in to comment.