-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemigo3.cpp
More file actions
84 lines (75 loc) · 1.67 KB
/
Enemigo3.cpp
File metadata and controls
84 lines (75 loc) · 1.67 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
77
78
79
80
81
82
83
84
#include "Enemigo3.h"
Enemigo3::Enemigo3()
{
this->x=150;
this->y=425;
this->tiempo=0;
this->cuadro_actual=0;
this->para_adelante=false;
sprites.push_back(IMG_Load("Assests/enemigo3/emenigo3_1.png"));
sprites.push_back(IMG_Load("Assests/enemigo3/emenigo3_2.png"));
sprites.push_back(IMG_Load("Assests/enemigo3/emenigo3_3.png"));
sprites.push_back(IMG_Load("Assests/enemigo3/emenigo3_4.png"));
}
Enemigo3::~Enemigo3()
{
//dtor
}
int Enemigo3::atacar(Personaje*personaje){
if (personaje->x+30==x&&personaje->y+25>y&&personaje->y+25<y+60){
personaje->x=0;
personaje->y=435;
reset();
return -1;
}else if (personaje->x-10==x&&personaje->y+25>y&&personaje->y+25<y+60){
personaje->x=0;
personaje->y=435;
reset();
return -1;
}else if (personaje->x+18>x&&personaje->x<x+40&&personaje->y==y+50){
personaje->x=0;
personaje->y=435;
reset();
return -1;
}
return 0;
}
int Enemigo3::recibir_ataque(Personaje*personaje){
if (personaje->x+18>x&&personaje->x+18<x+40&&personaje->y+40==y){
return 10;
}else
return 0;
}
void Enemigo3::logica(){
tiempo++;
if (para_adelante==false){
x--;
cuadro_actual=0;
}else if (para_adelante==true){
cuadro_actual=2;
x++;
}
if (tiempo==10){
cuadro_actual++;
if (para_adelante==false){
if (cuadro_actual==0)
cuadro_actual=1;
}else if (para_adelante==true){
if (cuadro_actual==2)
cuadro_actual=3;
}
tiempo=0;
}
if (x==0||x==-200){
para_adelante=true;
}else if (x==150||x==-50){
para_adelante=false;
}
}
void Enemigo3::reset(){
this->x=150;
this->y=425;
this->tiempo=0;
this->cuadro_actual=0;
this->para_adelante=false;
}