Skip to content

Commit

Permalink
Merge pull request #32 from gal11002/Lutong-L
Browse files Browse the repository at this point in the history
Lutong l
  • Loading branch information
john committed Apr 25, 2015
2 parents c18db4d + 300d8ab commit 585740b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 10 additions & 1 deletion MerchantRPGCSE2102/src/controller/RPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ public class RPGame {
private ArrayList<String> merchantInventoryList2 = new ArrayList<String>(); // merchant 2's inventory list
private ArrayList<String> merchantInventoryList3 = new ArrayList<String>(); // merchant 3's inventory list
private ArrayList<String> playerInventoryList = new ArrayList<String>(); // the player's inventory list
private ArrayList<String> miscList = new ArrayList<String>();

// Character instances
private Player _player;
private Merchant _merchant1;
private Merchant _merchant2;
private Merchant _merchant3;
private Merchant _misc1;

// Map instance
private Map map;
Expand Down Expand Up @@ -65,14 +67,20 @@ public RPGame(int transactionLimit, int tileSize) {
map.initializeMerchant(_merchant1, rows/2, 1);
map.initializeMerchant(_merchant2, rows-2, cols/2);
map.initializeMerchant(_merchant3, rows/2, cols-2);
map.initializeMerchant(_misc1, rows/3, cols/3);


// Creating the MapUI instance and Sprites cooresponding to characters
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);
//just the object collison
mapui.addCollison(rows/3, cols/3);

// Creating JFrame window
JFrame frame = new JFrame("Merchant RPG");
Expand Down Expand Up @@ -135,6 +143,7 @@ public void buildMerchants()
_merchant1 = new Merchant("Cheap Merchant", 200, merchantInventoryList1, 0);
_merchant2 = new Merchant("Medium Merchant", 600, merchantInventoryList2, merchantInventoryList1.size());
_merchant3 = new Merchant("Expensive Merchant", 1000, merchantInventoryList3, merchantInventoryList1.size()+ merchantInventoryList2.size());
_misc1 = new Merchant(null, 0, miscList, 0);
}

/**
Expand Down Expand Up @@ -342,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 585740b

Please sign in to comment.