Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Hill committed Apr 23, 2017
2 parents 62350f3 + d43683f commit 7e4dc47
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 9 deletions.
30 changes: 30 additions & 0 deletions src/controller/Cashflow.java
Expand Up @@ -3,6 +3,8 @@ package controller;
import view.*;

import java.util.ArrayList;
import java.awt.*;
import java.swing.*;

import model.*;

Expand All @@ -11,6 +13,9 @@ public class Cashflow
private static GameBoard _board;
public GameboardWindow gameboard;
public static int numPlayers;
private JFrame frame;
private JWindow sidewindow;
private GameboardWindow window;

public static void main(String[] args)
{
Expand Down Expand Up @@ -131,6 +136,31 @@ public class Cashflow
}


}
public void setUpScreen() {
frame = new JFrame("Cashflow");
frame.setLayout(new FlowLayout());
window = new GameboardWindow(_board);

sidewindow = new JWindow();
sidewindow.setLayout(new GridLayout(5, 5));

frame.add(window);


frame.pack();

frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Cashflow(4);

}
public Cashflow(int numPlayers)
{
//this.setUpScreen(); // just did this to test the screen

}

}
Expand Down
26 changes: 19 additions & 7 deletions src/view/GameboardWindow.java
Expand Up @@ -4,26 +4,38 @@ import controller.*;
import java.awt.*;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.*;


import controller.Cashflow;

public class GameboardWindow extends JPanel {


public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
GameboardWindow window = new GameboardWindow(board);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}


private static final long serialVersionUID = 1L;
private Image img = new ImageIcon(this.getClass().getResource(
"gameboard.png")).getImage();
private Image img = new ImageIcon(this.getClass().getResource("gameboard.png")).getImage();

private GameBoard board;
private static GameBoard board;
private Point[] points = new Point[24];

private ArrayList<Positioner> Positioners;


public GameboardWindow(GameBoard board) {
this.board = board;
GameboardWindow.board = board;
Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
setPreferredSize(size);
setMinimumSize(size);
Expand Down Expand Up @@ -186,7 +198,7 @@ public class GameboardWindow extends JPanel {
public void update() { //updates the location of the player on the board
for (int i = 0; i < Cashflow.numPlayers; i++) {
int x = (int) points[Player[i].getLocation()].getX(); // i will fix this later
int y = (int) points[Player[i].getLocation()].getY(); // hopefully lol
int y = (int) points[Player[i].getLocation()].getY(); //
Positioners.get(i).setX(x);
Positioners.get(i).setY(y);

Expand Down
30 changes: 28 additions & 2 deletions src/view/TileButton.java
Expand Up @@ -11,13 +11,14 @@ public class TileButton extends JButton {

private static final long serialVersionUID = 1L;
private Tile tile;
private int tileNumber;

public TileButton(String name, int TileOnBoard, GameBoard board) {
super(name);

tile = board.getTile(TileOnBoard);
// this.setOpaque(false);

this.setContentAreaFilled(false);
setTileNumber(TileOnBoard);
// this.setBorderPainted(false);
this.setVisible(true);

Expand All @@ -28,5 +29,30 @@ public class TileButton extends JButton {
public void paint(Graphics g) { // Do nothing here }

}




public Tile getTile() {
return tile;
}



public void setTile(Tile tile) {
this.tile = tile;
}



public int getTileNumber() {
return tileNumber;
}



public void setTileNumber(int tileNumber) {
this.tileNumber = tileNumber;
}

}

0 comments on commit 7e4dc47

Please sign in to comment.