-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemy.cpp
More file actions
58 lines (47 loc) · 1.03 KB
/
Copy pathenemy.cpp
File metadata and controls
58 lines (47 loc) · 1.03 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
#include "enemy.h"
#include <SFML/Graphics.hpp>
#include <iostream>
Enemy::Enemy(int newX, int newY, int dif)
:side_length(CELL/4),
sides(CELL/8) {
x = newX;
y = newY;
points = dif*5;
octagon.setRadius(side_length);
octagon.setPointCount(sides);
octagon.setPosition(x,y);
octagon.setFillColor(sf::Color::Blue);
rectagle.setSize(sf::Vector2f(side_length*2, side_length/2));
rectagle.setPosition(x,y + side_length*3/2);
rectagle.setFillColor(sf::Color::Blue);
}
Enemy::~Enemy() {
}
void Enemy::Update() {
}
void Enemy::Draw(sf::RenderWindow& window) {
window.draw(octagon);
window.draw(rectagle);
}
void Enemy::Move(int dir) {
if (dir == LEFT) {
x = x - 2;
}
else if (dir == RIGHT) {
x = x + 2;
}
else if (dir == DOWN) {
y = y + CELL/4;
}
octagon.setPosition(x,y);
rectagle.setPosition(x,y + side_length*3/2);
}
int Enemy::GetY() {
return y;
}
int Enemy::GetX() {
return x;
}
int Enemy::GetPoints() {
return points;
}