Skip to content

Commit

Permalink
added projectile class but dont have time to finish
Browse files Browse the repository at this point in the history
  • Loading branch information
john kavanagh committed Sep 1, 2015
1 parent 1957bcd commit a66e3eb
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 9 deletions.
Binary file modified bin/BawsePhighter.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/Boss.class
Binary file not shown.
Binary file added bin/classes/com/bawsephighter/GameScene$1.class
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/GameScene.class
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/Player.class
Binary file not shown.
Binary file added bin/classes/com/bawsephighter/Projectile.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified bin/dexedLibs/appcompat_v7-e1ceeea49e4ff6e6ca6882136ade5f89.jar
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
8 changes: 2 additions & 6 deletions src/com/bawsephighter/Boss.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Boss(float pX, float pY, VertexBufferObjectManager vbo, PhysicsWorld phys
}

private void createPhysics(PhysicsWorld physicsWorld){
body = PhysicsFactory.createBoxBody(physicsWorld, this, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(0, 0, 0));
body = PhysicsFactory.createBoxBody(physicsWorld, this, BodyType.KinematicBody, PhysicsFactory.createFixtureDef(0, 0, 0));
body.setUserData("boss");
body.setLinearDamping(5);
body.setFixedRotation(true);
Expand All @@ -29,11 +29,7 @@ private void createPhysics(PhysicsWorld physicsWorld){
}

public void setX(float pX){
body.setLinearVelocity(pX, body.getLinearVelocity().y);
}

public void setY(float pY){
body.setLinearVelocity(body.getLinearVelocity().x, pY);
body.setLinearVelocity(pX, 0);
}

public int getLives(){
Expand Down
40 changes: 37 additions & 3 deletions src/com/bawsephighter/GameScene.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bawsephighter;

import java.util.ArrayList;

import org.andengine.engine.camera.hud.HUD;
import org.andengine.entity.scene.IOnSceneTouchListener;
import org.andengine.entity.scene.Scene;
Expand Down Expand Up @@ -43,6 +45,8 @@ public class GameScene<SimpleLevelEntityLoaderData> extends BaseScene implements

private Player player;
private Boss boss;

private ArrayList<Projectile> projectiles = new ArrayList<Projectile>();

private void createHUD(){
gameHUD = new HUD();
Expand All @@ -52,7 +56,7 @@ private void createHUD(){
bossHealth.setSkewCenter(0, 0);
bossHealth.setScale(0.5f);
bossHealth.setText("Bawse Health: 100");
bossHealth.setColor(0,0,0);
bossHealth.setColor(255,0,255);
gameHUD.attachChild(bossHealth);

// CREATE player health
Expand Down Expand Up @@ -80,9 +84,35 @@ private void AddScore(int i){
}

private void createPhysics(){
physicsWorld = new FixedStepPhysicsWorld(60, new Vector2(0, 0), false);
physicsWorld = new FixedStepPhysicsWorld(60, new Vector2(0, 0), false){
@Override
public void onUpdate(float pSecondsElapsed){
super.onUpdate(pSecondsElapsed);
shoot();
BossAI();

ArrayList projectiles = getProjectiles();
for (int i = 0; i < projectiles.size(); i++) {
Projectile p = (Projectile) projectiles.get(i);
if (p.isVisible() == true) {
p.update();
} else {
projectiles.remove(i);
}
}
}
};
registerUpdateHandler(physicsWorld);
}

public void shoot() {
Projectile p = new Projectile(player.getX() + 30, player.getY());
projectiles.add(p);
}

public ArrayList getProjectiles() {
return projectiles;
}

private void createBackground(){
setBackground(new Background(255, 255, 255));
Expand Down Expand Up @@ -138,7 +168,7 @@ public void createObjects(){
player = new Player(300, 400, vbom, physicsWorld);
attachChild(player);

boss = new Boss(300, -50, vbom, physicsWorld);
boss = new Boss(300, 0, vbom, physicsWorld);
attachChild(boss);
}

Expand All @@ -152,6 +182,10 @@ public SceneType getSceneType(){
return SceneType.SCENE_GAME;
}

public void BossAI(){

}

@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
float touchFromRight = pSceneTouchEvent.getX() - (player.getX() + player.getWidth());
Expand Down
1 change: 1 addition & 0 deletions src/com/bawsephighter/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;

public class Player extends Sprite {

private Body body;
private int health;

Expand Down
52 changes: 52 additions & 0 deletions src/com/bawsephighter/Projectile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.bawsephighter;

public class Projectile {
private float x, y, speedX, speedY;
private boolean visible;

public Projectile(float startX, float startY) {
x = startX;
y = startY;
speedY = -7;
visible = true;
}

public void update(){
y += speedY;
if (y < 0) {
visible = false;
}
}

public float getX() {
return x;
}

public float getY() {
return y;
}

public float getSpeedX() {
return speedX;
}

public boolean isVisible() {
return visible;
}

public void setX(int x) {
this.x = x;
}

public void setY(int y) {
this.y = y;
}

public void setSpeedX(int speedX) {
this.speedX = speedX;
}

public void setVisible(boolean visible) {
this.visible = visible;
}
}

0 comments on commit a66e3eb

Please sign in to comment.