Skip to content

Commit

Permalink
hitboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Turupawn committed Feb 13, 2015
1 parent fd5e430 commit f041bd9
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 7 deletions.
11 changes: 11 additions & 0 deletions Enemigo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Enemigo::Enemigo()
{
//ctor
hitbox.w = 75;
hitbox.h = 30;
atacando = false;
}

Enemigo::~Enemigo()
Expand All @@ -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++;
}
5 changes: 4 additions & 1 deletion Enemigo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ class Enemigo
{
public:
vector<SDL_Texture*>texturas;
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();
Expand Down
6 changes: 6 additions & 0 deletions EnemigoAzul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -23,6 +25,10 @@ EnemigoAzul::~EnemigoAzul()
void EnemigoAzul::act()
{
rect.x++;
if(frame%100==0)
atacando = true;
else
atacando = false;
}


Expand Down
3 changes: 3 additions & 0 deletions EnemigoRojo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions EnemigoVerde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 8 additions & 6 deletions SDL2Testground.depend
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,16 @@
<SDL2/SDL_image.h>
<iostream>

1423250201 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/main.cpp
1423251830 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/main.cpp
<SDL2/SDL.h>
<SDL2/SDL_image.h>
<iostream>
<vector>
<list>
"Sho.h"
"EnemigoAzul.h"
"EnemigoVerde.h"
"EnemigoRojo.h"

1422648139 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.h
<SDL2/SDL.h>
Expand All @@ -574,27 +576,27 @@
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
<SDL2/SDL.h>
<SDL2/SDL_image.h>
<vector>

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
Expand Down
Binary file modified bin/Debug/SDL2Testground
Binary file not shown.
Binary file added hitbox/azul.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hitbox/roja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified obj/Debug/Enemigo.o
Binary file not shown.
Binary file modified obj/Debug/EnemigoAzul.o
Binary file not shown.
Binary file modified obj/Debug/EnemigoRojo.o
Binary file not shown.
Binary file modified obj/Debug/EnemigoVerde.o
Binary file not shown.
Binary file modified obj/Debug/main.o
Binary file not shown.

0 comments on commit f041bd9

Please sign in to comment.