summary refs log tree commit diff
path: root/src/hvy_guns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hvy_guns.c')
-rw-r--r--src/hvy_guns.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/hvy_guns.c b/src/hvy_guns.c
index 43fd1f1..1eabbe2 100644
--- a/src/hvy_guns.c
+++ b/src/hvy_guns.c
@@ -11,7 +11,7 @@
 
 #define HVY_SHOTGUN_RELOAD 150
 
-#define HVY_REPEATER_RELOAD 60
+#define HVY_REPEATER_RELOAD 120
 #define HVY_REPEATER_ROUNDS 3
 
 #define HVY_CHAINGUN_RELOAD 30
@@ -19,6 +19,29 @@
 
 static int bullet_update(struct projectile *self) {
 	self->x += self->velocity.x;
+	self->y += self->velocity.y;
+	if (collision_solid(tilemap_tile(tilemap, from_fixed(self->x), from_fixed(self->y)))) {
+		return 1;
+	}
+
+	self->hp--;
+	int x = from_fixed(self->x);
+	int y = from_fixed(self->y);
+	self->hitbox = (struct hitbox) {.left = x, .right = x, .top = y, .bottom = y};
+	if (hitbox_overlap(self->hitbox, entities.player[0].hitbox)) {
+		if (entities.player[0].hurt(entities.player + 0, (struct damage) {1, 60})) {
+			//return 1;
+		}
+	}
+	if (self->hp == 0) {
+		return 1;
+		self->state = 0;
+	}
+	return 0;
+}
+
+static int bouncy_bullet_update(struct projectile *self) {
+	self->x += self->velocity.x;
 	if (collision_solid(tilemap_tile(tilemap, from_fixed(self->x), from_fixed(self->y)))) {
 		self->velocity.x = -self->velocity.x;
 		self->x += self->velocity.x;
@@ -144,7 +167,7 @@ int hvy_blaster(struct gun *self, struct entity *parent, struct entity *target)
 	}
 	if (target != NULL) {
 		entities.projectile[entities.projectiles] = (struct projectile) {
-			.update = bullet_update,
+			.update = bouncy_bullet_update,
 			.draw = bullet_draw,
 			.free = bullet_free,
 			.x = POS_X, .y = POS_Y,