blob: 9b04aa34f7023526e4815dcb20c16a22d5f818c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <iostream>
#include "Weapon.h"
#include "Projectile.h"
Weapon::Weapon() {
damage = 1;
speed = 50;
size = 1;
curProjectile = 0;
setImage("weapons.png");
setClip(0, 0, 0, 100, 50);
}
int Weapon::getDamage() {
return damage;
}
int Weapon::getSpeed() {
return speed;
}
int Weapon::getSize() {
return size;
}
void Weapon::setDamage(int damage) {
this->damage = damage;
}
void Weapon::setSpeed(int speed) {
this->speed = speed;
}
void Weapon::setSize(int size) {
this->size = size;
}
void Weapon::attack() {
// Start the projectile at the end of the gun
projectiles[curProjectile].setX(getX() + 50);
projectiles[curProjectile].setY(getY() + 10);
projectiles[curProjectile].setActive(true);
// Use 10 projectiles then re-use from the beginning
if (curProjectile < 9) {
curProjectile++;
} else {
curProjectile = 0;
}
}
|