Skip to content

Commit

Permalink
cleaning code 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Vizalt committed Nov 7, 2021
1 parent 6285020 commit 3c780cc
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 27 deletions.
14 changes: 5 additions & 9 deletions Assigment1/Game/Source/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ bool App::Awake()

bool ret = false;

// L01: DONE 3: Load config from XML

config = LoadConfig(configFile);

if (config.empty() == false)
{
ret = true;
configApp = config.child("app");

// L01: DONE 4: Read the title from the config file

title.Create(configApp.child("title").child_value());
organization.Create(configApp.child("organization").child_value());
}
Expand All @@ -97,10 +97,7 @@ bool App::Awake()

while ((item != NULL) && (ret == true))
{
// L01: DONE 5: Add a new argument to the Awake method to receive a pointer to an xml node.
// If the section with the module name exists in config.xml, fill the pointer with the valid xml_node
// that can be used to read all variables for that module.
// Send nullptr if the node does not exist in config.xml

ret = item->data->Awake(config.child(item->data->name.GetString()));
item = item->next;
}
Expand Down Expand Up @@ -169,7 +166,7 @@ void App::PrepareUpdate()
// ---------------------------------------------
void App::FinishUpdate()
{
// L02: DONE 1: This is a good place to call Load / Save methods

if (loadGameRequested == true) {
LoadGame();
loadGameRequested == false;
Expand Down Expand Up @@ -300,7 +297,6 @@ void App::SaveGameRequest() const
}

// ---------------------------------------
// L02: TODO 5: Create a method to actually load an xml file
// then call all the modules to load themselves
bool App::LoadGame()
{
Expand Down Expand Up @@ -328,7 +324,7 @@ bool App::LoadGame()
return ret;
}

// L02: TODO 7: Implement the xml save method for current state

bool App::SaveGame() const
{
bool ret = true;
Expand Down
5 changes: 0 additions & 5 deletions Assigment1/Game/Source/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ class App

List<Module *> modules;

// L01: DONE 2: Create new variables from pugui namespace
// NOTE: Redesigned LoadConfig() to avoid storing this variables
//pugi::xml_document configFile;
//pugi::xml_node config;
//pugi::xml_node configApp;

uint frames;
float dt;
Expand Down
2 changes: 1 addition & 1 deletion Assigment1/Game/Source/Collider.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Collider.h"

Collider::Collider(SDL_Rect rectangle, Type type, Module* listener): rect(rectangle), type(type) /*listeners(listener)*/
Collider::Collider(SDL_Rect rectangle, Type type, Module* listener): rect(rectangle), type(type)
{
listeners[0] = listener;
}
Expand Down
1 change: 0 additions & 1 deletion Assigment1/Game/Source/Collider.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct Collider
bool pendingToDelete = false;
Type type;
Module* listeners[MAX_LISTENERS] = { nullptr };
//Module* listener = nullptr;
};


Expand Down
5 changes: 2 additions & 3 deletions Assigment1/Game/Source/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Map::Draw()

while (mapLayerItem != NULL) {

if (mapLayerItem->data->properties.GetProperty("Draw") == 1)
if (mapLayerItem->data->properties.GetProperty("Draw") == 1)//dinuja solo las capas con a propiedad draw
{
for (int x = 0; x < mapLayerItem->data->width; x++)
{
Expand Down Expand Up @@ -440,7 +440,7 @@ void Map::CreateColliders() {
while (mapLayerItem != NULL) {

//suelo
if (mapLayerItem->data->properties.GetProperty("collider") == 1) {
if (mapLayerItem->data->properties.GetProperty("collider") == 1) {//crea colliders de tipo suelo con las tiles de tipo collider


for (int x = 0; x < mapLayerItem->data->width; x++) {
Expand All @@ -452,7 +452,6 @@ void Map::CreateColliders() {

if (gid > 0) {


//now we always use the firt tileset in the list
TileSet* tileset = mapData.tilesets.start->data;
/*TileSet* tileset = GetTilesetFromTileId(gid);*/
Expand Down
3 changes: 2 additions & 1 deletion Assigment1/Game/Source/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ bool Player::Start()
colliderPlayer = app->coll->AddCollider({ position.x,position.y, 16,5 }, Collider::Type::PLAYER, this);
colliderPlayerR = app->coll->AddCollider({ position.x + 16,position.y - 16, 5,12 }, Collider::Type::PLAYERRIGHT, this);
colliderPlayerL = app->coll->AddCollider({ position.x,position.y, 5,12 }, Collider::Type::PLAYERLEFT, this);
//colliderplayerR y colliderplayerL solo colisionan para las paredes

contact = false;
death = false;
Expand Down Expand Up @@ -161,7 +162,7 @@ bool Player::Update(float dt) {
{
position.y -= speed*2;
}
if ((app->input->GetKey(SDL_SCANCODE_S) == KEY_REPEAT) && /*(sidesL == false || sidesR == false) &&*/ contact == false && god == true)
if ((app->input->GetKey(SDL_SCANCODE_S) == KEY_REPEAT) && contact == false && god == true)
{
position.y += speed;
}
Expand Down
7 changes: 2 additions & 5 deletions Assigment1/Game/Source/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,9 @@ bool Render::PreUpdate()

bool Render::Update(float dt)
{
//camera follows player
if(app->scene->currentScene==SCENE){
/*camera.x = ((app->player->position.x - app->player->position.x * 2) * 5) + (app->win->screenSurface->w / 2 - 24 * 5);
camera.y = ((app->player->position.y - app->player->position.y * 2) * 5) + (app->win->screenSurface->h / 2 - 24 * 5);
*/
/*camera.x =-(app->player->position.x + app->win->screenSurface->w/5);
camera.y = -(app->player->position.y + app->win->screenSurface->h/5);*/

camera.x = (-app->player->position.x)* 5 + app->win->screenSurface->w / 2 -30;
camera.y = (-app->player->position.y* 5) + app->win->screenSurface->h / 3;
}
Expand Down
1 change: 0 additions & 1 deletion Assigment1/Game/Source/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ bool Scene::Awake()
bool Scene::Start()
{

// L03: DONE: Load map
app->map->Load("level1.tmx");

app->map->CreateColliders();
Expand Down
2 changes: 1 addition & 1 deletion Assigment1/Output/save_game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<audio />
<scene />
<renderer>
<position x="162" y="275" />
<position x="114" y="20" />
</renderer>
</game_state>

0 comments on commit 3c780cc

Please sign in to comment.