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.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import menus.Battle;
import menus.Fin;
import menus.Menu;
import menus.MenuInicio;
@ -27,8 +27,12 @@ public class MyGdxGame extends ApplicationAdapter {
int aux=menuSeleccionado;
boolean fin=false;
Color color;
Music musica;
@Override
public void create () {
this.musica=Gdx.audio.newMusic(Gdx.files.internal("musica.mp3"));
musica.play();
musica.setLooping(true);
this.color=new Color();
color.set(0.5f, 0, 0, 1);
batch = new SpriteBatch();
@ -55,6 +59,7 @@ public class MyGdxGame extends ApplicationAdapter {
@Override
public void dispose () {
musica.dispose();
batch.dispose();
font.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) {
batch.draw(suelo,0,0);
if (Gdx.input.isKeyPressed(Input.Keys.E)) {
p1.cambiarEstado(p1.MEDIO);
p1.cambiarEstado(Personaje.MEDIO);
}else if(Gdx.input.isKeyPressed(Input.Keys.W)){
p1.cambiarEstado(p1.ALTO);
p1.cambiarEstado(Personaje.ALTO);
}else if(Gdx.input.isKeyPressed(Input.Keys.S)){
p1.cambiarEstado(p1.BAJO);
p1.cambiarEstado(Personaje.BAJO);
}else{
p1.cambiarEstado(p1.STAND);
p1.cambiarEstado(Personaje.STAND);
}
contador+=delta;
if(contador>0.5) {
if(cambio) {
p2.cambiarEstado((int)Math.round(Math.random()*2));
p2.cambiarEstado((int)Math.round(Math.random()*3));
cambio=false;
}
if(finalRound) {
@ -64,7 +64,7 @@ public class Battle extends Menu{
}
}else {
p2.cambiarEstado(p2.STAND);
p2.cambiarEstado(Personaje.STAND);
}
p1.mover();
p2.mover();
@ -87,11 +87,11 @@ public class Battle extends Menu{
@Override
int darSeleccionado() {
if(p1.muerto()) {
Menu.menus.remove(Menu.BATTLE);
//Menu.menus.remove(Menu.BATTLE);
return Menu.FINAL;
}else if(p2.muerto()) {
if(finalRound) {
Menu.menus.remove(Menu.BATTLE);
//Menu.menus.remove(Menu.BATTLE);
return Menu.FINAL;
}else {
this.p1=new Personaje(p1.toString(), false);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,6 +26,8 @@ public class Personaje {
int y;
float contadorCombo;
float tempCombo;
float contadorComboDefensa;
float tempComboDefensa;
private float vida;
Rectangle caja;
Rectangle enemigo;
@ -156,7 +158,12 @@ public class Personaje {
public void recivir(Ataque ataque) {
if(this.caja.overlaps(enemigo)) {
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 {
this.actual.draw(batch, this.y, this.x);
}
this.dibujarBoost(batch, delta);
}
void dibujarBoost(SpriteBatch batch, float delta) {
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);
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();
Gdx.gl.glDisable(GL20.GL_BLEND);
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();
}

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

Binary file not shown.