Skip to content

Commit

Permalink
Enable/Disable Scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
Historn committed Nov 6, 2022
1 parent d4f835b commit 5f38720
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 44 deletions.
20 changes: 12 additions & 8 deletions citm_desvj_project_template-L07/Game/Source/EndingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ bool EndingScreen::Awake(pugi::xml_node& config)
// Called before the first frame
bool EndingScreen::Start()
{
LOG("--STARTS ENDING SCENE--");
/*app->entityManager->Disable();
app->scene->Disable();
app->physics->Disable();
app->map->Disable();*/

img = app->tex->Load("Assets/Textures/EndingScreen.png");
app->scene->player->dead = false;
app->scene->player->ResetPlayerPos();
Expand All @@ -64,9 +70,9 @@ bool EndingScreen::Update(float dt)


if (app->input->GetKey(SDL_SCANCODE_RETURN) == KEY_DOWN) {
LOG("PASA A OTRA PUTA ESCENA");
LOG("PASA A GAME SCENE");
app->fade->FadeToBlack(this, (Module*)app->scene, 90);
app->scene->cameraFix = false;
//app->scene->cameraFix = false;
app->audio->PlayFx(startSFX);
}

Expand All @@ -77,22 +83,20 @@ bool EndingScreen::Update(float dt)
bool EndingScreen::PostUpdate()
{
bool ret = true;


app->render->DrawTexture(img, app->render->camera.x, 0,NULL);


if (app->input->GetKey(SDL_SCANCODE_ESCAPE) == KEY_DOWN)
ret = false;

app->render->DrawTexture(img, app->render->camera.x, 0, NULL);

return ret;
}

// Called before quitting
bool EndingScreen::CleanUp()
{
LOG("Freeing scene");

LOG("Freeing ENDING SCENE");
//app->scene->Enable();
if (img != nullptr) {
app->tex->UnLoad(img);
}
Expand Down
14 changes: 9 additions & 5 deletions citm_desvj_project_template-L07/Game/Source/LogoScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ bool LogoScreen::Awake(pugi::xml_node& config)
// Called before the first frame
bool LogoScreen::Start()
{
LOG("--STARTS LOGO SCENE--");
img = app->tex->Load("Assets/Textures/LogoScreen.png");
app->audio->PlayMusic("Assets/Audio/Music/logoedit.ogg");

Expand All @@ -54,18 +55,21 @@ bool LogoScreen::Update(float dt)
{
time++;
frameCount--;
/*if (app->input->GetKey(SDL_SCANCODE_SPACE) == KEY_DOWN) {
LOG("PASA A OTRA PUTA ESCENA");

if (app->input->GetKey(SDL_SCANCODE_RETURN) == KEY_DOWN) {
LOG("PASA A TITLE SCENE");
app->fade->FadeToBlack(this, (Module*)app->titlescreen, 90);
}*/
}

fadeRatio = (float)frameCount / (float)maxFadeFrames;


SDL_RenderFillRect(app->render->renderer, NULL);

if (time >= 480)
if (time >= 480) {
LOG("PASA A TITLE SCENE");
app->fade->FadeToBlack(this, (Module*)app->titlescreen, 90);
}

app->render->DrawTexture(img, 0, 0, NULL);

Expand All @@ -89,7 +93,7 @@ bool LogoScreen::PostUpdate()
// Called before quitting
bool LogoScreen::CleanUp()
{
LOG("Freeing scene");
LOG("Freeing LOGO SCENE");

if (img != nullptr) {
app->tex->UnLoad(img);
Expand Down
27 changes: 11 additions & 16 deletions citm_desvj_project_template-L07/Game/Source/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,24 +428,19 @@ Properties::Property* Properties::GetProperty(const char* name)
return p;
}

/*
bool Map::Parallax() {

//// L05: DONE 9: Complete the draw function
//int gid = mapLayerItem->data->Get(x, y);
//bool Map::Parallax(TileSet* tileset_, float x) {
//
// bool ret = true;
//
// /*app->render->DrawTexture(tileset_->texture,
// pos.x - app->render->camera.x * x,
// pos.y,
// &r);*/
//
// return ret;
//}

//TileSet* tileset = GetTilesetFromTileId(gid);
//SDL_Rect r = tileset->GetTileRect(gid);
//iPoint pos = MapToWorld(x, y);
//app->render->DrawTexture(tileset->texture,
// pos.x,
// pos.y,
// &r);
}
*/

bool Map::CreateColliders()
{
Expand Down
2 changes: 1 addition & 1 deletion citm_desvj_project_template-L07/Game/Source/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Map : public Module
// L06: DONE 6: Load a group of properties
bool LoadProperties(pugi::xml_node& node, Properties& properties);

bool Parallax();
bool Parallax(TileSet* tileset_, float x);

bool CreateColliders();

Expand Down
10 changes: 9 additions & 1 deletion citm_desvj_project_template-L07/Game/Source/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,20 @@ class Module

}

void Enable() {
/*void Enable() {
if (!active)
{
active = true;
Start();
}
}*/

void Enable() {
if (!active)
{
active = true;
Awake(node);
}
}

void Disable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool ModuleFadeToBlack::Update(float dt)

// Render the black square with alpha on the screen
SDL_SetRenderDrawColor(app->render->renderer, 0, 0, 0, (Uint8)(fadeRatio * 255.0f));
LOG("%f", fadeRatio);
//LOG("%f", fadeRatio);


return true;
Expand Down
10 changes: 3 additions & 7 deletions citm_desvj_project_template-L07/Game/Source/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ bool Scene::Start()
app->physics->Enable();
app->entityManager->Enable();
app->map->Enable();
LOG("--STARTS GAME SCENE--");

// L03: DONE: Load map
app->map->Load();

Expand Down Expand Up @@ -151,13 +153,7 @@ bool Scene::PostUpdate()
// Called before quitting
bool Scene::CleanUp()
{
LOG("Freeing scene");
app->scene->Disable();
app->entityManager->Disable();
//app->physics->Disable();
app->map->Disable();
player->Disable();
app->endingscreen->Enable();
LOG("Freeing GAME SCENE");

return true;
}
Expand Down
11 changes: 9 additions & 2 deletions citm_desvj_project_template-L07/Game/Source/TitleScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "Entity.h"
#include "Physics.h"
#include "EntityManager.h"
#include "Scene.h"
#include "Map.h"
#include "ModuleFadeToBlack.h"

#include "SDL/include/SDL_render.h"
Expand Down Expand Up @@ -37,7 +39,12 @@ bool TitleScreen::Awake(pugi::xml_node& config)
// Called before the first frame
bool TitleScreen::Start()
{
/*app->map->Disable();
app->entityManager->Disable();
app->scene->Disable();
app->physics->Disable();*/

LOG("--STARTS TITLE SCENE--");
img = app->tex->Load("Assets/Textures/TitleScreen.png");

// Music
Expand All @@ -61,7 +68,7 @@ bool TitleScreen::Update(float dt)


if (app->input->GetKey(SDL_SCANCODE_RETURN) == KEY_DOWN) {
LOG("PASA A OTRA PUTA ESCENA");
LOG("PASA A GAME SCENE");
app->fade->FadeToBlack(this, (Module*)app->scene, 90);
app->audio->PlayFx(startSFX);
}
Expand All @@ -85,7 +92,7 @@ bool TitleScreen::PostUpdate()
// Called before quitting
bool TitleScreen::CleanUp()
{
LOG("Freeing scene");
LOG("Freeing TITLE SCENE");

if (img != nullptr) {
app->tex->UnLoad(img);
Expand Down
6 changes: 3 additions & 3 deletions citm_desvj_project_template-L07/Output/save_game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<textures />
<audio />
<fade />
<LogoScreen />
<TitleScreen />
<:anonymous />
<scene />
<entitymanager />
<LogoScreen />
<TitleScreen />
<map />
<EndingScreen />
<renderer>
<camera x="-13" y="0" />
<camera x="0" y="0" />
</renderer>
</save_state>

0 comments on commit 5f38720

Please sign in to comment.