Skip to content

Commit 55df723

Browse files
committed
funciona
1 parent a0c7c8b commit 55df723

15 files changed

+75
-66
lines changed

EnemigoAzul.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22

33
EnemigoAzul::EnemigoAzul(SDL_Renderer* renderer, list<Personaje*> *personajes)
44
{
5-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/1.png"));
6-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/2.png"));
7-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/3.png"));
8-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/4.png"));
5+
vector<SDL_Texture*>*texturas = new vector<SDL_Texture*>();
6+
vector<SDL_Texture*>*texturas_left = new vector<SDL_Texture*>();
97

10-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing_left/1.png"));
11-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing_left/2.png"));
12-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing_left/3.png"));
13-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing_left/4.png"));
8+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/1.png"));
9+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/2.png"));
10+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/3.png"));
11+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/4.png"));
1412

15-
mapa_texturas["left"]=&texturas_left;
16-
mapa_texturas["right"]=&texturas;
13+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing_left/1.png"));
14+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing_left/2.png"));
15+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing_left/3.png"));
16+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing_left/4.png"));
1717

18-
textura_actual = "right";
18+
mapa_texturas["left"]=texturas_left;
19+
mapa_texturas["right"]=texturas;
20+
21+
vector_actual_str = "right";
1922

2023
rect.x = 100;
2124
rect.y = 250;

EnemigoRojo.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
EnemigoRojo::EnemigoRojo(SDL_Renderer* renderer, list<Personaje*> *personajes)
44
{
5-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/1.png"));
6-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/2.png"));
7-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/3.png"));
8-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/4.png"));
5+
vector<SDL_Texture*>*texturas = new vector<SDL_Texture*>();
6+
vector<SDL_Texture*>*texturas_left = new vector<SDL_Texture*>();
97

10-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing_left/1.png"));
11-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing_left/2.png"));
12-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing_left/3.png"));
13-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing_left/4.png"));
8+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/1.png"));
9+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/2.png"));
10+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/3.png"));
11+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/4.png"));
1412

15-
mapa_texturas["left"]=&texturas_left;
16-
mapa_texturas["right"]=&texturas;
13+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing_left/1.png"));
14+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing_left/2.png"));
15+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing_left/3.png"));
16+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing_left/4.png"));
17+
18+
mapa_texturas["left"]=texturas_left;
19+
mapa_texturas["right"]=texturas;
20+
21+
vector_actual_str = "right";
1722

18-
textura_actual = "right";
19-
2023
rect.x = 750;
2124
rect.y = 250;
2225

EnemigoVerde.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
EnemigoVerde::EnemigoVerde(SDL_Renderer* renderer, list<Personaje*> *personajes)
44
{
5-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/1.png"));
6-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/2.png"));
7-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/3.png"));
8-
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/4.png"));
5+
vector<SDL_Texture*>*texturas = new vector<SDL_Texture*>();
6+
vector<SDL_Texture*>*texturas_left = new vector<SDL_Texture*>();
97

10-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing_left/1.png"));
11-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing_left/2.png"));
12-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing_left/3.png"));
13-
texturas_left.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing_left/4.png"));
8+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/1.png"));
9+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/2.png"));
10+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/3.png"));
11+
texturas->push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/4.png"));
1412

15-
mapa_texturas["left"]=&texturas_left;
16-
mapa_texturas["right"]=&texturas;
13+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing_left/1.png"));
14+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing_left/2.png"));
15+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing_left/3.png"));
16+
texturas_left->push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing_left/4.png"));
17+
18+
mapa_texturas["left"] = texturas_left;
19+
mapa_texturas["right"] = texturas;
20+
21+
vector_actual_str = "right";
1722

18-
textura_actual = "right";
19-
2023
rect.x = 500;
2124
rect.y = 250;
2225

Personaje.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ Personaje::~Personaje()
1414

1515
void Personaje::draw(SDL_Renderer* renderer)
1616
{
17-
vector<SDL_Texture*> *vector_textura_actual_temp = mapa_texturas[textura_actual];
17+
vector<SDL_Texture*> *vector_textura_actual_temp = mapa_texturas[vector_actual_str];
1818

19-
SDL_Texture* textura_actual_temp = (*vector_textura_actual_temp)[animacion];
19+
SDL_Texture* textura_actual_temp = (*vector_textura_actual_temp)[textura_actual_int];
2020

2121
SDL_QueryTexture( textura_actual_temp, NULL, NULL, &rect.w, &rect.h);
2222

2323
SDL_RenderCopy(renderer, textura_actual_temp, NULL, &rect);
2424
if(frame%100==0)
2525
{
26-
animacion++;
27-
if(animacion>=(*vector_textura_actual_temp).size())
28-
animacion=0;
26+
textura_actual_int++;
27+
if(textura_actual_int>=(*vector_textura_actual_temp).size())
28+
textura_actual_int=0;
2929
}
3030
hitbox.x = rect.x + rect.w/2 - hitbox.w/2;
3131
hitbox.y = rect.y + rect.h - hitbox.h/2;
@@ -41,7 +41,7 @@ void Personaje::draw(SDL_Renderer* renderer)
4141
void Personaje::init(SDL_Renderer* renderer, list<Personaje*> *personajes)
4242
{
4343
frame = 0;
44-
animacion = 0;
44+
textura_actual_int = 0;
4545
hitbox_azul = IMG_LoadTexture(renderer,"hitbox/azul.png");
4646
hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png");
4747

Personaje.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ class Personaje
1313
{
1414
public:
1515
list<Personaje*> *personajes;
16-
vector<SDL_Texture*>texturas;
17-
vector<SDL_Texture*>texturas_left;
18-
vector<SDL_Texture*>texturas_right;
19-
string textura_actual;
16+
string vector_actual_str;
2017
map< string, vector<SDL_Texture*>* > mapa_texturas;
2118
SDL_Texture* hitbox_azul;
2219
SDL_Texture* hitbox_roja;
2320
SDL_Rect rect,hitbox;
2421
int frame;
25-
int animacion;
22+
int textura_actual_int;
2623
bool atacando;
2724
bool muerto;
2825

SDL2Testground.depend

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -665,27 +665,27 @@
665665
1424454928 /home/turupawn/Projects/Clases/_Progra3/Beup2/Enemigo.h
666666
"Personaje.h"
667667

668-
1424456477 /home/turupawn/Projects/Clases/_Progra3/Beup2/Personaje.h
668+
1424457589 /home/turupawn/Projects/Clases/_Progra3/Beup2/Personaje.h
669669
<SDL2/SDL.h>
670670
<SDL2/SDL_image.h>
671671
<vector>
672672
<list>
673673
<iostream>
674674
<map>
675675

676-
1424456477 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoAzul.cpp
676+
1424457769 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoAzul.cpp
677677
"EnemigoAzul.h"
678678

679679
1424454928 /home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoAzul.h
680680
"Enemigo.h"
681681

682-
1424456477 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoRojo.cpp
682+
1424457788 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoRojo.cpp
683683
"EnemigoRojo.h"
684684

685685
1424454928 /home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoRojo.h
686686
"Enemigo.h"
687687

688-
1424456477 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoVerde.cpp
688+
1424457805 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoVerde.cpp
689689
"EnemigoVerde.h"
690690

691691
1424454928 /home/turupawn/Projects/Clases/_Progra3/Beup2/EnemigoVerde.h
@@ -705,9 +705,9 @@
705705
1424454928 /home/turupawn/Projects/Clases/_Progra3/Beup2/Sho.h
706706
"Personaje.h"
707707

708-
1424456757 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/Personaje.cpp
708+
1424457537 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/Personaje.cpp
709709
"Personaje.h"
710710

711-
1424456477 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/Sho.cpp
711+
1424457823 source:/home/turupawn/Projects/Clases/_Progra3/Beup2/Sho.cpp
712712
"Sho.h"
713713

Sho.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
Sho::Sho(SDL_Renderer* renderer,list<Personaje*> *personajes)
44
{
5-
texturas.push_back(IMG_LoadTexture(renderer,"Sho/standing/1.png"));
6-
texturas.push_back(IMG_LoadTexture(renderer,"Sho/standing/2.png"));
7-
texturas.push_back(IMG_LoadTexture(renderer,"Sho/standing/3.png"));
8-
texturas.push_back(IMG_LoadTexture(renderer,"Sho/standing/4.png"));
5+
vector<SDL_Texture*>*texturas = new vector<SDL_Texture*>();
6+
vector<SDL_Texture*>*texturas_left = new vector<SDL_Texture*>();
97

10-
texturas_left.push_back(IMG_LoadTexture(renderer,"Sho/standing_left/1.png"));
11-
texturas_left.push_back(IMG_LoadTexture(renderer,"Sho/standing_left/2.png"));
12-
texturas_left.push_back(IMG_LoadTexture(renderer,"Sho/standing_left/3.png"));
13-
texturas_left.push_back(IMG_LoadTexture(renderer,"Sho/standing_left/4.png"));
8+
texturas->push_back(IMG_LoadTexture(renderer,"Sho/standing/1.png"));
9+
texturas->push_back(IMG_LoadTexture(renderer,"Sho/standing/2.png"));
10+
texturas->push_back(IMG_LoadTexture(renderer,"Sho/standing/3.png"));
11+
texturas->push_back(IMG_LoadTexture(renderer,"Sho/standing/4.png"));
1412

15-
mapa_texturas["left"]=&texturas_left;
16-
mapa_texturas["right"]=&texturas;
13+
texturas_left->push_back(IMG_LoadTexture(renderer,"Sho/standing_left/1.png"));
14+
texturas_left->push_back(IMG_LoadTexture(renderer,"Sho/standing_left/2.png"));
15+
texturas_left->push_back(IMG_LoadTexture(renderer,"Sho/standing_left/3.png"));
16+
texturas_left->push_back(IMG_LoadTexture(renderer,"Sho/standing_left/4.png"));
17+
18+
mapa_texturas["left"] = texturas_left;
19+
mapa_texturas["right"] = texturas;
20+
21+
vector_actual_str = "right";
1722

18-
textura_actual = "right";
19-
2023
rect.x = 0;
2124
rect.y = 0;
2225

@@ -37,7 +40,7 @@ void Sho::act()
3740
if(currentKeyStates[SDL_SCANCODE_Z])
3841
{
3942
rect.x--;
40-
textura_actual = "left";
43+
vector_actual_str = "left";
4144
}
4245

4346
if(currentKeyStates[SDL_SCANCODE_S])
@@ -48,7 +51,7 @@ void Sho::act()
4851
if(currentKeyStates[SDL_SCANCODE_D])
4952
{
5053
rect.x++;
51-
textura_actual = "right";
54+
vector_actual_str = "right";
5255
}
5356

5457
attackCheck();

bin/Debug/SDL2Testground

-102 Bytes
Binary file not shown.

obj/Debug/Enemigo.o

0 Bytes
Binary file not shown.

obj/Debug/EnemigoAzul.o

5.12 KB
Binary file not shown.

obj/Debug/EnemigoRojo.o

5.13 KB
Binary file not shown.

obj/Debug/EnemigoVerde.o

5.13 KB
Binary file not shown.

obj/Debug/Personaje.o

-15.8 KB
Binary file not shown.

obj/Debug/Sho.o

5.13 KB
Binary file not shown.

obj/Debug/main.o

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)