From 3e808ebdd4a65b3e2a74508fedaa9bfcff640e54 Mon Sep 17 00:00:00 2001 From: lul11003 Date: Sat, 25 Apr 2015 11:28:54 -0400 Subject: [PATCH 1/3] ideas for world --- MerchantRPGCSE2102/src/controller/RPGame.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MerchantRPGCSE2102/src/controller/RPGame.java b/MerchantRPGCSE2102/src/controller/RPGame.java index 165db89..8f5c926 100644 --- a/MerchantRPGCSE2102/src/controller/RPGame.java +++ b/MerchantRPGCSE2102/src/controller/RPGame.java @@ -23,12 +23,14 @@ public class RPGame { private ArrayList merchantInventoryList2 = new ArrayList(); // merchant 2's inventory list private ArrayList merchantInventoryList3 = new ArrayList(); // merchant 3's inventory list private ArrayList playerInventoryList = new ArrayList(); // the player's inventory list + private ArrayList miscList = new ArrayList(); // Character instances private Player _player; private Merchant _merchant1; private Merchant _merchant2; private Merchant _merchant3; + private Merchant _misc1; // Map instance private Map map; @@ -65,6 +67,7 @@ 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 @@ -135,6 +138,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); } /** From af546c7504e97042f4e2f2ca8ca3547f6be81d81 Mon Sep 17 00:00:00 2001 From: lul11003 Date: Sat, 25 Apr 2015 11:52:20 -0400 Subject: [PATCH 2/3] working Object collison --- MerchantRPGCSE2102/src/controller/RPGame.java | 7 ++++++- MerchantRPGCSE2102/src/view/MapUI.java | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/MerchantRPGCSE2102/src/controller/RPGame.java b/MerchantRPGCSE2102/src/controller/RPGame.java index 8f5c926..3740343 100644 --- a/MerchantRPGCSE2102/src/controller/RPGame.java +++ b/MerchantRPGCSE2102/src/controller/RPGame.java @@ -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"); @@ -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) } } } diff --git a/MerchantRPGCSE2102/src/view/MapUI.java b/MerchantRPGCSE2102/src/view/MapUI.java index 4e26292..bba61c8 100644 --- a/MerchantRPGCSE2102/src/view/MapUI.java +++ b/MerchantRPGCSE2102/src/view/MapUI.java @@ -29,7 +29,7 @@ public class MapUI extends JPanel { public int tileSize; private PlayerSprite player; private ArrayList merchants = new ArrayList(); - + private ArrayList collisons = new ArrayList(); public MapUI(Map map, RPGame Game, int tileSize) { @@ -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 @@ -177,7 +180,7 @@ public Map getMap() { } public ArrayList getMerchants() { - return merchants; + return collisons; } From 300d8ab69e89708a16513c4efe531c575824b87d Mon Sep 17 00:00:00 2001 From: lul11003 Date: Sat, 25 Apr 2015 12:03:04 -0400 Subject: [PATCH 3/3] Object collison --- MerchantRPGCSE2102/src/controller/RPGame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerchantRPGCSE2102/src/controller/RPGame.java b/MerchantRPGCSE2102/src/controller/RPGame.java index 3740343..e05082e 100644 --- a/MerchantRPGCSE2102/src/controller/RPGame.java +++ b/MerchantRPGCSE2102/src/controller/RPGame.java @@ -79,7 +79,7 @@ public RPGame(int transactionLimit, int tileSize) { 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