aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-01-10 11:18:50 -0500
committerClyne Sullivan <tullivan99@gmail.com>2017-01-10 11:18:50 -0500
commitfbd59263b52a42f85453ae918f8d2ab5817bd470 (patch)
tree8f68da5b6ae4461b08d8ac2b51dde8293ab36ebc /src
parentbef28375cbaaa3f527b98b8c617fbfd5ca3a525a (diff)
help fix the particles please
Diffstat (limited to 'src')
-rw-r--r--src/particle.cpp7
-rw-r--r--src/player.cpp16
-rw-r--r--src/world.cpp6
3 files changed, 19 insertions, 10 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index 3a286c4..a8fab9d 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -46,8 +46,8 @@ void ParticleSystem::render(void)
// copy data into VBO
glBindBuffer(GL_ARRAY_BUFFER, particleVBO);
- int offset = 0;
- for (const auto& p : parts) {
+ for (unsigned int i = 0, offset = 0; i < parts.size() - 1; i++, offset += entrySize) {
+ const auto& p = parts[i];
static const auto& hl = game::HLINE;
GLfloat coords[30] = {
p.location.x, p.location.y, -1, p.color.x, p.color.y,
@@ -59,7 +59,6 @@ void ParticleSystem::render(void)
};
glBufferSubData(GL_ARRAY_BUFFER, offset, entrySize, coords);
- offset += entrySize;
}
// begin actual rendering
@@ -128,7 +127,7 @@ void ParticleSystem::update(entityx::EntityManager &en, entityx::EventManager &e
case ParticleType::SmallPoof:
if (p.velocity.x == 0) {
p.velocity.y = 0.1f;
- p.velocity.x = randGet() % 12 / 30.0f - 0.2f;
+ p.velocity.x = randGet() % 10 / 20.0f - 0.25f;
} else {
p.velocity.x += (p.velocity.x > 0) ? -0.001f : 0.001f;
p.velocity.y -= 0.0015f;
diff --git a/src/player.cpp b/src/player.cpp
index 62ff6fe..e83616d 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -6,6 +6,13 @@
#include <world.hpp>
#include <particle.hpp>
+static const char *spriteXML =
+ "<Sprite> \
+ <frame> \
+ <src limb='0' offset='0,0' size='19,15' drawOffset='0,0'>assets/cat.png</src> \
+ </frame> \
+ </Sprite>";
+
void PlayerSystem::create(void)
{
player = game::entities.create();
@@ -17,9 +24,12 @@ void PlayerSystem::create(void)
player.assign<Visible>(-0.2f);
auto sprite = player.assign<Sprite>();
- sprite->addSpriteSegment(SpriteData("assets/cat.png",
- vec2(0, 0)),
- vec2(0, 0));
+ XMLDocument xmld;
+ xmld.Parse(spriteXML);
+ auto frame = developFrame(xmld.FirstChildElement("Sprite"));
+ if (frame.size() > 0)
+ sprite->sprite = frame.at(0);
+
vec2 dim = player.component<Sprite>().get()->getSpriteSize();
float cdat[2] = {dim.x, dim.y};
player.assign<Solid>(cdat[0], cdat[1]);
diff --git a/src/world.cpp b/src/world.cpp
index b6149e8..c882256 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -338,7 +338,7 @@ void WorldSystem::load(const std::string& file)
auto sprite = entity.assign<Sprite>();
auto sprx = abcd;
auto frames = developFrame(sprx);
- if (frames.size())
+ if (frames.size() > 0)
sprite->sprite = frames.at(0);
} else if (tname == "Portal") {
entity.assign<Portal>(wxml->StrAttribute("inside"));
@@ -401,8 +401,8 @@ void WorldSystem::load(const std::string& file)
idtc = 0;
else
idtc = limbx->UnsignedAttribute("changeID");
- for (uint i = 0; i < frames.size(); i++) {
- entan->frame.push_back(std::make_pair(idtc, frames[i]));
+ for (const auto& f : frames) {
+ entan->frame.emplace_back(idtc, f);
}
limbx = limbx->NextSiblingElement();
}