float g; /**< The gravity constant, how fast the object falls */
};
+/**
+ * @struct Grounded
+ * @brief Places an entity without physics on the ground.
+ * This is used so we don't have to update the physics of a non-moving object every loop.
+ */
+struct Grounded {
+ //TODO possibly make a way to change this
+ bool grounded = false;
+};
+
/**
* @struct Health
* @brief Gives and entity health and stuff.
};
//TODO
-
struct Input {
};
void main(){
vec4 pixelColor = texture2D(sampler, vec2(texCoord.x, texCoord.y));
//TODO
- if (pixelColor.w != 1.0f)
- discard;
+ //if (pixelColor.w != 1.0f)
+ // discard;
gl_FragColor = pixelColor * color;
}
en.each<Visible, Position, Solid, Name>([](entityx::Entity e, Visible &v, Position &pos, Solid& dim, Name &name) {
(void)e;
(void)v;
+ ui::setFontZ(-5.0);
ui::putStringCentered(pos.x + dim.width / 2, pos.y - ui::fontSize - HLINES(0.5), name.name);
});
}
void Engine::update(entityx::TimeDelta dt)
{
systems.update<InputSystem>(dt);
- //systems.update<PhysicsSystem>(dt);
systems.update<MovementSystem>(dt);
systems.update<WorldSystem>(dt);
systems.update<PlayerSystem>(dt);
void setFontSize(unsigned int size) {
(void)size;
- /*if (size == 16) {
+ if (size == 16) {
if (!ft16loaded) {
loadFontSize(fontSize = size, ftex16, ftdat16);
ft16loaded = true;
ftex = &ftex24;
ftdat = &ftdat24;
fontSize = 24;
- }*/
+ }
}
/*
* Draw the character:
*/
+
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,(*ftex)[c-33]);
glUniform1i(Render::textShader.uniform[WU_texture], 0);
+ glUniform4f(Render::textShader.uniform[WU_tex_color], 1.0f, 1.0f, 1.0f, 1.0f);
//glDisable(GL_DEPTH_TEST);
entity.assign<Physics>(g);
} else if (tname == "Name") {
entity.assign<Name>(coalesce(wxml->Attribute("name"), abcd->Attribute("value")));
+ } else if (tname == "Grounded") {
+ entity.assign<Grounded>();
}
abcd = abcd->NextSiblingElement();
void WorldSystem::detect(entityx::TimeDelta dt)
{
+ game::entities.each<Grounded, Position, Solid>(
+ [&](entityx::Entity e, Grounded &g, Position &loc, Solid &dim) {
+ (void)e;
+ if (!g.grounded) {
+ // get the line the entity is on
+ int line = std::clamp(static_cast<int>((loc.x + dim.width / 2 - world.startX) / game::HLINE),
+ 0,
+ static_cast<int>(world.data.size()));
+
+ // make sure entity is above ground
+ const auto& data = world.data;
+ if (loc.y != data[line].groundHeight) {
+ loc.y = data[line].groundHeight;
+ e.remove<Grounded>();
+ }
+ }
+
+ });
+
game::entities.each<Direction, Physics>(
[&](entityx::Entity e, Direction &vel, Physics &phys) {
(void)e;
<Sprite image="assets/style/classic/house1.png" />
<Portal />
<Solid />
+ <Grounded />
</structure>
<chest>
<Visible value="0.15" />
<Sprite image="assets/chest.png" />
<Solid />
+ <Grounded />
</chest>