Skip to content

Commit

Permalink
antes de examen
Browse files Browse the repository at this point in the history
  • Loading branch information
Turupawn committed Feb 20, 2015
1 parent 6b62c4a commit 6166a1b
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 46 deletions.
2 changes: 2 additions & 0 deletions EnemigoAzul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ void EnemigoAzul::act()
atacando = true;
else
atacando = false;

attackCheck();
}


Expand Down
34 changes: 28 additions & 6 deletions Personaje.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,40 @@ void Personaje::init(SDL_Renderer* renderer, list<Personaje*> *personajes)
hitbox_roja = IMG_LoadTexture(renderer,"hitbox/roja.png");

this->personajes = personajes;

muerto = false;
}

bool Personaje::colision(SDL_Rect param)
{
if(param.x + param.w < rect.x
|| param.x > rect.x + rect.w
|| param.y + param.h < rect.y
|| param.y > rect.y + rect.h)
if(param.x + param.w < hitbox.x
|| param.x > hitbox.x + hitbox.w
|| param.y + param.h < hitbox.y
|| param.y > hitbox.y + hitbox.h)
return false;
else
return true;
}



void Personaje::attackCheck()
{
if(atacando)
{
//detecto colision con los demas personajes
list<Personaje*>::iterator i;
for(i= personajes->begin();
i!=personajes->end();
i++)
{
if((*i)!=this)
{
if(colision((*i)->hitbox))
{
cout<<"Colision! "<< frame <<endl;
//personajes->erase(i);
(*i)->muerto = true;
}
}
}
}
}
2 changes: 2 additions & 0 deletions Personaje.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ class Personaje
int frame;
int animacion;
bool atacando;
bool muerto;

virtual void draw(SDL_Renderer* renderer);
virtual void act()=0;
void init(SDL_Renderer* renderer, list<Personaje*> *personajes);
bool colision(SDL_Rect param);
void attackCheck();

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

1423853846 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/main.cpp
1423855866 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/main.cpp
<SDL2/SDL.h>
<SDL2/SDL_image.h>
<iostream>
Expand All @@ -571,7 +571,7 @@
1423853838 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.h
"Personaje.h"

1423855167 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Sho.cpp
1423856102 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 @@ -583,7 +583,7 @@
1423853744 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoAzul.h
"Enemigo.h"

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

1423853753 source:/home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoRojo.cpp
Expand All @@ -598,13 +598,13 @@
1423853736 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/EnemigoVerde.h
"Enemigo.h"

1423855091 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Personaje.h
1423856110 /home/turupawn/Projects/Clases/Progra3/SDL2TestSimple-master/Personaje.h
<SDL2/SDL.h>
<SDL2/SDL_image.h>
<vector>
<list>
<iostream>

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

56 changes: 38 additions & 18 deletions SDL2Testground.layout
Original file line number Diff line number Diff line change
@@ -1,49 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
<File name="Sho.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="6" zoom_2="0">
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="287" topLine="0" />
<Cursor1 position="2495" topLine="71" />
</Cursor>
</File>
<File name="EnemigoRojo.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
<File name="EnemigoAzul.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="7" zoom_2="0">
<Cursor>
<Cursor1 position="529" topLine="0" />
<Cursor1 position="187" topLine="0" />
</Cursor>
</File>
<File name="Enemigo.h" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
<File name="Sho.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="6" zoom_2="0">
<Cursor>
<Cursor1 position="59" topLine="0" />
<Cursor1 position="161" topLine="0" />
</Cursor>
</File>
<File name="EnemigoAzul.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
<File name="Enemigo.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
<Cursor>
<Cursor1 position="529" topLine="9" />
<Cursor1 position="91" topLine="0" />
</Cursor>
</File>
<File name="Sho.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
<File name="Personaje.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
<Cursor>
<Cursor1 position="506" topLine="6" />
<Cursor1 position="658" topLine="1" />
</Cursor>
</File>
<File name="EnemigoAzul.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="7" zoom_2="0">
<File name="Personaje.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="8" zoom_2="0">
<Cursor>
<Cursor1 position="65" topLine="0" />
<Cursor1 position="1299" topLine="58" />
</Cursor>
</File>
<File name="Enemigo.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
<File name="Enemigo.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
<Cursor>
<Cursor1 position="370" topLine="10" />
<Cursor1 position="209" topLine="0" />
</Cursor>
</File>
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<File name="Sho.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
<Cursor>
<Cursor1 position="872" topLine="18" />
</Cursor>
</File>
<File name="EnemigoRojo.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="187" topLine="0" />
</Cursor>
</File>
<File name="EnemigoVerde.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
<Cursor>
<Cursor1 position="191" topLine="0" />
</Cursor>
</File>
<File name="EnemigoRojo.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
<Cursor>
<Cursor1 position="495" topLine="0" />
</Cursor>
</File>
<File name="EnemigoAzul.cpp" open="1" top="1" tabpos="6" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
<Cursor>
<Cursor1 position="1789" topLine="60" />
<Cursor1 position="669" topLine="5" />
</Cursor>
</File>
<File name="EnemigoVerde.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
<File name="EnemigoVerde.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
<Cursor>
<Cursor1 position="536" topLine="0" />
<Cursor1 position="502" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
18 changes: 1 addition & 17 deletions Sho.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,7 @@ void Sho::act()
rect.x++;
}

if(atacando)
{
//detecto colision con los demas personajes
list<Personaje*>::iterator i;
for(i= personajes->begin();
i!=personajes->end();
i++)
{
if((*i)!=this)
{
if(colision((*i)->rect))
{
cout<<"Colision! "<< frame <<endl;
}
}
}
}
attackCheck();
}

Sho::~Sho()
Expand Down
Binary file modified bin/Debug/SDL2Testground
Binary file not shown.
9 changes: 9 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ int main( int argc, char* args[] )
p!=personajes.end();
p++)
(*p)->draw(renderer);

for(list<Personaje*>::iterator p=personajes.begin();
p!=personajes.end();
p++)
if((*p)->muerto)
{
personajes.erase(p);
p--;
}

SDL_RenderPresent(renderer);

Expand Down
Binary file modified obj/Debug/EnemigoAzul.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 6166a1b

Please sign in to comment.