diff --git a/Enemigo.cpp b/Enemigo.cpp index b5e5a6a..c98af3b 100644 --- a/Enemigo.cpp +++ b/Enemigo.cpp @@ -3,6 +3,9 @@ Enemigo::Enemigo() { //ctor + hitbox.w = 75; + hitbox.h = 30; + atacando = false; } Enemigo::~Enemigo() @@ -19,5 +22,13 @@ void Enemigo::draw(SDL_Renderer* renderer) if(animacion_enemigo>=texturas.size()) animacion_enemigo=0; } + hitbox.x = rect.x + rect.w/2 - hitbox.w/2; + hitbox.y = rect.y + rect.h - hitbox.h/2; + SDL_RenderCopy(renderer, hitbox_azul, NULL, &hitbox); + if(atacando) + SDL_RenderCopy(renderer, hitbox_roja, NULL, &hitbox); frame++; + +// hitbox.h++; +// hitbox.w++; } diff --git a/Enemigo.h b/Enemigo.h index c6ae257..ae27d49 100644 --- a/Enemigo.h +++ b/Enemigo.h @@ -10,9 +10,12 @@ class Enemigo { public: vectortexturas; - SDL_Rect rect; + SDL_Texture* hitbox_azul; + SDL_Texture* hitbox_roja; + SDL_Rect rect,hitbox; int frame; int animacion_enemigo; + bool atacando; Enemigo(); virtual ~Enemigo(); diff --git a/EnemigoAzul.cpp b/EnemigoAzul.cpp index 8f4d635..de4495c 100644 --- a/EnemigoAzul.cpp +++ b/EnemigoAzul.cpp @@ -13,6 +13,8 @@ EnemigoAzul::EnemigoAzul(SDL_Renderer* renderer) frame = 0; animacion_enemigo = 0; + hitbox_azul = IMG_LoadTexture(renderer,"hitbox/azul.png"); + hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png"); } EnemigoAzul::~EnemigoAzul() @@ -23,6 +25,10 @@ EnemigoAzul::~EnemigoAzul() void EnemigoAzul::act() { rect.x++; + if(frame%100==0) + atacando = true; + else + atacando = false; } diff --git a/EnemigoRojo.cpp b/EnemigoRojo.cpp index 1502a67..3646874 100644 --- a/EnemigoRojo.cpp +++ b/EnemigoRojo.cpp @@ -13,6 +13,9 @@ EnemigoRojo::EnemigoRojo(SDL_Renderer* renderer) frame = 0; animacion_enemigo = 0; + + hitbox_azul = IMG_LoadTexture(renderer,"hitbox/azul.png"); + hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png"); } EnemigoRojo::~EnemigoRojo() diff --git a/EnemigoVerde.cpp b/EnemigoVerde.cpp index 8528792..47c956b 100644 --- a/EnemigoVerde.cpp +++ b/EnemigoVerde.cpp @@ -13,6 +13,9 @@ EnemigoVerde::EnemigoVerde(SDL_Renderer* renderer) frame = 0; animacion_enemigo = 0; + + hitbox_azul = IMG_LoadTexture(renderer,"hitbox/azul.png"); + hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png"); } EnemigoVerde::~EnemigoVerde() diff --git a/SDL2Testground.depend b/SDL2Testground.depend index 12d0148..3a10149 100644 --- a/SDL2Testground.depend +++ b/SDL2Testground.depend @@ -557,14 +557,16 @@ -1423250201 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/main.cpp +1423251830 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/main.cpp + "Sho.h" "EnemigoAzul.h" "EnemigoVerde.h" + "EnemigoRojo.h" 1422648139 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.h @@ -574,10 +576,10 @@ 1422648136 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.cpp "Sho.h" -1423248618 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Enemigo.cpp +1423849494 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Enemigo.cpp "Enemigo.h" -1423248593 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Enemigo.h +1423850737 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Enemigo.h @@ -585,16 +587,16 @@ 1423248725 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoAzul.h "Enemigo.h" -1423251727 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoAzul.cpp +1423849438 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoAzul.cpp "EnemigoAzul.h" -1423251733 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoRojo.cpp +1423849448 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoRojo.cpp "EnemigoRojo.h" 1423250451 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoRojo.h "Enemigo.h" -1423251739 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoVerde.cpp +1423849449 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoVerde.cpp "EnemigoVerde.h" 1423250236 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoVerde.h diff --git a/bin/Debug/SDL2Testground b/bin/Debug/SDL2Testground index 5301e23..56e0710 100755 Binary files a/bin/Debug/SDL2Testground and b/bin/Debug/SDL2Testground differ diff --git a/hitbox/azul.png b/hitbox/azul.png new file mode 100644 index 0000000..95c10c6 Binary files /dev/null and b/hitbox/azul.png differ diff --git a/hitbox/roja.png b/hitbox/roja.png new file mode 100644 index 0000000..d372ce8 Binary files /dev/null and b/hitbox/roja.png differ diff --git a/obj/Debug/Enemigo.o b/obj/Debug/Enemigo.o index 4c8b941..725cdc6 100644 Binary files a/obj/Debug/Enemigo.o and b/obj/Debug/Enemigo.o differ diff --git a/obj/Debug/EnemigoAzul.o b/obj/Debug/EnemigoAzul.o index b080afe..5c35837 100644 Binary files a/obj/Debug/EnemigoAzul.o and b/obj/Debug/EnemigoAzul.o differ diff --git a/obj/Debug/EnemigoRojo.o b/obj/Debug/EnemigoRojo.o index ba81447..e910e07 100644 Binary files a/obj/Debug/EnemigoRojo.o and b/obj/Debug/EnemigoRojo.o differ diff --git a/obj/Debug/EnemigoVerde.o b/obj/Debug/EnemigoVerde.o index 8027c1e..779ca21 100644 Binary files a/obj/Debug/EnemigoVerde.o and b/obj/Debug/EnemigoVerde.o differ diff --git a/obj/Debug/main.o b/obj/Debug/main.o index a4a0b5b..f272953 100644 Binary files a/obj/Debug/main.o and b/obj/Debug/main.o differ