Skip to content

Commit

Permalink
bug fix (i hope)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panda248 committed May 22, 2022
1 parent 03e680d commit c0bc91b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/entities/units/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public Unit(int level, int health, int attack, int defense, int critRate, int cr
public void setPosition(int x, int y) {
this.position = new Coordinate(x,y);
}
public void setPosition(Coordinate c) {this.position = c;}

public void takeDamage(int amount) {
this.health-=amount;
Expand Down
13 changes: 4 additions & 9 deletions src/entities/units/npc/NPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class NPC extends Unit {
public void setCombatState(EnemyStates combatState) {
this.combatState = combatState;
}
private int interactLength = 1000;
private int interactLength = 120;
private int timer;
private boolean isInteracting;
public EnemyStates getCombatState() {
Expand All @@ -31,28 +31,23 @@ public NPC(float x, float y) throws SlickException {//later change parameters to
this.sheet = new SpriteSheet("res/experimentalEnemy.png", 256, 512);
this.sprite = sheet.getSprite(0, 0);
this.level = 1;
this.timer = -1;
this.timer = interactLength;
}

public void render(GameContainer gc, float plrX, float plrY) {
if(isInteracting) timer++;
timer++;
gc.getGraphics().drawImage(sprite, -plrX - position.getX(), -plrY/2 - position.getY());
gc.getGraphics().setColor(new Color(255, 0,0,0.5f));
hitBox.setX(-plrX - position.getX() + width);
hitBox.setY((-plrY/2) + this.getHeight()*1.6f);

if(timer <= interactLength && timer > -1) {
if(timer < interactLength) {
DrawUtilities.drawStringCentered(gc.getGraphics(),"Hello!!", -plrX - position.getX(),-plrY/2 + this.getHeight());
}
else {
isInteracting = false;
timer = -1;
}
}

public void interact() {
timer = 0;
isInteracting = true;
}


Expand Down
4 changes: 4 additions & 0 deletions src/entities/units/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public Player(Coordinate pos) throws SlickException {
this.hitBox = new Rectangle((Main.getScreenWidth()/2) - this.getWidth()/2, (Main.getScreenHeight()/2) + 170, this.width, this.height-100); // set size to tiles
}

public void resetHitbox() {
this.hitBox = new Rectangle((Main.getScreenWidth()/2) - this.getWidth()/2, (Main.getScreenHeight()/2) + 170, this.width, this.height-100);
}

public void startBattle() {
queue = 5;
this.arteHand = new ArrayList<Arte>(arteDeck.subList(0,6));
Expand Down
20 changes: 11 additions & 9 deletions src/gamestates/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class Game extends BasicGameState {

private static GameContainer gc;
private final int id;

public static int time;
public static long battleTimeStamp;
public static int battleCooldown;
Expand Down Expand Up @@ -183,13 +182,15 @@ public void update(GameContainer gc, StateBasedGame sbg, int delta) throws Slick

public void enter(GameContainer gc, StateBasedGame sbg) throws SlickException {
System.out.println("Entering game");

plr.gainExp(BattleState.expGain);
plr.gainMoney(BattleState.currencyGain);
// Reset time
time = 0;
System.out.println("[VERBOSE] Time reset");
plr.gainExp(BattleState.expGain);
plr.gainMoney(BattleState.currencyGain);
/*// Initialize Both Entity Maps
//enemy = new Enemy(10,0);
//plr.setPosition(0,0);
//plrTeam.add(plr);
// Initialize Both Entity Maps
entities = new EnumMap<>(Map.of(
EntityType.UNIT, new ArrayList<>(),
EntityType.PROJECTILE, new ArrayList<>(),
Expand All @@ -202,8 +203,10 @@ public void enter(GameContainer gc, StateBasedGame sbg) throws SlickException {
));

// Initialize the Player
plr = new Player(plrPosition);
plrTeam.add(plr);
plr.setPosition(plrPosition);
plr.resetHitbox();
//plr = new Player(plrPosition);
//plrTeam.add(plr);
System.out.println("[VERBOSE] Player initialized");
enemy = new Enemy(10, 0);
enemyTeam.add(enemy);
Expand All @@ -214,14 +217,13 @@ public void enter(GameContainer gc, StateBasedGame sbg) throws SlickException {
System.out.println("[VERBOSE] DisplayManager initialized");

// Play BGM
SoundManager.playBackgroundMusic("02");*/
SoundManager.playBackgroundMusic("02");
}

public void leave(GameContainer gc, StateBasedGame sbg) {
// This code happens when you leave a gameState.
BattleState.plrs = plrTeam;
BattleState.enemies = enemyTeam;

}


Expand Down

0 comments on commit c0bc91b

Please sign in to comment.