Post on 11-Jul-2015
Proyecto Integrador
Entrega 4
Creación de nave
// se declara objeto Player_1
static final int VelocityPlayer_1 = 300;
private Player Player_1;
// Cargamos la carpeta de recursos gfx, donde estan las
imágenes que usaremos para la nave, mapa, enemigos y disparos.
BitmapTextureRegionFactory.setAssetBasePath("gfx/");
// asignamos un espacio para Player_1, su imagen, textura y
posición inicial
this.BitmapTexture_Player_1 = new BitmapTexture(128, 128,
TextureOptions.DEFAULT);
this.TextureRegion_Player1 = BitmapTextureRegionFactory
.createTiledFromAsset(this.BitmapTexture_Player_1, this,
"Player_1.png", 0, 0, 1, 1);
this.mEngine.getTextureManager().loadTexture(
this.BitmapTexture_Player_1);
Creación de mapa
// Cargamos el mapa a la Pantalla y el player al mapa
this.BackgroundTexture = new BitmapTexture(1024, 1024,
TextureOptions.DEFAULT);
this.BackgroundLayerBack =
BitmapTextureRegionFactory.createFromAsset(
this.BackgroundTexture, this, "background.png", 0, 0);
this.mEngine.getTextureManager().loadTextures(
this.BitmapTexture_Player_1, this.BackgroundTexture);
// Camara
static final int CAMERA_WIDTH = 800;
static final int CAMERA_HEIGHT = 480;al int CAMERA_HEIGHT = 480;
// Margenes Pantalla
public Shape ground;
public Shape roof;
public Shape left;
public Shape right;
ground = new Rectangle(0, CAMERA_HEIGHT -25, CAMERA_WIDTH, 25);
roof = new Rectangle(0, 0, CAMERA_WIDTH, 25);
left = new Rectangle(0, 0, 50, CAMERA_HEIGHT);
right = new Rectangle(CAMERA_WIDTH -50, 0, 50, CAMERA_HEIGHT);
//Pondremos como no visibles los margenes ya que solo
se deben mostrar durante el juego
ground.setVisible(false);
roof.setVisible(false);
left.setVisible(false);
right.setVisible(false);
scene.attachChild(ground);
scene.attachChild(roof);
scene.attachChild(left);
scene.attachChild(right);
Creacion de enemigos
// Declaración de objeto enemigo, su bitmap , su
textura , cantidad de enemigos y una lista que nos
ayudara a enlistar la manera en que aparecerán.
private BitmapTexture BitmapTexture_EnemyUFO;
private TiledTextureRegion TextureRegion_EnemyUFO;
public int num_Enemy = 5;
private ArrayList<Enemy> listaEnemigos = new
ArrayList<Enemy>();
Creacion de enemigos
// Asignacion de espacio, textura, imagen y posicion
del enemigo
this.BitmapTexture_EnemyUFO = new BitmapTexture(512,
512,
TextureOptions.DEFAULT);
this.TextureRegion_EnemyUFO =
BitmapTextureRegionFactory
.createTiledFromAsset(this.BitmapTexture_EnemyUFO,
this,
"EnemyUFO.png", 0, 0, 8, 5);
this.mEngine.getTextureManager().loadTexture(
this.BitmapTexture_EnemyUFO);
Control de movimiento
//Declaracion del Joystick, para el movimiento de
la nave
private DigitalOnScreenControl
mDigitalOnScreenControl;
private BitmapTexture mOnScreenControlTexture;
private TextureRegion
mOnScreenControlBaseTextureRegion;
private TextureRegion
mOnScreenControlKnobTextureRegion;
public float DigitalControlX = 0;
public float DigitalControlY = 0;
// Cargamos las imagenes del joystick, dandole un espacio, textura y
posicion dentro del mapa
this.mOnScreenControlTexture = new BitmapTexture(256, 128,
TextureOptions.BILINEAR_PREMULTIPLYALPHA);
this.mOnScreenControlBaseTextureRegion = BitmapTextureRegionFactory
.createFromAsset(this.mOnScreenControlTexture, this,
"onscreen_control_base.png", 0, 0);
//Cargamos el control de movimiento digital
this.mOnScreenControlKnobTextureRegion = BitmapTextureRegionFactory
.createFromAsset(this.mOnScreenControlTexture, this,
"onscreen_control_knob.png", 128, 0);
this.mEngine.getTextureManager().loadTextures(
this.BitmapTexture_Player_1, this.mOnScreenControlTexture);
Botón de Disparos
// Declaración de Boton disparar
private BitmapTexture BitmapTexture_boton_Disparo;
private TextureRegion TextureRegion_boton_Disparo;
// Cargamos la imagen Boton disparo, en un espacio, con textura y su posicion
BitmapTexture_boton_Disparo = new BitmapTexture(128, 128,
TextureOptions.DEFAULT);
TextureRegion_boton_Disparo = BitmapTextureRegionFactory
.createFromAsset(BitmapTexture_boton_Disparo, this,
"botonDisparar.png", 0, 0);
mEngine.getTextureManager().loadTexture(
this.BitmapTexture_boton_Disparo);
Disparos
//Declaración del Disparo
private BitmapTexture BitmapTexture_Disparo;
public TiledTextureRegion TextureRegion_Disparo;
private ArrayList<Disparo> listaDisparos = new
ArrayList<Disparo>();
public boolean flag_disparo = false;
// Agregamos el Disparoa la pantalla en un espacio, con textura
y la posicion inicial
this.BitmapTexture_Disparo = new BitmapTexture(64, 64,
TextureOptions.DEFAULT);
this.TextureRegion_Disparo = BitmapTextureRegionFactory
.createTiledFromAsset(this.BitmapTexture_Disparo, this,
"disparo.png", 0, 0, 1, 2);
this.mEngine.getTextureManager()
.loadTexture(this.BitmapTexture_Disparo);
Barra de vida
// Level Live
public Rectangle level_life;
private BitmapTexture BitmapTexture_level_life_Background;
private TextureRegion TextureRegion_level_life_Background;
// Cargamos imagenes de la barra de vida con sus datos correspondientes
BitmapTexture_level_life_Background = new BitmapTexture(128, 32,
TextureOptions.DEFAULT);
TextureRegion_level_life_Background = BitmapTextureRegionFactory
.createFromAsset(this.BitmapTexture_level_life_Background,
this, "level_life_background.png", 0, 0);
mEngine.getTextureManager().loadTexture(
BitmapTexture_level_life_Background);