diff --git a/MerchantRPGCSE2102/src/config/instructions.txt b/MerchantRPGCSE2102/src/config/instructions.txt new file mode 100644 index 0000000..550cd0e --- /dev/null +++ b/MerchantRPGCSE2102/src/config/instructions.txt @@ -0,0 +1 @@ +Testing Instructions file \ No newline at end of file diff --git a/MerchantRPGCSE2102/src/controller/RPGame.java b/MerchantRPGCSE2102/src/controller/RPGame.java index 5e57a21..f52ac41 100644 --- a/MerchantRPGCSE2102/src/controller/RPGame.java +++ b/MerchantRPGCSE2102/src/controller/RPGame.java @@ -44,6 +44,7 @@ public class RPGame { public boolean _movement = true; private int _currentDay; private int _transactionLimit; + public boolean _initialGameVariable; public RPGame(int transactionLimit, int tileSize) { @@ -63,6 +64,21 @@ public RPGame(int transactionLimit, int tileSize) { buildMerchants(); buildPlayer("test", 500); + // Initialize the start screen + _initialGameVariable = false; + + try { + createStartScreen(this); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + while(_initialGameVariable == false) + { + System.out.println("In Loop"); + } + // Initialiing Map instance and adding the player and merchants to the map map = new Map(rows, cols); map.initializePlayer(_player, rows/2, cols/2); @@ -142,7 +158,7 @@ else if (currentMerchant == 3) */ public void buildMerchants() { - _merchant1 = new Merchant("Cheap Merchant", 200, merchantInventoryList1, 0); + _merchant1 = new Merchant("Cheap Merchant", 300, 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); @@ -208,6 +224,10 @@ public void createTransaction(Player player, Merchant targetMerchant) } } + public void createStartScreen(RPGame game) throws IOException + { + StartScreen newStartScreen = new StartScreen(game); + } /** * Will refresh number of transactions the Player has available diff --git a/MerchantRPGCSE2102/src/model/Player.java b/MerchantRPGCSE2102/src/model/Player.java index 4f77878..24a768b 100644 --- a/MerchantRPGCSE2102/src/model/Player.java +++ b/MerchantRPGCSE2102/src/model/Player.java @@ -141,4 +141,15 @@ public int getPlayerCash() { return _playerCash; } + + /** + * Setter for player name + * + * @param playerName Name of the player + */ + public void setPlayerName(String playerName) + { + _name = playerName; + } + } \ No newline at end of file diff --git a/MerchantRPGCSE2102/src/view/StartScreen.java b/MerchantRPGCSE2102/src/view/StartScreen.java index 1e0bf3c..8f933ca 100644 --- a/MerchantRPGCSE2102/src/view/StartScreen.java +++ b/MerchantRPGCSE2102/src/view/StartScreen.java @@ -1,35 +1,30 @@ package view; import java.awt.*; -import java.awt.Color; -import java.awt.GradientPaint; -import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; import javax.swing.*; +import javax.swing.border.EmptyBorder; -public class StartScreen extends JFrame { +import controller.RPGame; +import model.Player; - private static final long serialVersionUID = 1L; +@SuppressWarnings("serial") +public class StartScreen extends JFrame { JPanel startMenu = new JPanel(); + RPGame _master; + public StartScreen(RPGame master) throws IOException { - - public static void main(String[] args) throws IOException { - new StartScreen(); - } - - public StartScreen() throws IOException { - + _master = master; JLabel MainMenuBG = new JLabel(new ImageIcon("src/images/background.jpg")); MainMenuBG.setVisible(true); Image icon, background; @@ -47,18 +42,30 @@ public StartScreen() throws IOException { JButton start = new JButton("Start"); start.setVisible(true); - start.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e){ + start.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent arg0) { System.out.println("Game started"); + _master._initialGameVariable = true; + exitWindow(); + } }); JButton instructions = new JButton("Instructions"); instructions.setVisible(true); - instructions.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e){ + instructions.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent arg0) { System.out.println("Instructions opened"); + ProcessBuilder pb = new ProcessBuilder("Notepad.exe", "src/config/instructions.txt"); + try { + pb.start(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } }); @@ -94,5 +101,9 @@ public BufferedImage loadBackground() throws IOException { return null; } } - + + public void exitWindow() + { + this.dispose(); + } }