Entrada 4

13
Proyecto Integrador Entrega 4

Transcript of Entrada 4

Page 1: Entrada 4

Proyecto Integrador

Entrega 4

Page 2: Entrada 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);

Page 3: Entrada 4

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);

Page 4: Entrada 4

// 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);

Page 5: Entrada 4

//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);

Page 6: Entrada 4

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>();

Page 7: Entrada 4

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);

Page 8: Entrada 4

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;

Page 9: Entrada 4

// 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);

Page 10: Entrada 4

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);

Page 11: Entrada 4

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);

Page 12: Entrada 4

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);

Page 13: Entrada 4