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