aboutsummaryrefslogtreecommitdiffstats
path: root/src/items.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/items.cpp')
-rw-r--r--src/items.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/items.cpp b/src/items.cpp
index 99c143b..6c65b59 100644
--- a/src/items.cpp
+++ b/src/items.cpp
@@ -69,29 +69,30 @@ int Sword::useItem()
if (hitbox.end.x > e->loc.x && hitbox.end.x < e->loc.x + e->width) {
if (hitbox.end.y > e->loc.y && hitbox.end.y < e->loc.y + e->height) {
- e->takeHit(damage, 600);
+ if (e->type == MOBT)
+ Mobp(e)->onHit(damage);
+ else
+ e->takeHit(damage, 600);
- static GLuint sColor = Texture::genColor(Color(255,0,0));
-
- GLfloat t[] = {0.0, 0.0,
- 1.0, 1.0};
-
- GLfloat v[] = {hitbox.start.x, hitbox.start.y, 1.0,
- hitbox.end.x, hitbox.end.y, 1.0};
+ static GLuint sColor = Texture::genColor(Color(255,0,0));
+ GLfloat t[] = {0.0, 0.0,
+ 1.0, 1.0};
+ GLfloat v[] = {hitbox.start.x, hitbox.start.y, 1.0,
+ hitbox.end.x, hitbox.end.y, 1.0};
- glBindTexture(GL_TEXTURE_2D, sColor);
- glUseProgram(worldShader);
- glEnableVertexAttribArray(worldShader_attribute_coord);
- glEnableVertexAttribArray(worldShader_attribute_tex);
+ glBindTexture(GL_TEXTURE_2D, sColor);
+ glUseProgram(worldShader);
+ glEnableVertexAttribArray(worldShader_attribute_coord);
+ glEnableVertexAttribArray(worldShader_attribute_tex);
- glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, v);
- glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, t);
- glDrawArrays(GL_LINES, 0, 2);
+ glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, v);
+ glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, t);
+ glDrawArrays(GL_LINES, 0, 2);
- glDisableVertexAttribArray(worldShader_attribute_coord);
- glDisableVertexAttribArray(worldShader_attribute_tex);
- glUseProgram(0);
+ glDisableVertexAttribArray(worldShader_attribute_coord);
+ glDisableVertexAttribArray(worldShader_attribute_tex);
+ glUseProgram(0);
// add some blood
// for(int r = 0; r < (rand()%5);r++)
// currentWorld->addParticle(rand()%game::HLINE*3 + e->loc.x - .05f,e->loc.y + e->height*.5, game::HLINE,game::HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000);