Ultimo boost, musica y errores menores corregidos

This commit is contained in:
Guillermo Roche 2020-02-21 12:04:35 +01:00
parent 207ccfc87f
commit 04fd130ac2
12 changed files with 66 additions and 20 deletions

BIN
core/assets/musica.mp3 Normal file

Binary file not shown.

View File

@ -2,12 +2,12 @@ package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont; 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.Fin; import menus.Fin;
import menus.Menu; import menus.Menu;
import menus.MenuInicio; import menus.MenuInicio;
@ -27,8 +27,12 @@ public class MyGdxGame extends ApplicationAdapter {
int aux=menuSeleccionado; int aux=menuSeleccionado;
boolean fin=false; boolean fin=false;
Color color; Color color;
Music musica;
@Override @Override
public void create () { public void create () {
this.musica=Gdx.audio.newMusic(Gdx.files.internal("musica.mp3"));
musica.play();
musica.setLooping(true);
this.color=new Color(); this.color=new Color();
color.set(0.5f, 0, 0, 1); color.set(0.5f, 0, 0, 1);
batch = new SpriteBatch(); batch = new SpriteBatch();
@ -55,6 +59,7 @@ public class MyGdxGame extends ApplicationAdapter {
@Override @Override
public void dispose () { public void dispose () {
musica.dispose();
batch.dispose(); batch.dispose();
font.dispose(); font.dispose();
Menu.menus.get(this.menuSeleccionado).dispose(); Menu.menus.get(this.menuSeleccionado).dispose();

View File

@ -37,18 +37,18 @@ public class Battle extends Menu{
public int draw(SpriteBatch batch, float delta) { public int draw(SpriteBatch batch, float delta) {
batch.draw(suelo,0,0); batch.draw(suelo,0,0);
if (Gdx.input.isKeyPressed(Input.Keys.E)) { if (Gdx.input.isKeyPressed(Input.Keys.E)) {
p1.cambiarEstado(p1.MEDIO); p1.cambiarEstado(Personaje.MEDIO);
}else if(Gdx.input.isKeyPressed(Input.Keys.W)){ }else if(Gdx.input.isKeyPressed(Input.Keys.W)){
p1.cambiarEstado(p1.ALTO); p1.cambiarEstado(Personaje.ALTO);
}else if(Gdx.input.isKeyPressed(Input.Keys.S)){ }else if(Gdx.input.isKeyPressed(Input.Keys.S)){
p1.cambiarEstado(p1.BAJO); p1.cambiarEstado(Personaje.BAJO);
}else{ }else{
p1.cambiarEstado(p1.STAND); p1.cambiarEstado(Personaje.STAND);
} }
contador+=delta; contador+=delta;
if(contador>0.5) { if(contador>0.5) {
if(cambio) { if(cambio) {
p2.cambiarEstado((int)Math.round(Math.random()*2)); p2.cambiarEstado((int)Math.round(Math.random()*3));
cambio=false; cambio=false;
} }
if(finalRound) { if(finalRound) {
@ -64,7 +64,7 @@ public class Battle extends Menu{
} }
}else { }else {
p2.cambiarEstado(p2.STAND); p2.cambiarEstado(Personaje.STAND);
} }
p1.mover(); p1.mover();
p2.mover(); p2.mover();
@ -87,11 +87,11 @@ public class Battle extends Menu{
@Override @Override
int darSeleccionado() { int darSeleccionado() {
if(p1.muerto()) { if(p1.muerto()) {
Menu.menus.remove(Menu.BATTLE); //Menu.menus.remove(Menu.BATTLE);
return Menu.FINAL; return Menu.FINAL;
}else if(p2.muerto()) { }else if(p2.muerto()) {
if(finalRound) { if(finalRound) {
Menu.menus.remove(Menu.BATTLE); //Menu.menus.remove(Menu.BATTLE);
return Menu.FINAL; return Menu.FINAL;
}else { }else {
this.p1=new Personaje(p1.toString(), false); this.p1=new Personaje(p1.toString(), false);

View File

@ -62,7 +62,7 @@ public class Battle2 extends Menu{
@Override @Override
int darSeleccionado() { int darSeleccionado() {
if(p1.muerto()||p2.muerto()) { if(p1.muerto()||p2.muerto()) {
Menu.menus.remove(Menu.BATTLE); //Menu.menus.remove(Menu.BATTLE);
return Menu.FINAL; return Menu.FINAL;
} }

View File

@ -3,16 +3,25 @@ package menus;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class Fin extends Menu{ public class Fin extends Menu{
float contador=0;
@Override @Override
public int draw(SpriteBatch batch, float delta) { public int draw(SpriteBatch batch, float delta) {
try { try {
Thread.sleep(5000); Thread.sleep(400);
Menu.menus.get(BATTLE).draw(batch, delta);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return Menu.INICIAL; if(contador>1) {
Menu.menus.remove(Menu.BATTLE);
return Menu.INICIAL;
}else {
contador++;
return Menu.FINAL;
}
} }
@Override @Override

View File

@ -20,7 +20,6 @@ public class MenuOpcions extends Menu{
this.opcion1=0; this.opcion1=0;
this.opcion2=0; this.opcion2=0;
this.n_opciones=2; this.n_opciones=2;
this.pres=true;
this.local=Menu.OPCIONES; this.local=Menu.OPCIONES;
} }
@ -109,6 +108,8 @@ public class MenuOpcions extends Menu{
} }
int darSeleccionado() { int darSeleccionado() {
Menu.menus.get(Menu.INICIAL).pres=true;
this.pres=true;
return Menu.INICIAL; return Menu.INICIAL;
} }

View File

@ -3,7 +3,9 @@ package utilidades;
public class Ataque { public class Ataque {
int tipo; int tipo;
float valor; float valor;
boolean esquivado;
public Ataque(int tipo, float valor) { public Ataque(int tipo, float valor) {
esquivado=false;
this.tipo=tipo; this.tipo=tipo;
this.valor=valor; this.valor=valor;
} }
@ -17,6 +19,7 @@ public class Ataque {
switch(this.tipo) { switch(this.tipo) {
case Personaje.ALTO: case Personaje.ALTO:
if(tipo==Personaje.BAJO) { if(tipo==Personaje.BAJO) {
this.esquivado=true;
return 0; return 0;
}else { }else {
return valor*2; return valor*2;

View File

@ -19,14 +19,13 @@ public class Bot extends Personaje{
} }
if (mover == 2) { if (mover == 2) {
if((!this.position)) { if((!this.position)) {
if(y>0)this.y--; if(y>0)this.y-=2;
}else { }else {
if((!this.caja.overlaps(enemigo))) { if((!this.caja.overlaps(enemigo))) {
this.y--; this.y-=2;
} }
} }
} }
System.out.println(y);
if(position) { if(position) {
this.caja.setPosition(x, y+120); this.caja.setPosition(x, y+120);
}else { }else {

View File

@ -26,6 +26,8 @@ public class Personaje {
int y; int y;
float contadorCombo; float contadorCombo;
float tempCombo; float tempCombo;
float contadorComboDefensa;
float tempComboDefensa;
private float vida; private float vida;
Rectangle caja; Rectangle caja;
Rectangle enemigo; Rectangle enemigo;
@ -156,7 +158,12 @@ public class Personaje {
public void recivir(Ataque ataque) { public void recivir(Ataque ataque) {
if(this.caja.overlaps(enemigo)) { if(this.caja.overlaps(enemigo)) {
this.vida-=ataque.danio(this.estado)/this.coeficienteDef; if(this.tempComboDefensa>1) {
this.vida-=ataque.danio(this.estado)/(this.coeficienteDef*2);
}else {
this.vida-=ataque.danio(this.estado)/this.coeficienteDef;
if(ataque.esquivado)this.tempComboDefensa++;
}
} }
} }
@ -213,17 +220,39 @@ public class Personaje {
}else { }else {
this.actual.draw(batch, this.y, this.x); this.actual.draw(batch, this.y, this.x);
} }
this.dibujarBoost(batch, delta);
}
void dibujarBoost(SpriteBatch batch, float delta) {
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);
shapeDrawer.circle(70+(1.35f*y), x+80, 80); if(this.position) {
shapeDrawer.circle((y*1.1f)+200, x+80, 80);
}else {
shapeDrawer.circle((y*1.1f)+70, x+80, 80);
}
shapeDrawer.end(); shapeDrawer.end();
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL20.GL_BLEND);
tempCombo-=delta; tempCombo-=delta;
} }
if(tempComboDefensa>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(0f,0f,1f,0.3f);
if(this.position) {
shapeDrawer.circle((y*1.1f)+200, x+80, 80);
}else {
shapeDrawer.circle((y*1.1f)+70, x+80, 80);
}
shapeDrawer.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
tempComboDefensa-=delta;
}
batch.begin(); batch.begin();
} }

BIN
desktop/bin/main/musica.mp3 Normal file

Binary file not shown.