Skip to content

Commit

Permalink
boss added no i need to add it's AI
Browse files Browse the repository at this point in the history
  • Loading branch information
john kavanagh committed Aug 31, 2015
1 parent 8ee99fd commit 1957bcd
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 1 deletion.
Binary file modified assets/firstboss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified bin/BawsePhighter.apk
Binary file not shown.
1 change: 1 addition & 0 deletions bin/R.txt
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ int layout select_dialog_multichoice_material 0x7f030021
int layout select_dialog_singlechoice_material 0x7f030022
int layout support_simple_spinner_dropdown_item 0x7f030023
int menu main 0x7f0c0000
int string HighScore 0x7f0a0015
int string abc_action_bar_home_description 0x7f0a0001
int string abc_action_bar_home_description_format 0x7f0a0005
int string abc_action_bar_home_subtitle_description_format 0x7f0a0006
Expand Down
Binary file modified bin/classes.dex
Binary file not shown.
Binary file added bin/classes/com/bawsephighter/Boss.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/R$string.class
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/R$style.class
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/R$styleable.class
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/ResourcesManager.class
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
1 change: 1 addition & 0 deletions gen/com/bawsephighter/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,7 @@ public static final class menu {
public static final int main=0x7f0c0000;
}
public static final class string {
public static final int HighScore=0x7f0a0015;
/** Content description for the action bar "home" affordance. [CHAR LIMIT=NONE]
*/
public static final int abc_action_bar_home_description=0x7f0a0001;
Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<string name="app_name">BawsePhighter</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="HighScore">0</string>

</resources>
46 changes: 46 additions & 0 deletions src/com/bawsephighter/Boss.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.bawsephighter;

import org.andengine.entity.sprite.Sprite;
import org.andengine.extension.physics.box2d.PhysicsConnector;
import org.andengine.extension.physics.box2d.PhysicsFactory;
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;

public class Boss extends Sprite {
private Body body;
private int health;

public Boss(float pX, float pY, VertexBufferObjectManager vbo, PhysicsWorld physicsWorld){
super(pX, pY, ResourcesManager.getInstance().boss_region, vbo);
health = 100;
createPhysics(physicsWorld);
}

private void createPhysics(PhysicsWorld physicsWorld){
body = PhysicsFactory.createBoxBody(physicsWorld, this, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(0, 0, 0));
body.setUserData("boss");
body.setLinearDamping(5);
body.setFixedRotation(true);

physicsWorld.registerPhysicsConnector(new PhysicsConnector(this, body, true, false));
}

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

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

public int getLives(){
return health;
}

public void loseLife(){
health += -1;
}
}
4 changes: 4 additions & 0 deletions src/com/bawsephighter/GameScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class GameScene<SimpleLevelEntityLoaderData> extends BaseScene implements
private ITextureRegion mBoundryTextureRegion;

private Player player;
private Boss boss;

private void createHUD(){
gameHUD = new HUD();
Expand Down Expand Up @@ -136,6 +137,9 @@ private void createBoundry(){
public void createObjects(){
player = new Player(300, 400, vbom, physicsWorld);
attachChild(player);

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

@Override
Expand Down
22 changes: 21 additions & 1 deletion src/com/bawsephighter/ResourcesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.debug.Debug;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;

public class ResourcesManager{
Expand All @@ -36,10 +38,13 @@ public class ResourcesManager{
public ITextureRegion play_region;
public ITextureRegion options_region;
public ITextureRegion player_region;
public ITextureRegion boss_region;
public Font font;

//Game
public BuildableBitmapTextureAtlas gameTextureAtlas;

public static SharedPreferences mSharedPref;

public void loadMenuResources(){
loadMenuGraphics();
Expand Down Expand Up @@ -71,7 +76,7 @@ private void loadMenuAudio(){
private void loadGameTextures(){
gameTextureAtlas = new BuildableBitmapTextureAtlas(activity.getTextureManager(), 2048, 2048, TextureOptions.BILINEAR);
player_region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "player.png");

boss_region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "firstboss.png");
try
{
gameTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));
Expand Down Expand Up @@ -132,8 +137,23 @@ public static void prepareManager(Engine engine, GameActivity activity, Camera c
getInstance().activity = activity;
getInstance().camera = camera;
getInstance().vbom = vbom;
mSharedPref = activity.getPreferences(Context.MODE_PRIVATE);
}


public void saveHighScore(int highScore) {
mSharedPref = activity.getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = mSharedPref.edit();
//editor.putInt(activity.getString(R.string.saved_high_score), highScore);
editor.commit();
}

public int getHighScore(){
int defaultValue = 0;
// int highScore = ResourcesManager.mSharedPref.getInt(activity.getString(R.string.saved_high_score), defaultValue);
return 1;
}

public static ResourcesManager getInstance(){
return INSTANCE;
}
Expand Down

0 comments on commit 1957bcd

Please sign in to comment.