-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSho.cpp
More file actions
106 lines (87 loc) · 3.71 KB
/
Sho.cpp
File metadata and controls
106 lines (87 loc) · 3.71 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "Sho.h"
Sho::Sho(SDL_Renderer* renderer,list<Personaje*> *personajes)
{
mapa_texturas["left"] = new vector<SDL_Texture*>();
mapa_texturas["right"] = new vector<SDL_Texture*>();
mapa_texturas["walk_right"] = new vector<SDL_Texture*>();
mapa_texturas["walk_left"] = new vector<SDL_Texture*>();
mapa_texturas["punch_right"] = new vector<SDL_Texture*>();
mapa_texturas["punch_left"] = new vector<SDL_Texture*>();
mapa_texturas["right"]->push_back(IMG_LoadTexture(renderer,"Sho/standing/1.png"));
mapa_texturas["right"]->push_back(IMG_LoadTexture(renderer,"Sho/standing/2.png"));
mapa_texturas["right"]->push_back(IMG_LoadTexture(renderer,"Sho/standing/3.png"));
mapa_texturas["right"]->push_back(IMG_LoadTexture(renderer,"Sho/standing/4.png"));
mapa_texturas["left"]->push_back(IMG_LoadTexture(renderer,"Sho/standing_left/1.png"));
mapa_texturas["left"]->push_back(IMG_LoadTexture(renderer,"Sho/standing_left/2.png"));
mapa_texturas["left"]->push_back(IMG_LoadTexture(renderer,"Sho/standing_left/3.png"));
mapa_texturas["left"]->push_back(IMG_LoadTexture(renderer,"Sho/standing_left/4.png"));
mapa_texturas["walk_right"]->push_back(IMG_LoadTexture(renderer,"Sho/walk/1.png"));
mapa_texturas["walk_right"]->push_back(IMG_LoadTexture(renderer,"Sho/walk/2.png"));
mapa_texturas["walk_right"]->push_back(IMG_LoadTexture(renderer,"Sho/walk/3.png"));
mapa_texturas["walk_right"]->push_back(IMG_LoadTexture(renderer,"Sho/walk/4.png"));
mapa_texturas["walk_right"]->push_back(IMG_LoadTexture(renderer,"Sho/walk/5.png"));
mapa_texturas["walk_left"]->push_back(IMG_LoadTexture(renderer,"Sho/walk_left/1.png"));
mapa_texturas["walk_left"]->push_back(IMG_LoadTexture(renderer,"Sho/walk_left/2.png"));
mapa_texturas["walk_left"]->push_back(IMG_LoadTexture(renderer,"Sho/walk_left/3.png"));
mapa_texturas["walk_left"]->push_back(IMG_LoadTexture(renderer,"Sho/walk_left/4.png"));
mapa_texturas["walk_left"]->push_back(IMG_LoadTexture(renderer,"Sho/walk_left/5.png"));
mapa_texturas["punch_right"]->push_back(IMG_LoadTexture(renderer,"Sho/punch/1.png"));
mapa_texturas["punch_right"]->push_back(IMG_LoadTexture(renderer,"Sho/punch/2.png"));
mapa_texturas["punch_right"]->push_back(IMG_LoadTexture(renderer,"Sho/punch/3.png"));
mapa_texturas["punch_left"]->push_back(IMG_LoadTexture(renderer,"Sho/punch_left/1.png"));
mapa_texturas["punch_left"]->push_back(IMG_LoadTexture(renderer,"Sho/punch_left/2.png"));
mapa_texturas["punch_left"]->push_back(IMG_LoadTexture(renderer,"Sho/punch_left/3.png"));
vector_actual_str = "right";
rect.x = 0;
rect.y = 0;
init(renderer,personajes);
}
void Sho::act()
{
const Uint8* currentKeyStates = SDL_GetKeyboardState(NULL);
if(currentKeyStates[SDL_SCANCODE_SPACE])
{
atacando = true;
if(vector_actual_str=="walk_right" || vector_actual_str=="right")
{
setAnimacion("punch_right");
}
if(vector_actual_str=="walk_left" || vector_actual_str=="left")
{
setAnimacion("punch_left");
}
}else
{
atacando = false;
}
if(currentKeyStates[SDL_SCANCODE_W])
{
rect.y--;
}
else if(currentKeyStates[SDL_SCANCODE_S])
{
rect.y++;
}
if(currentKeyStates[SDL_SCANCODE_D])
{
rect.x++;
setAnimacion("walk_right");
}
else if(currentKeyStates[SDL_SCANCODE_Z])
{
rect.x--;
setAnimacion("walk_left");
}
else
{
if(vector_actual_str == "walk_right")
vector_actual_str = "right";
if(vector_actual_str == "walk_left")
vector_actual_str = "left";
}
attackCheck();
}
Sho::~Sho()
{
//dtor
}