aniadia Cammy, bot funcional
This commit is contained in:
		
							parent
							
								
									f30d646f99
								
							
						
					
					
						commit
						d816803514
					
				
							
								
								
									
										
											BIN
										
									
								
								core/assets/p3.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								core/assets/p3.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 35 MiB | 
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2
									
								
								core/bin/main/menus/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								core/bin/main/menus/.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -2,3 +2,5 @@ | ||||
| /MenuInicio.class | ||||
| /MenuOpcions.class | ||||
| /Battle.class | ||||
| /MenuSeleccion.class | ||||
| /Caratula.class | ||||
|  | ||||
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2
									
								
								core/bin/main/utilidades/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								core/bin/main/utilidades/.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,2 +1,4 @@ | ||||
| /Gifs.class | ||||
| /Personaje.class | ||||
| /Barra.class | ||||
| /Bot.class | ||||
|  | ||||
| @ -10,6 +10,7 @@ import menus.Battle; | ||||
| import menus.Menu; | ||||
| import menus.MenuInicio; | ||||
| import menus.MenuOpcions; | ||||
| import menus.MenuSeleccion; | ||||
| import utilidades.Gifs; | ||||
| 
 | ||||
| public class MyGdxGame extends ApplicationAdapter { | ||||
| @ -29,7 +30,7 @@ public class MyGdxGame extends ApplicationAdapter { | ||||
| 		Gdx.graphics.setWindowedMode(WIN_ALT, WIN_ANCH); | ||||
| 		Menu.menus.add(new MenuInicio()); | ||||
| 		Menu.menus.add(new MenuOpcions()); | ||||
| 		Menu.menus.add(new Battle()); | ||||
| 		Menu.menus.add(new MenuSeleccion()); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
|  | ||||
| @ -5,16 +5,22 @@ import com.badlogic.gdx.Input; | ||||
| import com.badlogic.gdx.graphics.Texture; | ||||
| import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||||
| 
 | ||||
| import utilidades.Bot; | ||||
| import utilidades.Personaje; | ||||
| 
 | ||||
| public class Battle extends Menu{ | ||||
| 	 | ||||
| 	Personaje p1; | ||||
| 	Personaje p2; | ||||
| 	Bot p2; | ||||
| 	Texture suelo; | ||||
| 	public Battle() { | ||||
| 		this.p2=new Personaje("ken", true); | ||||
| 		this.p1=new Personaje("ryu", false); | ||||
| 	float contador; | ||||
| 	boolean cambio; | ||||
| 	public Battle(String np1, String np2) { | ||||
| 		this.cambio=true; | ||||
| 		this.p2=new Bot(np2, true); | ||||
| 		this.p1=new Personaje(np1, false); | ||||
| 		this.p1.setEnemigo(p2.getCaja()); | ||||
| 		this.p2.setEnemigo(p1.getCaja()); | ||||
| 		suelo = new Texture("sueloChina.png"); | ||||
| 	} | ||||
| 	 | ||||
| @ -23,18 +29,47 @@ public class Battle extends Menu{ | ||||
| 		batch.draw(suelo,0,0); | ||||
| 		if (Gdx.input.isKeyPressed(Input.Keys.E)) { | ||||
| 			p1.cambiarEstado(p1.MEDIO); | ||||
| 		}else { | ||||
| 		}else if(Gdx.input.isKeyPressed(Input.Keys.W)){ | ||||
| 			p1.cambiarEstado(p1.ALTO); | ||||
| 		}else{ | ||||
| 			p1.cambiarEstado(p1.STAND); | ||||
| 		} | ||||
| 		this.p1.draw(batch, delta, 150, 10); | ||||
| 		this.p2.draw(batch, delta, 250, 10); | ||||
| 		return Menu.BATTLE; | ||||
| 		contador+=delta; | ||||
| 		if(contador>0.5) { | ||||
| 			if(cambio) { | ||||
| 				p2.cambiarEstado((int)Math.round(Math.random()*2)); | ||||
| 				cambio=false; | ||||
| 			} | ||||
| 			if(contador>1) { | ||||
| 				contador=0; | ||||
| 				cambio=true; | ||||
| 			} | ||||
| 		}else { | ||||
| 			p2.cambiarEstado(p2.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); | ||||
| 		return darSeleccionado(); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	int darSeleccionado() { | ||||
| 		 | ||||
| 		return 0; | ||||
| 		if(p1.muerto()||p2.muerto()) { | ||||
| 			Menu.menus.remove(Menu.BATTLE); | ||||
| 			return Menu.INICIAL; | ||||
| 		} | ||||
| 			 | ||||
| 		return Menu.BATTLE; | ||||
| 	} | ||||
| 	 | ||||
| 	public void dispose() { | ||||
| 		super.dispose(); | ||||
| 		p1.dispose(); | ||||
| 		p2.dispose(); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | ||||
							
								
								
									
										19
									
								
								core/src/menus/Caratula.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								core/src/menus/Caratula.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| package menus; | ||||
| 
 | ||||
| import com.badlogic.gdx.graphics.Texture; | ||||
| import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||||
| import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||||
| 
 | ||||
| public class Caratula { | ||||
| 	TextureRegion caratula; | ||||
| 	String nombre; | ||||
| 	public Caratula(String ruta, String nombre, int x, int y, int width, int height) { | ||||
| 		this.caratula=new TextureRegion(new Texture(ruta), x, y, width, height); | ||||
| 		this.nombre=nombre; | ||||
| 	} | ||||
| 	 | ||||
| 	public void draw(SpriteBatch batch, float x, float y) { | ||||
| 		batch.draw(this.caratula, x, y); | ||||
| 	} | ||||
| 	 | ||||
| } | ||||
| @ -20,7 +20,8 @@ public abstract class Menu { | ||||
| 	static final int FHD=2; | ||||
| 	static final int INICIAL=0; | ||||
| 	static final int OPCIONES=1; | ||||
| 	static final int BATTLE=2; | ||||
| 	static final int SELEC=2; | ||||
| 	static final int BATTLE=3; | ||||
| 	int local; | ||||
| 	static int resolution; | ||||
| 	BitmapFont font; | ||||
|  | ||||
| @ -30,7 +30,7 @@ public class MenuInicio extends Menu{ | ||||
| 	 | ||||
| 	int darSeleccionado() { | ||||
| 		switch(this.position) { | ||||
| 		case 0:return Menu.BATTLE; | ||||
| 		case 0:return Menu.SELEC; | ||||
| 		case 1:return Menu.OPCIONES; | ||||
| 		default: return -1; | ||||
| 		} | ||||
|  | ||||
							
								
								
									
										76
									
								
								core/src/menus/MenuSeleccion.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								core/src/menus/MenuSeleccion.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,76 @@ | ||||
| package menus; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| 
 | ||||
| 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; | ||||
| import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; | ||||
| 
 | ||||
| public class MenuSeleccion extends Menu{ | ||||
| 	 | ||||
| 	ArrayList<Caratula> caratulas; | ||||
| 	ShapeRenderer shapeDrawer; | ||||
| 	 | ||||
| 	public MenuSeleccion() { | ||||
| 		super(); | ||||
| 		this.shapeDrawer=new ShapeRenderer(); | ||||
| 		this.n_opciones=3; | ||||
| 		this.local=Menu.SELEC; | ||||
| 		this.caratulas=new ArrayList<Caratula>(); | ||||
| 		this.caratulas.add(new Caratula("p1.png", "ryu", 984, 88, 128, 110)); | ||||
| 		this.caratulas.add(new Caratula("p2.png", "ken", 228, 565, 128, 110)); | ||||
| 		this.caratulas.add(new Caratula("p3.png", "cam", 243,0,128, 110)); | ||||
| 	} | ||||
| 	 | ||||
| 	@Override | ||||
| 	public int draw(SpriteBatch batch, float delta) { | ||||
| 		for(int i=0; i<this.caratulas.size();i++) { | ||||
| 			if(i<3) { | ||||
| 				if(i==this.position) { | ||||
| 					batch.end(); | ||||
| 					shapeDrawer.begin(ShapeType.Filled); | ||||
| 					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; | ||||
| 				String malo = this.caratulas.get((int) Math.round(Math.random()*(this.caratulas.size()-1))).nombre; | ||||
| 				Menu.menus.add(new Battle(this.caratulas.get(this.position).nombre, malo)); | ||||
| 				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; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										35
									
								
								core/src/utilidades/Bot.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								core/src/utilidades/Bot.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| package utilidades; | ||||
| 
 | ||||
| import com.badlogic.gdx.Gdx; | ||||
| import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||||
| 
 | ||||
| public class Bot extends Personaje{ | ||||
| 
 | ||||
| 	public Bot(String caracter, boolean position) { | ||||
| 		super(caracter, position); | ||||
| 	} | ||||
| 	 | ||||
| 	public void mover() { | ||||
| 		int mover = (int)Math.round(Math.random()*3); | ||||
| 		if (mover == 1) { | ||||
| 			if(this.position) { | ||||
| 				this.y++; | ||||
| 			}else { | ||||
| 				if(!this.caja.overlaps(enemigo)) { | ||||
| 					this.y++; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		if (mover == 2) { | ||||
| 			if(!this.position) { | ||||
| 				this.y--; | ||||
| 			}else { | ||||
| 				if(!this.caja.overlaps(enemigo)) { | ||||
| 					this.y--; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		this.caja.setPosition(x, y); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| @ -1,6 +1,12 @@ | ||||
| package utilidades; | ||||
| 
 | ||||
| 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; | ||||
| import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; | ||||
| import com.badlogic.gdx.math.Rectangle; | ||||
| 
 | ||||
| public class Personaje { | ||||
| 	Gifs standby; | ||||
| @ -12,7 +18,30 @@ public class Personaje { | ||||
| 	public static final int ALTO=1; | ||||
| 	public static final int MEDIO=2; | ||||
| 	public static final int BAJO=3; | ||||
| 	private int keyR; | ||||
| 	private int keyL; | ||||
| 	int x; | ||||
| 	int y; | ||||
| 	private float vida; | ||||
| 	Rectangle caja; | ||||
| 	Rectangle enemigo; | ||||
| 	boolean position; | ||||
| 	ShapeRenderer shapeDrawer; | ||||
| 	public Personaje(String caracter, boolean position) { | ||||
| 		shapeDrawer=new ShapeRenderer(); | ||||
| 		//PolygonShape shape = new PolygonShape(1); | ||||
| 		this.vida=100; | ||||
| 		this.position=position; | ||||
| 		if(position) { | ||||
| 			this.x=10; | ||||
| 			this.y=250; | ||||
| 		}else { | ||||
| 			this.x=10; | ||||
| 			this.y=150; | ||||
| 		} | ||||
| 		this.caja=new Rectangle(x, y,70,70); | ||||
| 		this.keyR=Input.Keys.D; | ||||
| 		this.keyL=Input.Keys.A; | ||||
| 		switch (caracter) { | ||||
| 		case "ryu": | ||||
| 			this.ryu(position); | ||||
| @ -20,6 +49,8 @@ public class Personaje { | ||||
| 		case "ken": | ||||
| 			this.ken(position); | ||||
| 			break; | ||||
| 		case "cam": | ||||
| 			this.cam(position); | ||||
| 		default: | ||||
| 			break; | ||||
| 		} | ||||
| @ -43,22 +74,94 @@ public class Personaje { | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public void draw(SpriteBatch batch, float delta, int x, int y) { | ||||
| 		this.actual.avanzar(10, delta); | ||||
| 		this.actual.draw(batch, x, y); | ||||
| 	public void recivir(float danio) { | ||||
| 		if(this.caja.overlaps(enemigo)) { | ||||
| 			this.vida-=danio; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public float atacar(float delta) { | ||||
| 		if(this.actual==this.medio) { | ||||
| 			return delta*10; | ||||
| 		} | ||||
| 		if(this.actual==this.alto) { | ||||
| 			return delta*15; | ||||
| 		} | ||||
| 			return 0; | ||||
| 	} | ||||
| 	 | ||||
| 	public void mover() { | ||||
| 		 | ||||
| 		if (Gdx.input.isKeyPressed(this.keyR)) { | ||||
| 			if(this.position) { | ||||
| 				this.y++; | ||||
| 			}else { | ||||
| 				if(!this.caja.overlaps(enemigo)) { | ||||
| 					this.y++; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		if (Gdx.input.isKeyPressed(this.keyL)) { | ||||
| 			if(!this.position) { | ||||
| 				this.y--; | ||||
| 			}else { | ||||
| 				if(!this.caja.overlaps(enemigo)) { | ||||
| 					this.y--; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		this.caja.setPosition(x, y); | ||||
| 	} | ||||
| 	 | ||||
| 	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); | ||||
| 		if(this.position) { | ||||
| 			shapeDrawer.rect(550-(this.vida-100)*3, 400, this.vida*3, 10); | ||||
| 		}else { | ||||
| 			shapeDrawer.rect(45, 400, this.vida*3, 10); | ||||
| 		} | ||||
| 		shapeDrawer.end(); | ||||
| 		batch.begin(); | ||||
| 	} | ||||
| 	 | ||||
| 	public void dispose() { | ||||
| 		shapeDrawer.dispose(); | ||||
| 		this.actual.dispose(); | ||||
| 	} | ||||
| 	 | ||||
| 	private void ryu(boolean 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.alto=new Gifs("p1.png", 3, 8, 74, 779, 75, 130, position); | ||||
| 	} | ||||
| 	 | ||||
| 	private void ken(boolean 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.alto=new Gifs("p2.png", 3, 6, 74, 2920, 75, 130, position); | ||||
| 	} | ||||
| 	 | ||||
| 	private void cam(boolean 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.alto=new Gifs("p3.png", 2, 192, 68, 1327, 60, 100, position); | ||||
| 	} | ||||
| 	 | ||||
| 	public Rectangle getCaja() { | ||||
| 		return this.caja; | ||||
| 	} | ||||
| 	 | ||||
| 	public void setEnemigo(Rectangle enemigo) { | ||||
| 		this.enemigo=enemigo; | ||||
| 	} | ||||
| 	 | ||||
| 	public boolean muerto() { | ||||
| 		return this.vida<0; | ||||
| 	} | ||||
| } | ||||
|  | ||||
							
								
								
									
										1
									
								
								desktop/bin/main/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								desktop/bin/main/.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -2,3 +2,4 @@ | ||||
| /p1.png | ||||
| /p2.png | ||||
| /sueloChina.png | ||||
| /p3.png | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user