aniadido combo

This commit is contained in:
Guillermo Roche 2020-02-20 10:46:04 +01:00
parent d816803514
commit 8bf3cbd393

View File

@ -3,6 +3,7 @@ package utilidades;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
@ -22,12 +23,18 @@ public class Personaje {
private int keyL; private int keyL;
int x; int x;
int y; int y;
float contadorCombo;
float tempCombo;
private float vida; private float vida;
Rectangle caja; Rectangle caja;
Rectangle enemigo; Rectangle enemigo;
boolean position; boolean position;
ShapeRenderer shapeDrawer; ShapeRenderer shapeDrawer;
String combo;
int caracter;
public Personaje(String caracter, boolean position) { public Personaje(String caracter, boolean position) {
this.tempCombo=0;
this.combo="";
shapeDrawer=new ShapeRenderer(); shapeDrawer=new ShapeRenderer();
//PolygonShape shape = new PolygonShape(1); //PolygonShape shape = new PolygonShape(1);
this.vida=100; this.vida=100;
@ -44,12 +51,15 @@ public class Personaje {
this.keyL=Input.Keys.A; this.keyL=Input.Keys.A;
switch (caracter) { switch (caracter) {
case "ryu": case "ryu":
this.caracter=1;
this.ryu(position); this.ryu(position);
break; break;
case "ken": case "ken":
this.caracter=2;
this.ken(position); this.ken(position);
break; break;
case "cam": case "cam":
this.caracter=3;
this.cam(position); this.cam(position);
default: default:
break; break;
@ -58,22 +68,57 @@ public class Personaje {
} }
public void cambiarEstado(int estado) { public void cambiarEstado(int estado) {
this.boost(estado);
switch(estado) { switch(estado) {
case STAND: case STAND:
this.actual=this.standby; this.actual=this.standby;
break; break;
case ALTO: case ALTO:
this.actual=this.alto; this.actual=this.alto;
this.combo+=estado;
break; break;
case MEDIO: case MEDIO:
this.actual=this.medio; this.actual=this.medio;
this.combo+=estado;
break; break;
case BAJO: case BAJO:
this.actual=this.bajo; this.actual=this.bajo;
this.combo+=estado;
break; break;
} }
} }
public void boost(int estado) {
switch(caracter) {
case 1:
if(estado==Personaje.MEDIO) {
if(contadorCombo<2) {
contadorCombo++;
}
}else if(estado==Personaje.ALTO) {
if(contadorCombo>=2) {
contadorCombo=0;
this.tempCombo=5;
}
}else {
contadorCombo=0;
}
break;
case 2:
break;
case 3:
break;
default:
break;
}
}
void aplicarBoost() {
this.tempCombo=10;
}
public void recivir(float danio) { public void recivir(float danio) {
if(this.caja.overlaps(enemigo)) { if(this.caja.overlaps(enemigo)) {
this.vida-=danio; this.vida-=danio;
@ -82,11 +127,19 @@ public class Personaje {
public float atacar(float delta) { public float atacar(float delta) {
if(this.actual==this.medio) { if(this.actual==this.medio) {
if(tempCombo>0) {
return delta*20;
}else {
return delta*10; return delta*10;
} }
}
if(this.actual==this.alto) { if(this.actual==this.alto) {
if(tempCombo>0) {
return delta*30;
}else {
return delta*15; return delta*15;
} }
}
return 0; return 0;
} }
@ -114,10 +167,6 @@ public class Personaje {
} }
public void draw(SpriteBatch batch, float delta) { public void draw(SpriteBatch batch, float delta) {
this.actual.avanzar(5, delta);
this.actual.draw(batch, this.y, this.x);
//batch.disableBlending();
batch.end(); batch.end();
shapeDrawer.begin(ShapeType.Filled); shapeDrawer.begin(ShapeType.Filled);
shapeDrawer.setColor(Color.GREEN); shapeDrawer.setColor(Color.GREEN);
@ -128,6 +177,24 @@ public class Personaje {
} }
shapeDrawer.end(); shapeDrawer.end();
batch.begin(); batch.begin();
this.actual.avanzar(5, delta);
this.actual.draw(batch, this.y, this.x);
batch.end();
if(tempCombo>0) {
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shapeDrawer.begin(ShapeType.Filled);
shapeDrawer.setColor(1f,0f,0f,0.3f);
if(this.position) {
shapeDrawer.circle(y+100, x+80, 80);
}else {
shapeDrawer.circle(y+50, x+80, 80);
}
shapeDrawer.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
tempCombo-=delta;
}
batch.begin();
} }
public void dispose() { public void dispose() {