Skip to content

Commit

Permalink
working Object collison
Browse files Browse the repository at this point in the history
  • Loading branch information
lul11003 committed Apr 25, 2015
1 parent 3e808eb commit af546c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion MerchantRPGCSE2102/src/controller/RPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ public RPGame(int transactionLimit, int tileSize) {
mapui = new MapUI(map, this, tileSize);
mapui.createPlayerSprite(rows/2, cols/2);
mapui.addMerchantSprite(rows/2, 1);
mapui.addCollison(rows/2,1);
mapui.addMerchantSprite(rows-2, cols/2);
mapui.addCollison(rows-2, cols/2);
mapui.addMerchantSprite(rows/2, cols-2);
mapui.addCollison(rows/2, cols-2);

mapui.addCollison(rows/3, cols/3);

// Creating JFrame window
JFrame frame = new JFrame("Merchant RPG");
Expand Down Expand Up @@ -346,7 +351,7 @@ public static void main(String[] args) throws InterruptedException
// MAIN GAME LOOP
while (true) {
rpgGame.updateMapUI();
Thread.sleep(1000/144); // Controls the speed of the game (currently 144 frames/second)
Thread.sleep(1000/300); // Controls the speed of the game (currently 144 frames/second)
}
}
}
9 changes: 6 additions & 3 deletions MerchantRPGCSE2102/src/view/MapUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class MapUI extends JPanel {
public int tileSize;
private PlayerSprite player;
private ArrayList<MerchantSprite> merchants = new ArrayList<MerchantSprite>();

private ArrayList<MerchantSprite> collisons = new ArrayList<MerchantSprite>();


public MapUI(Map map, RPGame Game, int tileSize) {
Expand Down Expand Up @@ -99,7 +99,10 @@ public void addMerchantSprite(int row, int col) {
MerchantSprite merchant = new MerchantSprite(row, col);
merchants.add(merchant);
}

public void addCollison(int row, int col) {
MerchantSprite merchant = new MerchantSprite(row, col);
collisons.add(merchant);
}
/**
* Creates a player sprite to be painted on the canvas
* @param row The row of the player
Expand Down Expand Up @@ -177,7 +180,7 @@ public Map getMap() {
}

public ArrayList<MerchantSprite> getMerchants() {
return merchants;
return collisons;
}


Expand Down

0 comments on commit af546c7

Please sign in to comment.