Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix healthy change and instruction #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added Resources/.DS_Store
Binary file not shown.
Binary file added Resources/Backgrounds/optionBG2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/main/.DS_Store
Binary file not shown.
Binary file added src/main/java/al/.DS_Store
Binary file not shown.
41 changes: 33 additions & 8 deletions src/main/java/al/artofsoul/batbatgame/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Player extends al.artofsoul.batbatgame.entity.MapObject {
protected long time;
// actions
protected boolean dashing;

private int getHitLossHp;
protected boolean attacking;
protected boolean upattacking;
protected boolean charging;
Expand Down Expand Up @@ -104,7 +104,7 @@ public Player(TileMap tm) {

facingRight = true;

lives = 3;
lives = 5;
health = maxHealth = 5;

// load sprites
Expand Down Expand Up @@ -137,12 +137,14 @@ public Player(TileMap tm) {

setAnimation(IDLE_ANIM);

/*JukeBox.load("/SFX/playerjump.mp3", PLAYERJUMP_MUSIC_NAME);
/*
JukeBox.load("/SFX/playerjump.mp3", PLAYERJUMP_MUSIC_NAME);
JukeBox.load("/SFX/playerlands.mp3", "playerlands");
JukeBox.load("/SFX/playerattack.mp3", PLAYERATTACK_MUSIC_NAME);
JukeBox.load("/SFX/playerhit.mp3", "playerhit");
JukeBox.load("/SFX/playercharge.mp3", "playercharge");*/


}

public void init(List<al.artofsoul.batbatgame.entity.Enemy> enemies, List<al.artofsoul.batbatgame.entity.EnergyParticle> energyParticles) {
Expand Down Expand Up @@ -196,7 +198,7 @@ public void setCharging() {
return;
if (!attacking && !upattacking && !charging) {
charging = true;
JukeBox.play("playercharge");
//JukeBox.play("playercharge");
chargingTick = 0;
}
}
Expand All @@ -215,6 +217,10 @@ else if (!falling) {

public void setDead() {
health = 0;
// if (getTime() >20 ){
// stop();
// }

stop();
}

Expand All @@ -223,6 +229,12 @@ public String getTimeToString() {
int seconds = (int) ((time % 3600) / 60);
return seconds < 10 ? minutes + ":0" + seconds : minutes + ":" + seconds;
}
public String getScoreToString() {
int score = getScore();
return "score is:" + score;
}



public long getTime() {
return time;
Expand All @@ -231,12 +243,16 @@ public long getTime() {
public void setTime(long t) {
time = t;
}
public void setScore(int i) {
score = i;
}

public void gainLife() {
lives++;
}

public void loseLife() {
// System.out.println("******************");
lives--;
}

Expand All @@ -261,7 +277,9 @@ public void hit(int damage) {
return;
//JukeBox.play("playerhit");
stop();

// System.out.println("===========");
// System.out.println(health);
getHitLossHp = 50;
health -= damage;
if (health < 0)
health = 0;
Expand All @@ -286,6 +304,7 @@ public void reset() {

public void stop() {
left = right = up = down = flinching = dashing = jumping = attacking = upattacking = charging = false;

}

protected void getNextPosition() {
Expand All @@ -307,14 +326,14 @@ private void jumpAndFall() {
if (jumping && !falling) {
dy = jumpStart;
falling = true;
JukeBox.play(PLAYERJUMP_MUSIC_NAME);
// JukeBox.play(PLAYERJUMP_MUSIC_NAME);
}

if (doubleJump) {
dy = doubleJumpStart;
alreadyDoubleJump = true;
doubleJump = false;
JukeBox.play(PLAYERJUMP_MUSIC_NAME);
//JukeBox.play(PLAYERJUMP_MUSIC_NAME);
for (int i = 0; i < 6; i++) {
energyParticles.add(new al.artofsoul.batbatgame.entity.EnergyParticle(tileMap, x, y + cheight / 4.0, al.artofsoul.batbatgame.entity.EnergyParticle.ENERGY_DOWN));
}
Expand Down Expand Up @@ -379,6 +398,7 @@ private void setAnimation(int i) {
public void update() {

time++;
score++;

// check teleporting
if (teleporting) {
Expand All @@ -391,7 +411,7 @@ public void update() {
checkTileMapCollision();
setPosition(xtemp, ytemp);
if (isFalling && !falling) {
JukeBox.play("playerlands");
//JukeBox.play("playerlands");
}
if (dx == 0)
x = (int) x;
Expand Down Expand Up @@ -572,6 +592,11 @@ public void draw(Graphics2D g) {
if (flinching && !knockback && flinchCount % 10 < 5) {
return;
}
if(getHitLossHp > 0){
g.drawString("HP-1", 240, 133);
getHitLossHp --;
}


super.draw(g);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
public class OptionsState extends BasicState {

final ImageIcon howTo = new ImageIcon(getClass().getResource("/Backgrounds/howTo.gif"));
//final ImageIcon howTo = new ImageIcon(getClass().getResource("/Backgrounds/optionBG2.gif"));

public OptionsState(GameStateManager gsm) {

super(gsm);
options = new String[]{"HowTo Play", "Back"};
options = new String[]{"How To Play", "Back"};
}

@Override
Expand Down