From c12fcf8e7663c20e2c2c0696fb35a7059b83127a Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Tue, 8 Mar 2011 15:14:57 +0000 Subject: Implement weapons --- Shotgun.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Shotgun.cpp (limited to 'Shotgun.cpp') diff --git a/Shotgun.cpp b/Shotgun.cpp new file mode 100644 index 0000000..a265c26 --- /dev/null +++ b/Shotgun.cpp @@ -0,0 +1,24 @@ +#include "Shotgun.h" + +Shotgun::Shotgun() { + damage = 20; + speed = 5; + size = 1; + curProjectile = 0; + setImage("weapons.png"); + setClip(0, 100, 0, 100, 50); +} + +void Shotgun::attack() { + // Shoots 3 bullets in a row + for (int i = 0; i < 3; i++) { + projectiles[curProjectile].setX(getX() + 50); + projectiles[curProjectile].setY(getY() - 50 + (i * 30)); + projectiles[curProjectile].setActive(true); + if (curProjectile < 9) { + curProjectile++; + } else { + curProjectile = 0; + } + } +} -- cgit v1.2.3