Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
john committed Apr 25, 2015
2 parents 6591cc8 + c40fbf3 commit 7f25e84
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 21 deletions.
1 change: 1 addition & 0 deletions MerchantRPGCSE2102/src/config/instructions.txt
@@ -0,0 +1 @@
Testing Instructions file
22 changes: 21 additions & 1 deletion MerchantRPGCSE2102/src/controller/RPGame.java
Expand Up @@ -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) {
Expand All @@ -63,6 +64,21 @@ public class RPGame {
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);
Expand Down Expand Up @@ -142,7 +158,7 @@ public class RPGame {
*/
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);
Expand Down Expand Up @@ -208,6 +224,10 @@ public class RPGame {
}
}

public void createStartScreen(RPGame game) throws IOException
{
StartScreen newStartScreen = new StartScreen(game);
}

/**
* Will refresh number of transactions the Player has available
Expand Down
11 changes: 11 additions & 0 deletions MerchantRPGCSE2102/src/model/Player.java
Expand Up @@ -141,4 +141,15 @@ public class Player extends Character
{
return _playerCash;
}

/**
* Setter for player name
*
* @param playerName Name of the player
*/
public void setPlayerName(String playerName)
{
_name = playerName;
}

}
51 changes: 31 additions & 20 deletions 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;
Expand All @@ -47,18 +42,30 @@ public class StartScreen extends JFrame {
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();
}
}
});

Expand Down Expand Up @@ -94,5 +101,9 @@ public class StartScreen extends JFrame {
return null;
}
}


public void exitWindow()
{
this.dispose();
}
}

0 comments on commit 7f25e84

Please sign in to comment.