inicio personajes y partida
This commit is contained in:
		
							parent
							
								
									f72eede716
								
							
						
					
					
						commit
						32b63d42c4
					
				
							
								
								
									
										
											BIN
										
									
								
								core/assets/iconos.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								core/assets/iconos.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.5 MiB | 
							
								
								
									
										
											BIN
										
									
								
								core/assets/p1.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								core/assets/p1.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 18 MiB | 
							
								
								
									
										
											BIN
										
									
								
								core/assets/p2.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								core/assets/p2.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 34 MiB | 
							
								
								
									
										
											BIN
										
									
								
								core/assets/sueloChina.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								core/assets/sueloChina.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 512 KiB | 
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										4
									
								
								core/bin/main/menus/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								core/bin/main/menus/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | |||||||
|  | /Menu.class | ||||||
|  | /MenuInicio.class | ||||||
|  | /MenuOpcions.class | ||||||
|  | /Battle.class | ||||||
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2
									
								
								core/bin/main/utilidades/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								core/bin/main/utilidades/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | |||||||
|  | /Gifs.class | ||||||
|  | /Personaje.class | ||||||
										
											Binary file not shown.
										
									
								
							| @ -3,11 +3,10 @@ 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.graphics.GL20; | import com.badlogic.gdx.graphics.GL20; | ||||||
| import com.badlogic.gdx.graphics.Texture; |  | ||||||
| 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 com.badlogic.gdx.graphics.g2d.TextureRegion; |  | ||||||
| 
 | 
 | ||||||
|  | import menus.Battle; | ||||||
| import menus.Menu; | import menus.Menu; | ||||||
| import menus.MenuInicio; | import menus.MenuInicio; | ||||||
| import menus.MenuOpcions; | import menus.MenuOpcions; | ||||||
| @ -15,25 +14,22 @@ import utilidades.Gifs; | |||||||
| 
 | 
 | ||||||
| public class MyGdxGame extends ApplicationAdapter { | public class MyGdxGame extends ApplicationAdapter { | ||||||
| 	SpriteBatch batch; | 	SpriteBatch batch; | ||||||
| 	Texture img; |  | ||||||
| 	BitmapFont font; | 	BitmapFont font; | ||||||
| 	int WIN_ALT; | 	int WIN_ALT; | ||||||
| 	int WIN_ANCH; | 	int WIN_ANCH; | ||||||
| 	private TextureRegion[] 	regions = new TextureRegion[14];	 |  | ||||||
| 	float contadorGif = 0; | 	float contadorGif = 0; | ||||||
| 	Gifs pinchos; | 	Gifs pinchos; | ||||||
| 	int menuSeleccionado=0; | 	int menuSeleccionado=0; | ||||||
| 	@Override | 	@Override | ||||||
| 	public void create () { | 	public void create () { | ||||||
| 		batch = new SpriteBatch(); | 		batch = new SpriteBatch(); | ||||||
| 		img = new Texture("125760.png"); |  | ||||||
| 		font = new BitmapFont(Gdx.files.internal("CentieSans.fnt")); | 		font = new BitmapFont(Gdx.files.internal("CentieSans.fnt")); | ||||||
| 		WIN_ALT=900; | 		WIN_ALT=900; | ||||||
| 		WIN_ANCH=700; | 		WIN_ANCH=700; | ||||||
| 		Gdx.graphics.setWindowedMode(WIN_ALT, WIN_ANCH); | 		Gdx.graphics.setWindowedMode(WIN_ALT, WIN_ANCH); | ||||||
| 		pinchos = new Gifs(img, 14, 39, 49, 15, 40, 40); |  | ||||||
| 		Menu.menus.add(new MenuInicio()); | 		Menu.menus.add(new MenuInicio()); | ||||||
| 		Menu.menus.add(new MenuOpcions()); | 		Menu.menus.add(new MenuOpcions()); | ||||||
|  | 		Menu.menus.add(new Battle()); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| @ -61,7 +57,7 @@ public class MyGdxGame extends ApplicationAdapter { | |||||||
| 	@Override | 	@Override | ||||||
| 	public void dispose () { | 	public void dispose () { | ||||||
| 		batch.dispose(); | 		batch.dispose(); | ||||||
| 		img.dispose(); |  | ||||||
| 		font.dispose(); | 		font.dispose(); | ||||||
|  | 		Menu.menus.get(this.menuSeleccionado).dispose(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										40
									
								
								core/src/menus/Battle.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								core/src/menus/Battle.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | package menus; | ||||||
|  | 
 | ||||||
|  | import com.badlogic.gdx.Gdx; | ||||||
|  | import com.badlogic.gdx.Input; | ||||||
|  | import com.badlogic.gdx.graphics.Texture; | ||||||
|  | import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||||||
|  | 
 | ||||||
|  | import utilidades.Personaje; | ||||||
|  | 
 | ||||||
|  | public class Battle extends Menu{ | ||||||
|  | 	 | ||||||
|  | 	Personaje p1; | ||||||
|  | 	Personaje p2; | ||||||
|  | 	Texture suelo; | ||||||
|  | 	public Battle() { | ||||||
|  | 		this.p2=new Personaje("ken", true); | ||||||
|  | 		this.p1=new Personaje("ryu", false); | ||||||
|  | 		suelo = new Texture("sueloChina.png"); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public int draw(SpriteBatch batch, float delta) { | ||||||
|  | 		batch.draw(suelo,0,0); | ||||||
|  | 		if (Gdx.input.isKeyPressed(Input.Keys.E)) { | ||||||
|  | 			p1.cambiarEstado(p1.MEDIO); | ||||||
|  | 		}else { | ||||||
|  | 			p1.cambiarEstado(p1.STAND); | ||||||
|  | 		} | ||||||
|  | 		this.p1.draw(batch, delta, 150, 10); | ||||||
|  | 		this.p2.draw(batch, delta, 250, 10); | ||||||
|  | 		return Menu.BATTLE; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	@Override | ||||||
|  | 	int darSeleccionado() { | ||||||
|  | 		 | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -20,6 +20,7 @@ public abstract class Menu { | |||||||
| 	static final int FHD=2; | 	static final int FHD=2; | ||||||
| 	static final int INICIAL=0; | 	static final int INICIAL=0; | ||||||
| 	static final int OPCIONES=1; | 	static final int OPCIONES=1; | ||||||
|  | 	static final int BATTLE=2; | ||||||
| 	int local; | 	int local; | ||||||
| 	static int resolution; | 	static int resolution; | ||||||
| 	BitmapFont font; | 	BitmapFont font; | ||||||
| @ -29,13 +30,14 @@ public abstract class Menu { | |||||||
| 		this.position=0; | 		this.position=0; | ||||||
| 		this.pres=true; | 		this.pres=true; | ||||||
| 		font = new BitmapFont(Gdx.files.internal("CentieSans.fnt")); | 		font = new BitmapFont(Gdx.files.internal("CentieSans.fnt")); | ||||||
| 		selector = new Gifs("125760.png", 14, 39, 49, 15, 40, 40); | 		selector = new Gifs("iconos.png", 14, 39, 49, 15, 40, 40, false); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	abstract public int draw(SpriteBatch batch, float delta); | 	abstract public int draw(SpriteBatch batch, float delta); | ||||||
| 	 | 	 | ||||||
| 	void dispose() { | 	public void dispose() { | ||||||
| 		font.dispose(); | 		font.dispose(); | ||||||
|  | 		selector.dispose(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	int cambiarSeleccionado() { | 	int cambiarSeleccionado() { | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ public class MenuInicio extends Menu{ | |||||||
| 	 | 	 | ||||||
| 	int darSeleccionado() { | 	int darSeleccionado() { | ||||||
| 		switch(this.position) { | 		switch(this.position) { | ||||||
| 		case 0:return 2; | 		case 0:return Menu.BATTLE; | ||||||
| 		case 1:return Menu.OPCIONES; | 		case 1:return Menu.OPCIONES; | ||||||
| 		default: return -1; | 		default: return -1; | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -11,13 +11,14 @@ public class Gifs { | |||||||
| 	private float contadorEstado; | 	private float contadorEstado; | ||||||
| 	 | 	 | ||||||
| 	public Gifs(String ruta, int n_estados, int inicio_image, int desplazamiento,  | 	public Gifs(String ruta, int n_estados, int inicio_image, int desplazamiento,  | ||||||
| 			int anchura, int x, int y) { | 			int anchura, int x, int y, boolean flip) { | ||||||
| 		textura = new Texture(ruta); | 		textura = new Texture(ruta); | ||||||
| 		this.n_estados = n_estados; | 		this.n_estados = n_estados; | ||||||
| 		frames = new TextureRegion[n_estados]; | 		frames = new TextureRegion[n_estados]; | ||||||
| 		for(int i = 0; i<n_estados; i++) { | 		for(int i = 0; i<n_estados; i++) { | ||||||
| 			frames[i] = new TextureRegion(textura, inicio_image+i*desplazamiento | 			frames[i] = new TextureRegion(textura, inicio_image+(i*desplazamiento) | ||||||
| 					, anchura, x, y); | 					, anchura, x, y); | ||||||
|  | 			frames[i].flip(flip, false); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -40,5 +41,7 @@ public class Gifs { | |||||||
| 	public void draw(SpriteBatch batch, float x, float y) { | 	public void draw(SpriteBatch batch, float x, float y) { | ||||||
| 		batch.draw(this.frames[(int)contadorEstado], x, y); | 		batch.draw(this.frames[(int)contadorEstado], x, y); | ||||||
| 	} | 	} | ||||||
| 	 | 	public void dispose() { | ||||||
|  | 		this.textura.dispose(); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										64
									
								
								core/src/utilidades/Personaje.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								core/src/utilidades/Personaje.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,64 @@ | |||||||
|  | package utilidades; | ||||||
|  | 
 | ||||||
|  | import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||||||
|  | 
 | ||||||
|  | public class Personaje { | ||||||
|  | 	Gifs standby; | ||||||
|  | 	Gifs medio; | ||||||
|  | 	Gifs alto; | ||||||
|  | 	Gifs bajo; | ||||||
|  | 	Gifs actual; | ||||||
|  | 	public static final int STAND=0; | ||||||
|  | 	public static final int ALTO=1; | ||||||
|  | 	public static final int MEDIO=2; | ||||||
|  | 	public static final int BAJO=3; | ||||||
|  | 	public Personaje(String caracter, boolean position) { | ||||||
|  | 		switch (caracter) { | ||||||
|  | 		case "ryu": | ||||||
|  | 			this.ryu(position); | ||||||
|  | 			break; | ||||||
|  | 		case "ken": | ||||||
|  | 			this.ken(position); | ||||||
|  | 			break; | ||||||
|  | 		default: | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		this.actual=this.standby; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void cambiarEstado(int estado) { | ||||||
|  | 		switch(estado) { | ||||||
|  | 		case STAND: | ||||||
|  | 			this.actual=this.standby; | ||||||
|  | 			break; | ||||||
|  | 		case ALTO: | ||||||
|  | 			this.actual=this.alto; | ||||||
|  | 			break; | ||||||
|  | 		case MEDIO: | ||||||
|  | 			this.actual=this.medio; | ||||||
|  | 			break; | ||||||
|  | 		case BAJO: | ||||||
|  | 			this.actual=this.bajo; | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void draw(SpriteBatch batch, float delta, int x, int y) { | ||||||
|  | 		this.actual.avanzar(10, delta); | ||||||
|  | 		this.actual.draw(batch, x, y); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void 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); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	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); | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										4
									
								
								desktop/bin/main/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								desktop/bin/main/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | |||||||
|  | /iconos.png | ||||||
|  | /p1.png | ||||||
|  | /p2.png | ||||||
|  | /sueloChina.png | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user