diff --git a/Resources/animations/bubble_anim.xml b/Resources/animations/bubble_anim.xml
index d5c71bb..a2b7efd 100644
--- a/Resources/animations/bubble_anim.xml
+++ b/Resources/animations/bubble_anim.xml
@@ -1,6 +1,8 @@
+
diff --git a/Resources/animations/character_anims.xml b/Resources/animations/character_anims.xml
new file mode 100644
index 0000000..98bcd3f
--- /dev/null
+++ b/Resources/animations/character_anims.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/animations/machine_gun_anim.xml b/Resources/animations/machine_gun_anim.xml
index 3ce6e89..dba9320 100644
--- a/Resources/animations/machine_gun_anim.xml
+++ b/Resources/animations/machine_gun_anim.xml
@@ -1,3 +1,4 @@
+
diff --git a/Resources/animations/object_anims.xml b/Resources/animations/object_anims.xml
new file mode 100644
index 0000000..b9b5749
--- /dev/null
+++ b/Resources/animations/object_anims.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/Resources/animations/pistol_anim.xml b/Resources/animations/pistol_anim.xml
index c0450d6..8d2c786 100644
--- a/Resources/animations/pistol_anim.xml
+++ b/Resources/animations/pistol_anim.xml
@@ -1,3 +1,4 @@
+
diff --git a/Resources/animations/player_anim.xml b/Resources/animations/player_anim.xml
deleted file mode 100644
index 0b375f9..0000000
--- a/Resources/animations/player_anim.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- 7
-
-
-
-
- 5
-
-
-
diff --git a/Resources/animations/shot_gun_anim.xml b/Resources/animations/shotgun_anim.xml
similarity index 95%
rename from Resources/animations/shot_gun_anim.xml
rename to Resources/animations/shotgun_anim.xml
index 55c75c1..0601b58 100644
--- a/Resources/animations/shot_gun_anim.xml
+++ b/Resources/animations/shotgun_anim.xml
@@ -1,3 +1,4 @@
+
diff --git a/Resources/animations/tmp_enemy_anim.xml b/Resources/animations/tmp_enemy_anim.xml
index 68500ec..139959f 100644
--- a/Resources/animations/tmp_enemy_anim.xml
+++ b/Resources/animations/tmp_enemy_anim.xml
@@ -1,6 +1,8 @@
+
diff --git a/Resources/animations/weapon_anims.xml b/Resources/animations/weapon_anims.xml
new file mode 100644
index 0000000..1d1ab6f
--- /dev/null
+++ b/Resources/animations/weapon_anims.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/scenes/debugScene.xml b/Resources/scenes/debugScene.xml
index 2ba1a06..50b4ad8 100644
--- a/Resources/scenes/debugScene.xml
+++ b/Resources/scenes/debugScene.xml
@@ -3,19 +3,19 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/Resources/soundeffects/big_boom.ogg b/Resources/sounds/gun/big_boom.ogg
similarity index 100%
rename from Resources/soundeffects/big_boom.ogg
rename to Resources/sounds/gun/big_boom.ogg
diff --git a/Resources/soundeffects/small_pew.ogg b/Resources/sounds/gun/small_pew.ogg
similarity index 100%
rename from Resources/soundeffects/small_pew.ogg
rename to Resources/sounds/gun/small_pew.ogg
diff --git a/Resources/sounds/gun_effects.xml b/Resources/sounds/gun_effects.xml
new file mode 100644
index 0000000..ce9f250
--- /dev/null
+++ b/Resources/sounds/gun_effects.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/weapons/bubblegun.xml b/Resources/weapons/bubblegun.xml
index 7ca7761..bbd670d 100644
--- a/Resources/weapons/bubblegun.xml
+++ b/Resources/weapons/bubblegun.xml
@@ -1,8 +1,8 @@
-
-
+
+
60
20.0
250.0
@@ -11,9 +11,9 @@
-
+
-
+
@@ -26,8 +26,8 @@
-
-
+
+
@@ -40,8 +40,8 @@
-
-
+
+
diff --git a/YuppleMayham/include/gameplay/map.h b/YuppleMayham/include/gameplay/map.h
index 88a1ba4..4fdfb2b 100644
--- a/YuppleMayham/include/gameplay/map.h
+++ b/YuppleMayham/include/gameplay/map.h
@@ -16,7 +16,7 @@ struct TileSetData;
class Map : public Drawable
{
public:
- Map(std::shared_ptr mapData, const unsigned shaderID, std::shared_ptr resourceManager);
+ Map(const MapData* mapData, const unsigned shaderID, std::shared_ptr resourceManager);
const std::vector> getCollisionMap() const { return collisionMap; }
@@ -28,8 +28,8 @@ private:
size_t getTileSetIndex(int id) const;
- std::shared_ptr mapData;
- std::vector> tileSetData;
+ const MapData* mapData;
+ std::vector tileSetData;
std::vector> instanceHandles;
std::vector>> tileIds;
@@ -37,4 +37,4 @@ private:
std::vector> tileData;
};
-#endif
\ No newline at end of file
+#endif
diff --git a/YuppleMayham/include/gameplay/scene.h b/YuppleMayham/include/gameplay/scene.h
index 45d0a59..33ebd23 100644
--- a/YuppleMayham/include/gameplay/scene.h
+++ b/YuppleMayham/include/gameplay/scene.h
@@ -78,7 +78,7 @@ private:
std::shared_ptr resourceManager;
std::weak_ptr globalEventManager;
std::shared_ptr eventManager;
- std::shared_ptr sceneData;
+ const SceneData* sceneData;
};
#endif //_H_SCENE_H
diff --git a/YuppleMayham/include/gameplay/weapons/weapon.h b/YuppleMayham/include/gameplay/weapons/weapon.h
index 3dfa1ac..381b256 100644
--- a/YuppleMayham/include/gameplay/weapons/weapon.h
+++ b/YuppleMayham/include/gameplay/weapons/weapon.h
@@ -27,7 +27,7 @@ struct WeaponData;
class Weapon : public Entity, public std::enable_shared_from_this
{
public:
- Weapon(std::shared_ptr data, const unsigned weaponShaderID, const unsigned bulletShaderID, ResourceManager* resourceManager);
+ Weapon(const WeaponData* data, const unsigned weaponShaderID, const unsigned bulletShaderID, ResourceManager* resourceManager);
void setWielder(GameActor* wielder) { this->wielder = wielder; }
void toggleInfiniteAmmo() { infiniteAmmo = !infiniteAmmo; }
diff --git a/YuppleMayham/include/graphics/animation.h b/YuppleMayham/include/graphics/animation.h
index 8f3fb04..707ee0a 100644
--- a/YuppleMayham/include/graphics/animation.h
+++ b/YuppleMayham/include/graphics/animation.h
@@ -23,10 +23,11 @@ struct AnimationData;
class Animation
{
public:
- Animation(const std::shared_ptr& animData, ResourceManager* resourceManager);
+ Animation(const AnimationData* animData, ResourceManager* resourceManager);
- std::string getName() const { return animName; }
- std::string getType() const { return animType; }
+ std::string getPrefix() const { return prefix; }
+ std::string getType() const { return type; }
+ std::string getID() const { return prefix + "/" + type; }
void bind();
void draw();
@@ -34,7 +35,7 @@ public:
void play() { isPlaying = true; }
void stop() { isPlaying = false; }
- void reset() { currentFrame = 0; }
+ void reset() { currentFrame = 0; lastFrameTick = 0; elapsedTime = 0; }
const bool getPlaying() const { return isPlaying; }
const bool getDirectional() const { return isDirectional; }
@@ -43,8 +44,8 @@ public:
void setFPS(const float fps) { FPS = fps; }
private:
- std::string animName;
- std::string animType;
+ std::string prefix;
+ std::string type;
SpriteAtlas* spriteAtlas;
@@ -70,7 +71,7 @@ class AnimationSet : public std::enable_shared_from_this
{
public:
AnimationSet(const int& entityid);
- AnimationSet(const int& entityid, ResourceManager* resourceManager, std::vector> animSet);
+ AnimationSet(const int& entityid, ResourceManager* resourceManager, std::vector animSet);
AnimationSet(const int& entityid, std::unordered_map> animations);
Animation* operator [](std::string animType) { return anims[animType].get(); }
diff --git a/YuppleMayham/include/sound/soundeffect.h b/YuppleMayham/include/sound/soundeffect.h
index fe54781..8c4b4fa 100644
--- a/YuppleMayham/include/sound/soundeffect.h
+++ b/YuppleMayham/include/sound/soundeffect.h
@@ -26,13 +26,15 @@ class SoundEffect
public:
SoundEffect(const std::string& filename);
-
+ ALuint getBuffer() const { return buffer; }
+ bool isValid() const { return valid; }
~SoundEffect();
private:
bool loadFile(const std::string &filename);
ALuint buffer;
+ bool valid;
};
#endif // _H_SOUNDEFFECT_H
diff --git a/YuppleMayham/include/util.h b/YuppleMayham/include/util.h
index 28f8db7..21d9d9f 100644
--- a/YuppleMayham/include/util.h
+++ b/YuppleMayham/include/util.h
@@ -12,8 +12,26 @@ namespace UTIL
}
constexpr float INF_TIME = -99.6875f;
+ constexpr auto split = [](const std::string& s, size_t *left, size_t *right, std::string *out) {
+ if ((*right = s.find("/", *left)) != std::string::npos) {
+ if (out) {
+ *out = s.substr(*left, *right - *left);
+ }
+ *left = *right + 1;
+ } else {
+ if (out) {
+ out->append(s.substr(*left));
+ }
+ }
+ };
+
+ constexpr auto get_type = [](const std::string& id) {
+ auto pos = id.find_last_of("/");
+ return (pos != std::string::npos) ? id.substr(pos + 1) : id;
+ };
void flip_surface(SDL_Surface* surface);
+ std::string parsePrefix(const std::string& id);
class RandomGenerator
{
diff --git a/YuppleMayham/include/utility/resourcemanager.h b/YuppleMayham/include/utility/resourcemanager.h
index 2d9c480..9dae31b 100644
--- a/YuppleMayham/include/utility/resourcemanager.h
+++ b/YuppleMayham/include/utility/resourcemanager.h
@@ -5,6 +5,7 @@
#include
#include
+#include "sound/soundeffect.h"
#include "utility/xmlloader.h"
#include "graphics/shader.h"
#include "graphics/sprite.h"
@@ -40,12 +41,12 @@ public:
Background* loadBackground (const std::string& path);
std::shared_ptr loadAIScript (const std::string& path);
std::shared_ptr loadWeaponScript (const std::string& path);
+ std::shared_ptr loadWeapon (const std::string& name, const unsigned weaponShaderID, const unsigned bulletShaderID);
+ std::shared_ptr loadAnimationSet (const std::string& name, int entityid = 0);
const unsigned loadShader (const std::string& name, const std::string& vertexPath, const std::string& fragPath);
- std::shared_ptr loadWeapon (const std::string& name, const unsigned weaponShaderID, const unsigned bulletShaderID);
- std::shared_ptr loadScene (const std::string& id);
- std::shared_ptr loadAnimationSet (const std::string& name, int entityid = 0);
- std::shared_ptr loadTileSet (const std::string& name);
+ const SceneData* loadScene (const std::string& id);
+ const TileSetData* loadTileSet (const std::string& name);
// Returns a NON-OWNING pointer to a shader by ID
Shader* getShaderByID(unsigned int ID);
@@ -57,6 +58,7 @@ public:
private:
std::unordered_map> shaders;
std::unordered_map shaderIDs;
+ std::unordered_map> sounds;
std::unordered_map> sprites;
std::unordered_map> weapons;
std::unordered_map> scripts;
diff --git a/YuppleMayham/include/utility/xmlloader.h b/YuppleMayham/include/utility/xmlloader.h
index 06c7650..7016d72 100644
--- a/YuppleMayham/include/utility/xmlloader.h
+++ b/YuppleMayham/include/utility/xmlloader.h
@@ -19,7 +19,7 @@ struct EntityData {
bool animated;
int x = 0, y = 0;
std::string graphic;
- std::string weapon = "pistolGun";
+ std::string weapon = "pistol";
std::string script;
};
@@ -67,7 +67,7 @@ struct SceneData {
std::string type;
std::string bgFile;
- std::shared_ptr map;
+ const MapData* map;
std::vector entities;
};
@@ -78,7 +78,7 @@ struct WeaponData {
int maxAmmo = 512;
std::string script = "";
std::string graphic;
- std::string animSet;
+ std::string animPrefix;
bool animated = false;
float sizeX = 50.f, sizeY = 50.f;
float offsetX = 0.f, offsetY = 0.f;
@@ -89,22 +89,26 @@ struct WeaponData {
float modMin = 0.5f, modMax = 1.0f;
};
+// ID is the new tactic I've decided on.
+// Each animationable object will be given a prefix
+// denoting their type and object so /