diff --git a/data/actors/items/diamond.ani b/data/actors/items/diamond.ani
new file mode 100644
index 0000000..d7b2d89
--- /dev/null
+++ b/data/actors/items/diamond.ani
@@ -0,0 +1,10 @@
+frames_per_row=8
+frame_width=16
+frame_height=16
+
+[animation]
+name=default
+speed=8
+loop=0
+frames=0,1,2,3,4,5,6,7
+[/animation]
\ No newline at end of file
diff --git a/data/actors/items/diamond.png b/data/actors/items/diamond.png
new file mode 100644
index 0000000..4192c56
Binary files /dev/null and b/data/actors/items/diamond.png differ
diff --git a/data/actors/moving_platform.png b/data/actors/moving_platform.png
index 02893aa..97d1849 100644
Binary files a/data/actors/moving_platform.png and b/data/actors/moving_platform.png differ
diff --git a/data/map/01.map b/data/map/01.map
index 0e5cdee..6e4b13f 100644
--- a/data/map/01.map
+++ b/data/map/01.map
@@ -33,14 +33,41 @@ tileset=moving_platform.png
animation=moving_platform.ani
width=16
height=8
-x=19
+x=20
y=14
vx=0
vy=0.3
-x1=19
+x1=20
y1=14
-x2=19
+x2=20
y2=21
[/moving platform]
+[diamond]
+tileset=diamond.png
+animation=diamond.ani
+width=16
+height=16
+x=1
+y=10
+[/diamond]
+
+[diamond]
+tileset=diamond.png
+animation=diamond.ani
+width=16
+height=16
+x=24
+y=10
+[/diamond]
+
+[diamond]
+tileset=diamond.png
+animation=diamond.ani
+width=16
+height=16
+x=25
+y=12
+[/diamond]
+
[/actors]
\ No newline at end of file
diff --git a/data/map/01.tmx b/data/map/01.tmx
index fa2dce2..a092352 100644
--- a/data/map/01.tmx
+++ b/data/map/01.tmx
@@ -14,19 +14,19 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,51,52,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,159,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,191,192,0,0,0,0,0,0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,289,290,0,0,0,0,577,578,579,580,581,582,0,0,0,0,0,0,0,0,583,584,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,239,240,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,69,70,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,366,367,367,368,0,0,0,0,0,189,190,0,0,0,0,0,0,0,0,0,0,0,101,102,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,430,431,431,432,0,0,0,0,577,578,579,580,581,582,0,0,0,0,0,0,0,0,583,584,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,189,190,0,0,0,0,0,0,0,0,0,0,615,616,69,70,0,0,0,93,94,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,189,190,0,0,0,0,0,0,0,0,0,0,189,190,101,102,0,0,0,125,126,0,0,0,0,0,0,
-263,264,0,0,0,0,0,193,194,0,0,0,0,189,190,0,0,0,0,0,0,0,281,282,277,278,279,274,280,0,0,0,157,158,0,0,0,0,0,0,
-295,296,0,0,0,0,0,225,226,0,0,0,0,189,190,0,0,281,275,275,275,275,313,314,309,310,311,312,304,0,0,0,189,190,0,0,0,0,0,0,
+363,364,0,0,0,0,0,193,194,0,0,0,0,189,190,0,0,0,0,0,0,0,362,282,277,278,279,274,364,0,0,0,157,158,0,0,0,0,0,0,
+295,396,0,0,0,0,0,225,226,0,0,0,0,189,190,0,0,362,275,275,275,275,313,314,309,310,311,312,396,0,0,0,189,190,0,0,0,0,0,0,
265,264,263,264,263,264,263,264,263,264,263,264,263,264,263,264,263,264,263,266,266,266,283,284,266,265,266,264,263,264,263,264,263,264,263,264,263,264,263,264,
295,296,295,296,295,296,295,296,295,265,295,296,295,296,295,296,295,296,295,296,295,296,315,316,298,297,298,296,295,296,295,296,295,296,295,296,295,296,295,296
diff --git a/data/map/02.tmx b/data/map/02.tmx
index 28d96c0..ee0bf55 100644
--- a/data/map/02.tmx
+++ b/data/map/02.tmx
@@ -27,8 +27,8 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-263,263,263,263,263,263,263,263,263,263,263,263,263,263,263,263,263,263,263,263,263,264,264,264,264,264,0,0,0,0,264,264,264,264,264,264,264,264,264,264,
-295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,296,296,296,296,296,0,0,0,0,296,296,296,296,296,296,296,296,296,296
+363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,364,0,0,0,0,362,363,363,363,363,363,363,363,363,363,
+295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295,296,296,296,296,396,0,0,0,0,394,296,296,296,296,296,296,296,296,296
diff --git a/data/map/03.tmx b/data/map/03.tmx
index ff9527f..f551867 100644
--- a/data/map/03.tmx
+++ b/data/map/03.tmx
@@ -3,14 +3,14 @@
-265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,0,0,0,0,265,265,265,265,265,265,265,265,265,265,
+265,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,428,0,0,0,0,426,427,427,427,427,427,427,427,427,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,577,578,579,580,581,582,0,0,0,0,0,0,0,0,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,189,190,0,0,0,0,0,0,0,0,0,0,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,189,190,0,0,0,0,0,0,0,0,0,0,265,
-265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,257,257,257,257,258,257,258,258,258,257,257,257,0,0,0,0,0,265,
+265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,369,370,370,370,370,370,370,370,370,370,370,371,0,0,0,0,0,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,265,
265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,265,
diff --git a/data/map/surface.png b/data/map/surface.png
index a7ac088..dd97452 100644
Binary files a/data/map/surface.png and b/data/map/surface.png differ
diff --git a/data/sound/desktop.ini b/data/sound/desktop.ini
new file mode 100644
index 0000000..d957fd1
--- /dev/null
+++ b/data/sound/desktop.ini
@@ -0,0 +1,4 @@
+[ViewState]
+Mode=
+Vid=
+FolderType=Generic
diff --git a/data/sound/sound_drop_enemy.wav b/data/sound/sound_drop_enemy.wav
index e69de29..ad072c2 100644
Binary files a/data/sound/sound_drop_enemy.wav and b/data/sound/sound_drop_enemy.wav differ
diff --git a/data/sound/sound_drop_splat.wav b/data/sound/sound_drop_splat.wav
index e69de29..bbc4676 100644
Binary files a/data/sound/sound_drop_splat.wav and b/data/sound/sound_drop_splat.wav differ
diff --git a/data/sound/sound_menu_logo.wav b/data/sound/sound_menu_logo.wav
index e69de29..512e1e3 100644
Binary files a/data/sound/sound_menu_logo.wav and b/data/sound/sound_menu_logo.wav differ
diff --git a/data/sound/sound_menu_start.wav b/data/sound/sound_menu_start.wav
index e69de29..9870c1f 100644
Binary files a/data/sound/sound_menu_start.wav and b/data/sound/sound_menu_start.wav differ
diff --git a/data/sound/sound_player_coin.wav b/data/sound/sound_player_coin.wav
index e69de29..09f9ca0 100644
Binary files a/data/sound/sound_player_coin.wav and b/data/sound/sound_player_coin.wav differ
diff --git a/data/sound/sound_player_death.wav b/data/sound/sound_player_death.wav
index e69de29..aca90c8 100644
Binary files a/data/sound/sound_player_death.wav and b/data/sound/sound_player_death.wav differ
diff --git a/data/sound/sound_player_jump.wav b/data/sound/sound_player_jump.wav
index e69de29..53f0114 100644
Binary files a/data/sound/sound_player_jump.wav and b/data/sound/sound_player_jump.wav differ
diff --git a/source/actor_diamond.cpp b/source/actor_diamond.cpp
new file mode 100644
index 0000000..871e652
--- /dev/null
+++ b/source/actor_diamond.cpp
@@ -0,0 +1,13 @@
+#include "actor_diamond.h"
+#include
+#include
+
+// Constructor
+ActorDiamond::ActorDiamond(actor_t actor) : Actor(actor)
+{
+}
+
+// Destructor
+ActorDiamond::~ActorDiamond()
+{
+}
\ No newline at end of file
diff --git a/source/actor_diamond.h b/source/actor_diamond.h
new file mode 100644
index 0000000..7c71404
--- /dev/null
+++ b/source/actor_diamond.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include
+#include "actor.h"
+#include
+
+#ifndef ACTOR_DIAMOND_H
+#define ACTOR_DIAMOND_H
+
+// Clase Actor
+class ActorDiamond : public Actor
+{
+private:
+
+public:
+ // Constructor
+ ActorDiamond(actor_t actor);
+
+ // Destructor
+ ~ActorDiamond();
+
+
+};
+
+#endif
diff --git a/source/game.cpp b/source/game.cpp
index d20a047..a926fa2 100644
--- a/source/game.cpp
+++ b/source/game.cpp
@@ -193,6 +193,9 @@ void Game::renderDebugInfo()
text = "hookedOn = " + std::to_string(player->hookedOnMovingPlatform);
debugText->write(0, line += 6, text, -1);
+
+ text = "DIAMONDS = " + std::to_string(player->diamonds);
+ debugText->write(0, line += 6, text, -1);
// Pinta mascaras
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 128);
diff --git a/source/map.cpp b/source/map.cpp
index 893de6b..379c550 100644
--- a/source/map.cpp
+++ b/source/map.cpp
@@ -135,10 +135,40 @@ bool Map::load(std::string file_path)
} while (line != "[/moving platform]");
- printf("actor loaded\n");
+ printf("** actor moving platform loaded\n");
actors.push_back(new ActorMovingPlatform(actor, p1, p2));
}
+ if (line == "[diamond]")
+ {
+ actor_t actor;
+ actor.asset = asset;
+ actor.renderer = renderer;
+ actor.name = a_diamond;
+ actor.vx = 0.0f;
+ actor.vy = 0.0f;
+ SDL_Point p1, p2;
+
+ do
+ {
+ std::getline(file, line);
+
+ // Encuentra la posición del caracter '='
+ int pos = line.find("=");
+
+ // Procesa las dos subcadenas
+ if (!setActor(&actor, &p1, &p2, line.substr(0, pos), line.substr(pos + 1, line.length())))
+ {
+ printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
+ success = false;
+ }
+
+ } while (line != "[/diamond]");
+
+ printf("** actor diamond loaded\n");
+ actors.push_back(new ActorDiamond(actor));
+ }
+
} while (line != "[/actors]");
/*actor_t actor;
actor.asset = asset;
@@ -305,7 +335,7 @@ bool Map::setActor(actor_t *actor, SDL_Point *p1, SDL_Point *p2, std::string var
{
p2->y = std::stoi(value) * tile_size;
}
- else if (var == "[/moving platform]")
+ else if ((var == "[/moving platform]") || (var == "[/diamond]"))
{
}
else
@@ -554,4 +584,18 @@ int Map::getActorIncX(int index)
}
return shift;
+}
+
+// Elimina un actor
+bool Map::deleteActor(int index)
+{
+ bool success = false;
+ if (actors[index] != nullptr)
+ {
+ delete actors[index];
+ success = true;
+ }
+
+ actors.erase(actors.begin() + index);
+ return success;
}
\ No newline at end of file
diff --git a/source/map.h b/source/map.h
index 10a8a82..e4be016 100644
--- a/source/map.h
+++ b/source/map.h
@@ -5,6 +5,7 @@
#include "asset.h"
#include "const.h"
#include "actor_moving_platform.h"
+#include "actor_diamond.h"
#include
#include
#include
@@ -106,6 +107,9 @@ public:
// Devuelve el desplazamiento relativo del actor
int getActorIncX(int index);
+
+ // Elimina un actor
+ bool deleteActor(int index);
};
#endif
diff --git a/source/player.cpp b/source/player.cpp
index 0099952..343134a 100644
--- a/source/player.cpp
+++ b/source/player.cpp
@@ -41,6 +41,7 @@ Player::Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map)
collider.insert(collider.end(), {p, p, p, p, p, p, p, p, p, p, p, p});
underFeet.insert(underFeet.end(), {p, p, p});
hookedOnMovingPlatform = -1;
+ diamonds = 0;
}
// Destructor
@@ -106,6 +107,7 @@ void Player::checkInput()
vy -= jumpStrenght;
state = jumping;
jumpPressed = true;
+ JA_PlaySound(sound_jump);
}
}
else if (state == jumping)
@@ -356,6 +358,12 @@ bool Player::isOnMovingPlatform()
onMovingPlatform |= (map->getActorName(map->actorCollision(f)) == a_moving_platform);
hookedOnMovingPlatform = std::max(hookedOnMovingPlatform, (map->actorCollision(f)));
}
+
+ if (!onMovingPlatform)
+ {
+ hookedOnMovingPlatform = -1;
+ }
+
return onMovingPlatform;
}
@@ -433,5 +441,15 @@ void Player::setMap(Map *map)
int Player::checkActors()
{
SDL_Rect rect = sprite->getRect();
- return map->actorCollision(rect);
+ const int index = map->actorCollision(rect);
+ const int name = map->getActorName(index);
+
+ if (name == a_diamond)
+ {
+ diamonds++;
+ JA_PlaySound(sound_coin);
+ map->deleteActor(index);
+ }
+
+ return index;
}
\ No newline at end of file
diff --git a/source/player.h b/source/player.h
index f3f29a4..d49ffde 100644
--- a/source/player.h
+++ b/source/player.h
@@ -49,6 +49,7 @@ public:
float maxVX; // Velocidad mazima de desplazamiento horizontal
float maxVY; // Velocidad mazima de desplazamiento vertical
+ int diamonds; // Cantidad de diamantes recogidos por el jugador
std::vector key; // Indica las llaves que posee el jugador
std::vector collider; // Contiene los puntos de colisión del jugador con el mapa
std::vector underFeet; // Contiene los puntos que hay bajo cada pie del jugador
diff --git a/source/prog.cpp b/source/prog.cpp
index ee71493..06013f7 100644
--- a/source/prog.cpp
+++ b/source/prog.cpp
@@ -190,6 +190,8 @@ bool Prog::setFileList()
// Ficheros de actores
asset->add("/data/actors/moving_platform.png", bitmap);
asset->add("/data/actors/moving_platform.ani", data);
+ asset->add("/data/actors/items/diamond.png", bitmap);
+ asset->add("/data/actors/items/diamond.ani", data);
// Ficheros del logo
asset->add("/data/logo/logo.png", bitmap);
diff --git a/source/text.cpp b/source/text.cpp
index 7166f63..aa975c8 100644
--- a/source/text.cpp
+++ b/source/text.cpp
@@ -57,9 +57,9 @@ void Text::init()
offset[i].y = ((i - 32) / 15) * boxHeight;
}
- printf("Cargando %s\n", file.c_str());
- const std::string texto = "w = "+ std::to_string(boxWidth) + ", h = " + std::to_string(boxHeight);
- printf("%s\n",texto.c_str());
+ //printf("Cargando %s\n", file.c_str());
+ //const std::string texto = "w = "+ std::to_string(boxWidth) + ", h = " + std::to_string(boxHeight);
+ //printf("%s\n",texto.c_str());
}
// Escribe texto en pantalla