-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpistol.cpp
More file actions
57 lines (47 loc) · 765 Bytes
/
pistol.cpp
File metadata and controls
57 lines (47 loc) · 765 Bytes
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
50
51
52
53
54
55
56
57
/* pistol(int, int);
void reload();
void shoot();
Gun(int, int);
virtual void reload() = 0;
virtual void shoot() = 0;
int xpos;
int ypos;
protected:
QRect gunRect;
QImage gunImage;
int bullets;
int magazines;
int damage;
int speed;
*/
#include "pistol.h"
#include <iostream>
Pistol::Pistol(int xpos, int ypos) : Gun(xpos, ypos)
{
this->bullets = 12;
this->magazines = 4;
this->damage = 2;
this->speed = 3;
this->maxMagazines = 4;
this->maxBullets = 12;
this->weight = 1;
gunImage.load("pistol.png");
gunRect = gunImage.rect();
}
void Pistol::reload()
{
if (magazines > 0)
{
magazines--;
bullets = maxBullets;
}
}
bool Pistol::shoot()
{
if (bullets > 0)
{
bullets--;
return 1;
}
else return 0;
}