-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemigo6.cpp
More file actions
85 lines (76 loc) · 1.66 KB
/
Enemigo6.cpp
File metadata and controls
85 lines (76 loc) · 1.66 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
85
#include "Enemigo6.h"
Enemigo6::Enemigo6(){
this->x=850;
this->y=0;
this->tiempo=0;
this->cuadro_actual=0;
this->para_adelante=false;
sprites.push_back(IMG_Load("Assests/enemigo6/enemigo6_1.png"));
sprites.push_back(IMG_Load("Assests/enemigo6/enemigo6_2.png"));
sprites.push_back(IMG_Load("Assests/enemigo6/enemigo6_3.png"));
sprites.push_back(IMG_Load("Assests/enemigo6/enemigo6_4.png"));
}
Enemigo6::~Enemigo6()
{
//dtor
}
int Enemigo6::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+60&&personaje->y==y+50){
personaje->x=0;
personaje->y=435;
reset();
return -1;
}
return 0;
}
int Enemigo6::recibir_ataque(Personaje*personaje){
if (personaje->x+18>x&&personaje->x+18<x+60&&personaje->y+40==y){
return 10;
}else
return 0;
}
void Enemigo6::logica(){
tiempo++;
if (para_adelante==true){
x++;
y--;
cuadro_actual=0;
}else if (para_adelante==false){
cuadro_actual=2;
x--;
y++;
}
if (tiempo==10){
cuadro_actual++;
if (para_adelante==true){
if (cuadro_actual==0)
cuadro_actual=1;
}else if (para_adelante==false){
if (cuadro_actual==2)
cuadro_actual=3;
}
tiempo=0;
}
if (y==250){
para_adelante=true;
}else if (y==0){
para_adelante=false;
}
}
void Enemigo6::reset(){
this->x=900;
this->y=0;
this->tiempo=0;
this->cuadro_actual=0;
this->para_adelante=true;
}