-
Notifications
You must be signed in to change notification settings - Fork 0
/
oct.cpp
59 lines (48 loc) · 1 KB
/
oct.cpp
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
#include "oct.h"
#include <iostream>
using namespace std;
Oct::Oct():Mon(-1,0)
{
image.load("oct.png");
destroyed = FALSE;
reset();
rect = image.rect();
}
Oct::~Oct() {
std::cout << ("monster deleted\n");
}
void Oct::reset(){
xdir=-1;
ydir=0;
rect.moveTo(250,354);}
void Oct::autoMove()
{
rect.translate(xdir, ydir);
if (rect.left() <= 0) {
if(rect.bottom()==312||rect.bottom()==313||rect.bottom()==165||rect.bottom()==166){
xdir=1;
ydir=0;}
else if(rect.y()==354||rect.y()==355||rect.bottom()==248||rect.bottom()==249){
xdir=0;
ydir=-1;}
}
if (rect.right()>=300) {
if(rect.bottom()==312||rect.bottom()==313||rect.bottom()==165||rect.bottom()==166){
ydir=-1;
xdir = 0;}
else if(rect.y()==354||rect.y()==355||rect.bottom()==248||rect.bottom()==249){
ydir=0;
xdir=-1;}
}
}
void Oct::move(int x,int y){
rect.moveTo(x,y);//relocate the monster at (x,y)
}
bool Oct::isDestroyed()
{
return destroyed;
}
void Oct::setDestroyed(bool destr)
{
destroyed = destr;
}