targetx = dest_x;
}
-Player::Player() : Entity()
+Player::Player() : Entity()
{
width = HLINES(10);
height = HLINES(16);
loc.x, loc.y + height + game::HLINE * 2, z,
loc.x, loc.y + height, z,
};
-
+
glBindTexture(GL_TEXTURE_2D, backH);
GLfloat tex[] = { 0.0, 0.0,
1.0, 0.0,
1.0, 1.0,
-
+
1.0, 1.0,
0.0, 1.0,
0.0, 0.0,
// save the associated XMLElement
dopt.push_back(oxml);
} while ((oxml = oxml->NextSiblingElement()));
-
+
// run the dialog stuff
ui::dialogBox(name, optstr, false, ptr);
ui::waitForDialog();
index = Texture::getIndex(c);
}
-void Particles::draw(std::vector<GLfloat> &verts, std::vector<GLfloat> &tex) const
+void Particles::draw(std::vector<GLfloat> &p) const
{
vec2 tc = vec2 {0.25f * index.x, 0.125f * (8-index.y)};
if (behind)
z = 2.0;
- verts.push_back(loc.x);
- verts.push_back(loc.y);
- verts.push_back(z);
+ // lower left
+ p.push_back(loc.x);
+ p.push_back(loc.y);
+ p.push_back(z);
+
+ p.push_back(tc.x);
+ p.push_back(tc.y);
+
+ // lower right
+ p.push_back(loc.x + width);
+ p.push_back(loc.y);
+ p.push_back(z);
+
+ p.push_back(tc.x);
+ p.push_back(tc.y);
+
+ // upper right
+ p.push_back(loc.x + width);
+ p.push_back(loc.y + height);
+ p.push_back(z);
+
+ p.push_back(tc.x);
+ p.push_back(tc.y);
- verts.push_back(loc.x + width);
- verts.push_back(loc.y);
- verts.push_back(z);
-
- verts.push_back(loc.x + width);
- verts.push_back(loc.y + height);
- verts.push_back(z);
+ // upper right
+ p.push_back(loc.x + width);
+ p.push_back(loc.y + height);
+ p.push_back(z);
+ p.push_back(tc.x);
+ p.push_back(tc.y);
- verts.push_back(loc.x + width);
- verts.push_back(loc.y + height);
- verts.push_back(z);
+ // upper left
+ p.push_back(loc.x);
+ p.push_back(loc.y + height);
+ p.push_back(z);
- verts.push_back(loc.x);
- verts.push_back(loc.y + height);
- verts.push_back(z);
+ p.push_back(tc.x);
+ p.push_back(tc.y);
- verts.push_back(loc.x);
- verts.push_back(loc.y);
- verts.push_back(z);
+ // lower left
+ p.push_back(loc.x);
+ p.push_back(loc.y);
+ p.push_back(z);
- for (int i = 0; i < 6; i++){
- tex.push_back(tc.x);
- tex.push_back(tc.y);
- }
+ p.push_back(tc.x);
+ p.push_back(tc.y);
}
void Particles::update(float _gravity, float ground_y)
glEnableVertexAttribArray(worldShader_attribute_coord);
glEnableVertexAttribArray(worldShader_attribute_tex);
- std::vector<GLfloat> partc(0);
- std::vector<GLfloat> partt(0);
+ uint ps = particles.size();
+
+ std::vector<GLfloat> partVec;
+ partVec.reserve(ps * 6 * 5);
for (auto &p : particles) {
- if (p.behind)
- p.draw(partc, partt);
+ if (!p.behind)
+ p.draw(partVec);
}
- glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, &partc[0]);
- glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, &partt[0]);
- glDrawArrays(GL_TRIANGLES, 0, partc.size()/3);
+ glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[0]);
+ glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[3]);
+ glDrawArrays(GL_TRIANGLES, 0, ps * 6);
glDisableVertexAttribArray(worldShader_attribute_tex);
glDisableVertexAttribArray(worldShader_attribute_coord);
glEnableVertexAttribArray(worldShader_attribute_coord);
glEnableVertexAttribArray(worldShader_attribute_tex);
- partc.clear();
- partt.clear();
+ partVec.clear();
+ partVec.reserve(ps * 6 * 5);
for (auto &p : particles) {
if (!p.behind)
- p.draw(partc, partt);
+ p.draw(partVec);
}
- glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, &partc[0]);
- glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, &partt[0]);
- glDrawArrays(GL_TRIANGLES, 0, partc.size()/3);
+ glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[0]);
+ glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[3]);
+ glDrawArrays(GL_TRIANGLES, 0, ps * 6);
glDisableVertexAttribArray(worldShader_attribute_tex);
glDisableVertexAttribArray(worldShader_attribute_coord);
if (weather == WorldWeather::Sunny)
weather = WorldWeather::Dark;
else if (weather == WorldWeather::Dark)
- weather = WorldWeather::Sunny;
- }
+ weather = WorldWeather::Sunny;
+ }
// update player coords
p->loc.y += p->vel.y * delta;
npc.erase(std::find(std::begin(npc), std::end(npc), e));
entity.erase(std::find(std::begin(entity), std::end(entity), e));
-
+
e->loc.x = currentWorldToRight->worldStart + HLINES(15);
e->loc.y = GROUND_HEIGHT_MINIMUM;
--e->outnabout;