-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.cpp
More file actions
76 lines (64 loc) · 1.49 KB
/
Bullet.cpp
File metadata and controls
76 lines (64 loc) · 1.49 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "Bullet.h"
#include <iostream>
using namespace std;
Bullet::Bullet(){
posx = 0;
posy = 0;
state = false;
}
Bullet::Bullet(int x, int y){
posx = x;
posy = y;
}
void Bullet::draw(SDL_Plotter &g){
for(int j = 0; j < 6; j++){
for(int i = 0; i < 16; i++){
if (pic[i][j] == 'B'){
//its black
}else if(pic[i][j] == 'R'){
g.plotPixel(j + posx, i + posy, 255, 0, 0);
//g.plotPixel(j + posx, i + 700, 255, 255, 255);
}else if(pic[i][j] == 'W'){
g.plotPixel(j + posx, i + posy, 255, 255, 255);
//g.plotPixel(j + posx, i + 700, 255, 255, 255);
}else if(pic[i][j] == 'Q'){
g.plotPixel(j + posx, i + posy, 0, 0, 255);
//g.plotPixel(j + posx, i + 700, 255, 255, 255);
}
}
}
}
void Bullet::setX(int x){
posx = x;
}
void Bullet::setY(int y){
posy = y;
}
int Bullet::getX(){
return posx;
}
int Bullet::getY(){
return posy;
}
void Bullet::eraseShip(SDL_Plotter &g){
for(int i = 0; i < 6; i++){
for(int j = 0; j < 16; j++){
g.plotPixel(posx + i, posy + j, 0, 0, 0);
}
}
}
void Bullet::destroy(SDL_Plotter &g){
eraseShip(g);
posx = 1;
posy = 1;
eraseShip(g);
setState(false);
}
Bullet::~Bullet(){
}
bool Bullet::getState(){
return state;
}
void Bullet::setState(bool a){
state = a;
}