Nuevos sprites mejorados, valanceo de ataques y combos

This commit is contained in:
Guillermo Roche 2020-02-20 21:43:10 +01:00
parent 8bf3cbd393
commit 9884106a7d
70 changed files with 404 additions and 57 deletions

BIN
core/assets/cam/arriba1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/arriba2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/arriba3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/arriba4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/fente1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/fente2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/fente3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/fente4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/fente5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/fente6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/stand1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/stand2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/stand3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/stand4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/stand5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/stand6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/stand7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/cam/stand8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/arriba1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/arriba2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/arriba3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/frente1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/frente2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/frente3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/stand1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/stand2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/stand3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/stand4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/stand5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ken/stand6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/arriba1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/arriba2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/arriba3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/frente1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/frente2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/frente3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/stand1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/stand2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/stand3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/stand4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/stand5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
core/assets/ryu/stand6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -4,3 +4,6 @@
/Battle.class /Battle.class
/MenuSeleccion.class /MenuSeleccion.class
/Caratula.class /Caratula.class
/MenuSeleccion2p.class
/Battle2.class
/Fin.class

Binary file not shown.

Binary file not shown.

View File

@ -2,3 +2,6 @@
/Personaje.class /Personaje.class
/Barra.class /Barra.class
/Bot.class /Bot.class
/Personaje2.class
/Araque.class
/Ataque.class

Binary file not shown.

View File

@ -7,10 +7,12 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import menus.Battle; import menus.Battle;
import menus.Fin;
import menus.Menu; import menus.Menu;
import menus.MenuInicio; import menus.MenuInicio;
import menus.MenuOpcions; import menus.MenuOpcions;
import menus.MenuSeleccion; import menus.MenuSeleccion;
import menus.MenuSeleccion2p;
import utilidades.Gifs; import utilidades.Gifs;
public class MyGdxGame extends ApplicationAdapter { public class MyGdxGame extends ApplicationAdapter {
@ -21,6 +23,8 @@ public class MyGdxGame extends ApplicationAdapter {
float contadorGif = 0; float contadorGif = 0;
Gifs pinchos; Gifs pinchos;
int menuSeleccionado=0; int menuSeleccionado=0;
int aux=menuSeleccionado;
boolean fin=false;
@Override @Override
public void create () { public void create () {
batch = new SpriteBatch(); batch = new SpriteBatch();
@ -31,6 +35,8 @@ public class MyGdxGame extends ApplicationAdapter {
Menu.menus.add(new MenuInicio()); Menu.menus.add(new MenuInicio());
Menu.menus.add(new MenuOpcions()); Menu.menus.add(new MenuOpcions());
Menu.menus.add(new MenuSeleccion()); Menu.menus.add(new MenuSeleccion());
Menu.menus.add(new MenuSeleccion2p());
Menu.menus.add(new Fin());
} }
@Override @Override

View File

@ -15,7 +15,9 @@ public class Battle extends Menu{
Texture suelo; Texture suelo;
float contador; float contador;
boolean cambio; boolean cambio;
boolean finalRound;
public Battle(String np1, String np2) { public Battle(String np1, String np2) {
this.finalRound=false;
this.cambio=true; this.cambio=true;
this.p2=new Bot(np2, true); this.p2=new Bot(np2, true);
this.p1=new Personaje(np1, false); this.p1=new Personaje(np1, false);
@ -31,6 +33,8 @@ public class Battle extends Menu{
p1.cambiarEstado(p1.MEDIO); p1.cambiarEstado(p1.MEDIO);
}else if(Gdx.input.isKeyPressed(Input.Keys.W)){ }else if(Gdx.input.isKeyPressed(Input.Keys.W)){
p1.cambiarEstado(p1.ALTO); p1.cambiarEstado(p1.ALTO);
}else if(Gdx.input.isKeyPressed(Input.Keys.S)){
p1.cambiarEstado(p1.BAJO);
}else{ }else{
p1.cambiarEstado(p1.STAND); p1.cambiarEstado(p1.STAND);
} }
@ -40,27 +44,56 @@ public class Battle extends Menu{
p2.cambiarEstado((int)Math.round(Math.random()*2)); p2.cambiarEstado((int)Math.round(Math.random()*2));
cambio=false; cambio=false;
} }
if(contador>1) { if(finalRound) {
contador=0; if(contador>2) {
cambio=true; contador=0;
cambio=true;
}
}else {
if(contador>1) {
contador=0;
cambio=true;
}
} }
}else { }else {
p2.cambiarEstado(p2.STAND); p2.cambiarEstado(p2.STAND);
} }
p1.mover(); p1.mover();
p2.mover(); p2.mover();
p2.recivir(p1.atacar(delta)); p2.recivir(p1.atacar(delta));
p1.recivir(p2.atacar(delta)); if(finalRound) {
p1.recivir(p2.atacar(delta).ataqueFinal());
}else {
p1.recivir(p2.atacar(delta));
}
this.p1.draw(batch, delta); this.p1.draw(batch, delta);
this.p2.draw(batch, delta); this.p2.draw(batch, delta);
if(p1.muerto()) {
font.draw(batch, "Has perdido", Gdx.graphics.getWidth()/4,Gdx.graphics.getHeight()/2.6f);
}else if(p2.muerto()){
font.draw(batch, "Has ganado", Gdx.graphics.getWidth()/4,Gdx.graphics.getHeight()/2.6f);
}
return darSeleccionado(); return darSeleccionado();
} }
@Override @Override
int darSeleccionado() { int darSeleccionado() {
if(p1.muerto()||p2.muerto()) { if(p1.muerto()) {
Menu.menus.remove(Menu.BATTLE); Menu.menus.remove(Menu.BATTLE);
return Menu.INICIAL; return Menu.FINAL;
}else if(p2.muerto()) {
if(finalRound) {
Menu.menus.remove(Menu.BATTLE);
return Menu.FINAL;
}else {
this.p1=new Personaje(p1.toString(), false);
this.p2=new Bot(p2.toString(),true);
this.p1.setEnemigo(p2.getCaja());
this.p2.setEnemigo(p1.getCaja());
finalRound=true;
}
} }
return Menu.BATTLE; return Menu.BATTLE;

View File

@ -0,0 +1,77 @@
package menus;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import utilidades.Personaje;
import utilidades.Personaje2;
public class Battle2 extends Menu{
Personaje p1;
Personaje2 p2;
Texture suelo;
public Battle2(String np1, String np2) {
this.p2=new Personaje2(np2, true);
this.p1=new Personaje(np1, false);
this.p1.setEnemigo(p2.getCaja());
this.p2.setEnemigo(p1.getCaja());
suelo = new Texture("sueloChina.png");
}
@Override
public int draw(SpriteBatch batch, float delta) {
batch.draw(suelo,0,0);
if (Gdx.input.isKeyPressed(Input.Keys.E)) {
p1.cambiarEstado(Personaje.MEDIO);
}else if(Gdx.input.isKeyPressed(Input.Keys.W)){
p1.cambiarEstado(Personaje.ALTO);
}else if(Gdx.input.isKeyPressed(Input.Keys.S)){
p1.cambiarEstado(Personaje.BAJO);
}else{
p1.cambiarEstado(Personaje.STAND);
}
if (Gdx.input.isKeyPressed(Input.Keys.O)) {
p2.cambiarEstado(Personaje.MEDIO);
}else if(Gdx.input.isKeyPressed(Input.Keys.I)){
p2.cambiarEstado(Personaje.ALTO);
}else if(Gdx.input.isKeyPressed(Input.Keys.K)){
p2.cambiarEstado(Personaje.BAJO);
}else{
p2.cambiarEstado(Personaje.STAND);
}
p1.mover();
p2.mover();
p2.recivir(p1.atacar(delta));
p1.recivir(p2.atacar(delta));
this.p1.draw(batch, delta);
this.p2.draw(batch, delta);
if(p1.muerto()) {
font.draw(batch, "Ha ganado el jugador 2", Gdx.graphics.getWidth()/4,Gdx.graphics.getHeight()/2.6f);
}else if(p2.muerto()){
font.draw(batch, "Ha ganado el jugador 1", Gdx.graphics.getWidth()/4,Gdx.graphics.getHeight()/2.6f);
}
return darSeleccionado();
}
@Override
int darSeleccionado() {
if(p1.muerto()||p2.muerto()) {
Menu.menus.remove(Menu.BATTLE);
return Menu.FINAL;
}
return Menu.BATTLE;
}
public void dispose() {
super.dispose();
p1.dispose();
p2.dispose();
}
}

24
core/src/menus/Fin.java Normal file
View File

@ -0,0 +1,24 @@
package menus;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class Fin extends Menu{
@Override
public int draw(SpriteBatch batch, float delta) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return Menu.INICIAL;
}
@Override
int darSeleccionado() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -21,7 +21,9 @@ public abstract class Menu {
static final int INICIAL=0; static final int INICIAL=0;
static final int OPCIONES=1; static final int OPCIONES=1;
static final int SELEC=2; static final int SELEC=2;
static final int BATTLE=3; static final int SELEC2=3;
static final int FINAL=4;
static final int BATTLE=5;
int local; int local;
static int resolution; static int resolution;
BitmapFont font; BitmapFont font;

View File

@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class MenuInicio extends Menu{ public class MenuInicio extends Menu{
public MenuInicio() { public MenuInicio() {
super(); super();
this.n_opciones=2; this.n_opciones=3;
this.local=Menu.INICIAL; this.local=Menu.INICIAL;
} }
@Override @Override
@ -19,11 +19,18 @@ public class MenuInicio extends Menu{
break; break;
} }
case 1:{ case 1:{
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5, Gdx.graphics.getHeight()/3f);
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+220, Gdx.graphics.getHeight()/3f);
break;
}
case 2:{
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5-50, Gdx.graphics.getHeight()/5); Menu.selector.draw(batch, Gdx.graphics.getWidth()/5-50, Gdx.graphics.getHeight()/5);
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+230, Gdx.graphics.getHeight()/5); Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+230, Gdx.graphics.getHeight()/5);
break;
} }
} }
font.draw(batch, "iniciar", Gdx.graphics.getWidth()/3.75f,Gdx.graphics.getHeight()/2); font.draw(batch, "iniciar", Gdx.graphics.getWidth()/3.75f,Gdx.graphics.getHeight()/2);
font.draw(batch, "iniciar 2Vs2", Gdx.graphics.getWidth()/4,Gdx.graphics.getHeight()/2.6f);
font.draw(batch, "configuracion", Gdx.graphics.getWidth()/5,Gdx.graphics.getHeight()/4); font.draw(batch, "configuracion", Gdx.graphics.getWidth()/5,Gdx.graphics.getHeight()/4);
return this.cambiarSeleccionado(); return this.cambiarSeleccionado();
} }
@ -31,7 +38,8 @@ public class MenuInicio extends Menu{
int darSeleccionado() { int darSeleccionado() {
switch(this.position) { switch(this.position) {
case 0:return Menu.SELEC; case 0:return Menu.SELEC;
case 1:return Menu.OPCIONES; case 1:return Menu.SELEC2;
case 2:return Menu.OPCIONES;
default: return -1; default: return -1;
} }
} }

View File

@ -0,0 +1,83 @@
package menus;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
public class MenuSeleccion2p extends MenuSeleccion{
int p1;
public MenuSeleccion2p() {
super();
this.local=Menu.SELEC2;
this.p1=-1;
}
@Override
public int draw(SpriteBatch batch, float delta) {
if(p1!=-1) {
batch.end();
shapeDrawer.begin(ShapeType.Filled);
shapeDrawer.setColor(Color.GRAY);
shapeDrawer.rect(10+p1*280, 430, 190, 180);
shapeDrawer.end();
batch.begin();
}
for(int i=0; i<this.caratulas.size();i++) {
if(i<3) {
if(i==this.position) {
batch.end();
shapeDrawer.begin(ShapeType.Filled);
if(p1!=-1) {
shapeDrawer.setColor(Color.BLACK);
}else {
shapeDrawer.setColor(Color.GRAY);
}
shapeDrawer.rect(10+i*280, 430, 190, 180);
shapeDrawer.end();
batch.begin();
}
this.caratulas.get(i).draw(batch, 10+i*200, 300);
}else {
this.caratulas.get(i).draw(batch, 10+(i-2)*200, 150);
}
}
return this.darSeleccionado();
}
@Override
int darSeleccionado() {
if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
if(!this.pres) {
this.position++;
this.pres=true;
}
}else if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
if(!this.pres) {
this.position--;
this.pres=true;
}
}else if (Gdx.input.isKeyPressed(Input.Keys.ENTER)){
if(!this.pres) {
this.pres=true;
if(p1==-1) {
p1=this.position;
this.position=0;
}else {
Menu.menus.add(new Battle2(this.caratulas.get(this.p1).nombre,
this.caratulas.get(this.position).nombre));
this.p1=-1;
this.position=0;
return Menu.BATTLE;
}
}
}else if(this.pres) {
this.pres=false;
}
this.position%=this.n_opciones;
if(this.position<0)this.position=this.n_opciones-1;
return this.local;
}
}

View File

@ -0,0 +1,42 @@
package utilidades;
public class Ataque {
int tipo;
float valor;
public Ataque(int tipo, float valor) {
this.tipo=tipo;
this.valor=valor;
}
public Ataque ataqueFinal() {
this.valor*=2;
return this;
}
float danio(int tipo) {
switch(this.tipo) {
case Personaje.ALTO:
if(tipo==Personaje.BAJO) {
return 0;
}else {
return valor*2;
}
case Personaje.MEDIO:
if(tipo==Personaje.ALTO) {
return valor*1.2f;
}else if(tipo==Personaje.BAJO) {
return valor*0.8f;
}
break;
case Personaje.BAJO:{
if(tipo==Personaje.BAJO) {
return valor*1;
}else {
return valor*0.5f;
}
}
}
return 0;
}
}

View File

@ -1,8 +1,5 @@
package utilidades; package utilidades;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class Bot extends Personaje{ public class Bot extends Personaje{
public Bot(String caracter, boolean position) { public Bot(String caracter, boolean position) {
@ -29,7 +26,12 @@ public class Bot extends Personaje{
} }
} }
} }
this.caja.setPosition(x, y); if(position) {
this.caja.setPosition(x, y+120);
}else {
this.caja.setPosition(x, y);
}
} }
} }

View File

@ -22,14 +22,12 @@ public class Gifs {
} }
} }
public Gifs(Texture textura, int n_estados, int inicio_image, int desplazamiento, public Gifs(String nombre, int n_estados, boolean flip) {
int anchura, int x, int y) { this.n_estados=n_estados;
this.textura = textura;
this.n_estados = n_estados;
frames = new TextureRegion[n_estados]; frames = new TextureRegion[n_estados];
for(int i = 0; i<n_estados; i++) { for(int i = 0; i<n_estados; i++) {
frames[i] = new TextureRegion(textura, inicio_image+i*desplazamiento frames[i] = new TextureRegion(new Texture(nombre+(i+1)+".png"));
, anchura, x, y); frames[i].flip(flip, false);
} }
} }
public void avanzar(int speed, float delta) { public void avanzar(int speed, float delta) {

View File

@ -19,8 +19,9 @@ public class Personaje {
public static final int ALTO=1; public static final int ALTO=1;
public static final int MEDIO=2; public static final int MEDIO=2;
public static final int BAJO=3; public static final int BAJO=3;
private int keyR; int estado;
private int keyL; int keyR;
int keyL;
int x; int x;
int y; int y;
float contadorCombo; float contadorCombo;
@ -32,35 +33,46 @@ public class Personaje {
ShapeRenderer shapeDrawer; ShapeRenderer shapeDrawer;
String combo; String combo;
int caracter; int caracter;
float coeficienteDanio;
float coeficienteDef;
public Personaje(String caracter, boolean position) { public Personaje(String caracter, boolean position) {
this.tempCombo=0; this.tempCombo=0;
this.combo=""; this.combo="";
shapeDrawer=new ShapeRenderer(); shapeDrawer=new ShapeRenderer();
//PolygonShape shape = new PolygonShape(1);
this.vida=100; this.vida=100;
this.position=position; this.position=position;
if(position) { if(position) {
this.x=10; this.x=10;
this.y=250; this.y=370;
}else { }else {
this.x=10; this.x=10;
this.y=150; this.y=150;
} }
this.caja=new Rectangle(x, y,70,70); if(this.position) {
this.caja=new Rectangle(x, y+120,70,70);
}else {
this.caja=new Rectangle(x, y,70,70);
}
this.keyR=Input.Keys.D; this.keyR=Input.Keys.D;
this.keyL=Input.Keys.A; this.keyL=Input.Keys.A;
switch (caracter) { switch (caracter) {
case "ryu": case "ryu":
this.caracter=1; this.caracter=1;
this.ryu(position); this.ryu(position);
this.coeficienteDanio=1;
this.coeficienteDef=1;
break; break;
case "ken": case "ken":
this.caracter=2; this.caracter=2;
this.ken(position); this.ken(position);
this.coeficienteDanio=0.8f;
this.coeficienteDef=1.2f;
break; break;
case "cam": case "cam":
this.caracter=3; this.caracter=3;
this.cam(position); this.cam(position);
this.coeficienteDanio=1.2f;
this.coeficienteDef=0.8f;
default: default:
break; break;
} }
@ -68,6 +80,7 @@ public class Personaje {
} }
public void cambiarEstado(int estado) { public void cambiarEstado(int estado) {
this.estado=estado;
this.boost(estado); this.boost(estado);
switch(estado) { switch(estado) {
case STAND: case STAND:
@ -105,10 +118,32 @@ public class Personaje {
} }
break; break;
case 2: case 2:
if(estado==Personaje.BAJO) {
if(contadorCombo<2) {
contadorCombo++;
}
}else if(estado==Personaje.ALTO) {
if(contadorCombo>=2) {
contadorCombo=0;
this.tempCombo=5;
}
}else {
contadorCombo=0;
}
break; break;
case 3: case 3:
if(estado==Personaje.MEDIO) {
if(contadorCombo<2) {
contadorCombo++;
}
}else if(estado==Personaje.BAJO) {
if(contadorCombo>=2) {
contadorCombo=0;
this.tempCombo=5;
}
}else {
contadorCombo=0;
}
break; break;
default: default:
break; break;
@ -119,28 +154,18 @@ public class Personaje {
this.tempCombo=10; this.tempCombo=10;
} }
public void recivir(float danio) { public void recivir(Ataque ataque) {
if(this.caja.overlaps(enemigo)) { if(this.caja.overlaps(enemigo)) {
this.vida-=danio; this.vida-=ataque.danio(this.estado)/this.coeficienteDef;
} }
} }
public float atacar(float delta) { public Ataque atacar(float delta) {
if(this.actual==this.medio) { if(tempCombo>0) {
if(tempCombo>0) { return new Ataque(this.estado, this.coeficienteDanio*delta*20);
return delta*20; }else {
}else { return new Ataque(this.estado, this.coeficienteDanio*delta*10);
return delta*10;
}
} }
if(this.actual==this.alto) {
if(tempCombo>0) {
return delta*30;
}else {
return delta*15;
}
}
return 0;
} }
public void mover() { public void mover() {
@ -163,7 +188,12 @@ public class Personaje {
} }
} }
} }
this.caja.setPosition(x, y); if(this.position) {
this.caja.setPosition(x, y+120);
}else {
this.caja.setPosition(x, y);
}
} }
public void draw(SpriteBatch batch, float delta) { public void draw(SpriteBatch batch, float delta) {
@ -177,19 +207,19 @@ public class Personaje {
} }
shapeDrawer.end(); shapeDrawer.end();
batch.begin(); batch.begin();
this.actual.avanzar(5, delta); this.actual.avanzar(7, delta);
this.actual.draw(batch, this.y, this.x); if(this.position) {
this.actual.draw(batch, this.y, this.x);
}else {
this.actual.draw(batch, this.y, this.x);
}
batch.end(); batch.end();
if(tempCombo>0) { if(tempCombo>0) {
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shapeDrawer.begin(ShapeType.Filled); shapeDrawer.begin(ShapeType.Filled);
shapeDrawer.setColor(1f,0f,0f,0.3f); shapeDrawer.setColor(1f,0f,0f,0.3f);
if(this.position) { shapeDrawer.circle(70+(1.35f*y), x+80, 80);
shapeDrawer.circle(y+100, x+80, 80);
}else {
shapeDrawer.circle(y+50, x+80, 80);
}
shapeDrawer.end(); shapeDrawer.end();
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL20.GL_BLEND);
tempCombo-=delta; tempCombo-=delta;
@ -203,21 +233,33 @@ public class Personaje {
} }
private void ryu(boolean position) { private void ryu(boolean position) {
this.standby=new Gifs("p1.png", 5, 0, 74, 120, 70, 100, position); /*this.standby=new Gifs("p1.png", 5, 0, 74, 120, 70, 100, position);
this.medio=new Gifs("p1.png", 3, 4, 93, 355, 88, 100, position); this.medio=new Gifs("p1.png", 3, 4, 93, 355, 88, 100, position);
this.alto=new Gifs("p1.png", 3, 8, 74, 779, 75, 130, position); this.alto=new Gifs("p1.png", 3, 8, 74, 779, 75, 130, position);*/
this.standby=new Gifs("ryu/stand", 6, position);
this.medio=new Gifs("ryu/frente", 3, position);
this.alto=new Gifs("ryu/arriba", 3, position);
this.bajo=new Gifs("ryu/sentado",3,position);
} }
private void ken(boolean position) { private void ken(boolean position) {
this.standby=new Gifs("p2.png", 5, 0, 70, 863, 67, 93, position); /*this.standby=new Gifs("p2.png", 5, 0, 70, 863, 67, 93, position);
this.medio=new Gifs("p2.png", 2, 0, 70, 1145, 72, 100, position); this.medio=new Gifs("p2.png", 2, 0, 70, 1145, 72, 100, position);
this.alto=new Gifs("p2.png", 3, 6, 74, 2920, 75, 130, position); this.alto=new Gifs("p2.png", 3, 6, 74, 2920, 75, 130, position);*/
this.standby=new Gifs("ken/stand", 6, position);
this.medio=new Gifs("ken/frente", 3, position);
this.alto=new Gifs("ken/arriba", 3, position);
this.bajo=new Gifs("ken/sentado",3,position);
} }
private void cam(boolean position) { private void cam(boolean position) {
this.standby=new Gifs("p3.png", 8, 0, 78, 113, 75, 98, position); /*this.standby=new Gifs("p3.png", 8, 0, 78, 113, 75, 98, position);
this.medio=new Gifs("p3.png", 2, 77, 86, 613, 90, 100, position); this.medio=new Gifs("p3.png", 2, 77, 86, 613, 90, 100, position);
this.alto=new Gifs("p3.png", 2, 192, 68, 1327, 60, 100, position); this.alto=new Gifs("p3.png", 2, 192, 68, 1327, 60, 100, position);*/
this.standby=new Gifs("cam/stand", 8, position);
this.medio=new Gifs("cam/fente", 6, position);
this.alto=new Gifs("cam/arriba", 4, position);
this.bajo=new Gifs("cam/sentado",3,position);
} }
public Rectangle getCaja() { public Rectangle getCaja() {
@ -231,4 +273,13 @@ public class Personaje {
public boolean muerto() { public boolean muerto() {
return this.vida<0; return this.vida<0;
} }
public String toString() {
switch (caracter) {
case 1:return "ryu";
case 2:return "ken";
case 3:return "cam";
}
return "";
}
} }

View File

@ -0,0 +1,12 @@
package utilidades;
import com.badlogic.gdx.Input;
public class Personaje2 extends Personaje{
public Personaje2(String caracter, boolean position) {
super(caracter, position);
this.keyL=Input.Keys.J;
this.keyR=Input.Keys.L;
}
}

View File

@ -3,3 +3,6 @@
/p2.png /p2.png
/sueloChina.png /sueloChina.png
/p3.png /p3.png
/ryu/
/cam/
/ken/