Skip to content

Commit

Permalink
funcion init
Browse files Browse the repository at this point in the history
  • Loading branch information
Turupawn committed Feb 13, 2015
1 parent 483732f commit b9b08fd
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 48 deletions.
8 changes: 2 additions & 6 deletions EnemigoAzul.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
#include "EnemigoAzul.h"

EnemigoAzul::EnemigoAzul(SDL_Renderer* renderer)
EnemigoAzul::EnemigoAzul(SDL_Renderer* renderer, list<Personaje*> *personajes)
{
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/1.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/2.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/3.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoAzul/standing/4.png"));

SDL_QueryTexture(texturas[0], NULL, NULL, &rect.w, &rect.h);
rect.x = 100;
rect.y = 250;

frame = 0;
animacion = 0;
hitbox_azul = IMG_LoadTexture(renderer,"hitbox/azul.png");
hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png");
init(renderer,personajes);
}

EnemigoAzul::~EnemigoAzul()
Expand Down
2 changes: 1 addition & 1 deletion EnemigoAzul.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class EnemigoAzul : public Enemigo
{
public:
EnemigoAzul(SDL_Renderer* renderer);
EnemigoAzul(SDL_Renderer* renderer,list<Personaje*> *personajes);
virtual ~EnemigoAzul();

void act();
Expand Down
11 changes: 3 additions & 8 deletions EnemigoRojo.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#include "EnemigoRojo.h"

EnemigoRojo::EnemigoRojo(SDL_Renderer* renderer)
EnemigoRojo::EnemigoRojo(SDL_Renderer* renderer, list<Personaje*> *personajes)
{
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/1.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/2.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/3.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoRojo/standing/4.png"));

SDL_QueryTexture(texturas[0], NULL, NULL, &rect.w, &rect.h);

rect.x = 750;
rect.y = 250;

frame = 0;
animacion = 0;

hitbox_azul = IMG_LoadTexture(renderer,"hitbox/azul.png");
hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png");
init(renderer, personajes);
}

EnemigoRojo::~EnemigoRojo()
Expand Down
2 changes: 1 addition & 1 deletion EnemigoRojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class EnemigoRojo : public Enemigo
{
public:
EnemigoRojo(SDL_Renderer* renderer);
EnemigoRojo(SDL_Renderer* renderer,list<Personaje*> *personajes);
virtual ~EnemigoRojo();

void act();
Expand Down
11 changes: 3 additions & 8 deletions EnemigoVerde.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#include "EnemigoVerde.h"

EnemigoVerde::EnemigoVerde(SDL_Renderer* renderer)
EnemigoVerde::EnemigoVerde(SDL_Renderer* renderer, list<Personaje*> *personajes)
{
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/1.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/2.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/3.png"));
texturas.push_back(IMG_LoadTexture(renderer,"EnemigoVerde/standing/4.png"));

SDL_QueryTexture(texturas[0], NULL, NULL, &rect.w, &rect.h);

rect.x = 500;
rect.y = 250;

frame = 0;
animacion = 0;

hitbox_azul = IMG_LoadTexture(renderer,"hitbox/azul.png");
hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png");
init(renderer, personajes);
}

EnemigoVerde::~EnemigoVerde()
Expand Down
2 changes: 1 addition & 1 deletion EnemigoVerde.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class EnemigoVerde : public Enemigo
{
public:
EnemigoVerde(SDL_Renderer* renderer);
EnemigoVerde(SDL_Renderer* renderer,list<Personaje*> *personajes);
virtual ~EnemigoVerde();
void act();
protected:
Expand Down
13 changes: 13 additions & 0 deletions Personaje.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ void Personaje::draw(SDL_Renderer* renderer)
// hitbox.h++;
// hitbox.w++;
}

void Personaje::init(SDL_Renderer* renderer, list<Personaje*> *personajes)
{
SDL_QueryTexture(texturas[0], NULL, NULL, &rect.w, &rect.h);

frame = 0;
animacion = 0;
hitbox_azul = IMG_LoadTexture(renderer,"hitbox/azul.png");
hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png");

this->personajes = personajes;
}

4 changes: 3 additions & 1 deletion Personaje.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
#include<SDL2/SDL.h>
#include<SDL2/SDL_image.h>
#include <vector>
#include <list>
using namespace std;

class Personaje
{
public:

list<Personaje*> *personajes;
vector<SDL_Texture*>texturas;
SDL_Texture* hitbox_azul;
SDL_Texture* hitbox_roja;
Expand All @@ -20,6 +21,7 @@ class Personaje

virtual void draw(SDL_Renderer* renderer);
virtual void act()=0;
void init(SDL_Renderer* renderer, list<Personaje*> *personajes);

Personaje();
virtual ~Personaje();
Expand Down
23 changes: 12 additions & 11 deletions SDL2Testground.depend
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@
<SDL2/SDL_image.h>
<iostream>

1423251830 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/main.cpp
1423853803 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/main.cpp
<SDL2/SDL.h>
<SDL2/SDL_image.h>
<iostream>
Expand All @@ -568,10 +568,10 @@
"EnemigoVerde.h"
"EnemigoRojo.h"

1423852718 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.h
1423853838 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.h
"Personaje.h"

1423852740 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.cpp
1423853493 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.cpp
"Sho.h"

1423852506 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Enemigo.cpp
Expand All @@ -580,29 +580,30 @@
1423852523 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Enemigo.h
"Personaje.h"

1423248725 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoAzul.h
1423853744 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoAzul.h
"Enemigo.h"

1423852188 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoAzul.cpp
1423853722 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoAzul.cpp
"EnemigoAzul.h"

1423852191 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoRojo.cpp
1423853753 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoRojo.cpp
"EnemigoRojo.h"

1423250451 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoRojo.h
1423853740 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoRojo.h
"Enemigo.h"

1423852196 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoVerde.cpp
1423853761 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoVerde.cpp
"EnemigoVerde.h"

1423250236 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoVerde.h
1423853736 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoVerde.h
"Enemigo.h"

1423852529 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Personaje.h
1423853705 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Personaje.h
<SDL2/SDL.h>
<SDL2/SDL_image.h>
<vector>
<list>

1423852516 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Personaje.cpp
1423853690 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Personaje.cpp
"Personaje.h"

16 changes: 11 additions & 5 deletions Sho.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#include "Sho.h"

Sho::Sho(SDL_Renderer* renderer)
Sho::Sho(SDL_Renderer* renderer,list<Personaje*> *personajes)
{
texturas.push_back(IMG_LoadTexture(renderer,"Sho/standing/1.png"));
texturas.push_back(IMG_LoadTexture(renderer,"Sho/standing/2.png"));
texturas.push_back(IMG_LoadTexture(renderer,"Sho/standing/3.png"));
texturas.push_back(IMG_LoadTexture(renderer,"Sho/standing/4.png"));

SDL_QueryTexture(texturas[0], NULL, NULL, &rect.w, &rect.h);

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

frame = 0;
animacion = 0;
init(renderer,personajes);
}

void Sho::act()
{
const Uint8* currentKeyStates = SDL_GetKeyboardState(NULL);

atacando = currentKeyStates[SDL_SCANCODE_SPACE];

if(currentKeyStates[SDL_SCANCODE_W])
{
rect.y--;
Expand All @@ -37,6 +38,11 @@ void Sho::act()
{
rect.x++;
}

if(atacando)
{
//detecto colosion con los demas personajes
}
}

Sho::~Sho()
Expand Down
2 changes: 1 addition & 1 deletion Sho.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Sho : public Personaje
{
public:
Sho(SDL_Renderer* renderer);
Sho(SDL_Renderer* renderer,list<Personaje*> *personajes);
void act();
virtual ~Sho();
protected:
Expand Down
Binary file modified bin/Debug/SDL2Testground
Binary file not shown.
10 changes: 5 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ int main( int argc, char* args[] )


list<Personaje*> personajes;
personajes.push_back(new Sho(renderer));
personajes.push_back(new EnemigoAzul(renderer));
personajes.push_back(new EnemigoVerde(renderer));
personajes.push_back(new EnemigoRojo(renderer));
personajes.push_back(new Sho(renderer,&personajes));
personajes.push_back(new EnemigoAzul(renderer,&personajes));
personajes.push_back(new EnemigoVerde(renderer,&personajes));
personajes.push_back(new EnemigoRojo(renderer,&personajes));

//Main Loop
int frame=0;
Expand All @@ -70,7 +70,7 @@ int main( int argc, char* args[] )

if(frame%200==0)
{
personajes.push_back(new EnemigoAzul(renderer));
personajes.push_back(new EnemigoAzul(renderer,&personajes));
}

for(list<Personaje*>::iterator p=personajes.begin();
Expand Down
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/Personaje.o
Binary file not shown.
Binary file modified obj/Debug/Sho.o
Binary file not shown.
Binary file modified obj/Debug/main.o
Binary file not shown.

0 comments on commit b9b08fd

Please sign in to comment.