summaryrefslogtreecommitdiff
path: root/Shotgun.cpp
diff options
context:
space:
mode:
authorJoe Robinson <joe@lc8n.com>2011-03-08 15:14:57 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2011-03-08 15:14:57 +0000
commitc12fcf8e7663c20e2c2c0696fb35a7059b83127a (patch)
tree67eaa0be96e058aae54e4cf16aa0735d1a7b90f2 /Shotgun.cpp
parent78cab811b677f05a6447aafe2fb8658ecb2c573b (diff)
Implement weapons
Diffstat (limited to 'Shotgun.cpp')
-rw-r--r--Shotgun.cpp24
1 files changed, 24 insertions, 0 deletions
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;
+ }
+ }
+}