Skip to content

Commit

Permalink
Added collidable merchants that act as objects
Browse files Browse the repository at this point in the history
  • Loading branch information
john committed Apr 25, 2015
1 parent 585740b commit 8bd30fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions MerchantRPGCSE2102/src/sprites/PlayerSprite.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public void keyReleased(KeyEvent e) {
}
if (e.getKeyCode() == KeyEvent.VK_F) {
if (isMerchantNearby())
mapui.game.createTransaction(mapui.map.getPlayer(), mapui.map.getCurrentNearbyMerchant()); // RPGame initializes Trade
if (mapui.getMap().getCurrentNearbyMerchant().getName() != null)
mapui.game.createTransaction(mapui.map.getPlayer(), mapui.map.getCurrentNearbyMerchant()); // RPGame initializes Trade
}


Expand Down Expand Up @@ -287,7 +288,10 @@ public void setY(int y) {
}

public boolean isMerchantNearby() {
return (mapui.getMap().collisionTo("east"))||(mapui.getMap().collisionTo("west"))||(mapui.getMap().collisionTo("south"))||(mapui.getMap().collisionTo("north"))||(mapui.getMap().collisionTo("northeast"))||(mapui.getMap().collisionTo("northwest"))||(mapui.getMap().collisionTo("southeast"))||(mapui.getMap().collisionTo("southwest")) && (mapui.getMap().getCurrentNearbyMerchant() != null);
if ((mapui.getMap().collisionTo("east"))||(mapui.getMap().collisionTo("west"))||(mapui.getMap().collisionTo("south"))||(mapui.getMap().collisionTo("north"))||(mapui.getMap().collisionTo("northeast"))||(mapui.getMap().collisionTo("northwest"))||(mapui.getMap().collisionTo("southeast"))||(mapui.getMap().collisionTo("southwest")) && (mapui.getMap().getCurrentNearbyMerchant() != null))
return mapui.getMap().getCurrentNearbyMerchant() != null;
else
return false;
}

}
10 changes: 6 additions & 4 deletions MerchantRPGCSE2102/src/view/MapUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ public void paint(Graphics g) {
merchant.paint(g2d);

if (player.isMerchantNearby()) {
if (map.getCurrentNearbyMerchant().getCol() > map.getCols()/2)
g2d.drawImage(loadImage("dialogbubble-reverse.png"), map.getCurrentNearbyMerchant().getCol()*tileSize - 85, map.getCurrentNearbyMerchant().getRow()*tileSize - 60, null);
else
g2d.drawImage(loadImage("dialogbubble.png"), (map.getCurrentNearbyMerchant().getCol() + 1)*tileSize, map.getCurrentNearbyMerchant().getRow()*tileSize - 60, null);
if (map.getCurrentNearbyMerchant().getName() != null) {
if (map.getCurrentNearbyMerchant().getCol() > map.getCols()/2)
g2d.drawImage(loadImage("dialogbubble-reverse.png"), map.getCurrentNearbyMerchant().getCol()*tileSize - 85, map.getCurrentNearbyMerchant().getRow()*tileSize - 60, null);
else
g2d.drawImage(loadImage("dialogbubble.png"), (map.getCurrentNearbyMerchant().getCol() + 1)*tileSize, map.getCurrentNearbyMerchant().getRow()*tileSize - 60, null);
}
}

g2d.setColor(Color.BLUE);
Expand Down

0 comments on commit 8bd30fd

Please sign in to comment.