-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainScreen.java
More file actions
90 lines (69 loc) · 2.77 KB
/
Copy pathMainScreen.java
File metadata and controls
90 lines (69 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.image.BufferedImage;
import java.awt.*;
/**
* GUI interface for user. Put game inside a DS as a joke. I don't know what
* sort of interface will make the game look best to user.
*
* @Jonathan Ke
* @8/13/2019
*/
public class MainScreen
{
Player player;
//display cut from GameFrame
JLabel display;
JLabel textBox = new TextBox();
JFrame f;
public MainScreen(Player player){
this.player = player;
//create display object
display = new JLabel();
display.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
display.setBorder(new LineBorder(Color.BLACK));
//group display and right side of DS together
JPanel pMain = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
pMain.add(display);
JLabel rightSide = new JLabel(new ImageIcon(SpriteSheetCutter.getImage("dsRightSide")));
rightSide.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
pMain.add(BorderLayout.LINE_END,rightSide);
//add in other sides of DS
JPanel pTop = new JPanel(new BorderLayout(0,0));
pTop.setBackground(Color.BLACK);
pTop.add(BorderLayout.CENTER,pMain);
pTop.add(BorderLayout.PAGE_START,new JLabel(new ImageIcon(SpriteSheetCutter.getImage("dsTop"))));
pTop.add(BorderLayout.LINE_START,new JLabel(new ImageIcon(SpriteSheetCutter.getImage("dsLeftSide"))));
pTop.add(BorderLayout.PAGE_END,new JLabel(new ImageIcon(SpriteSheetCutter.getImage("dsBottom"))));
//testing ArrowKeys
ArrowKeys arrowKeys = new ArrowKeys(player, this);
JPanel pBottom = new JPanel(new BorderLayout());
pBottom.setBackground(Color.BLACK);
pBottom.add(BorderLayout.CENTER,textBox);
pBottom.add(BorderLayout.SOUTH,arrowKeys);
JPanel pFinal = new JPanel(new BorderLayout());
pFinal.add(BorderLayout.CENTER, pTop);
pFinal.add(BorderLayout.PAGE_END, pBottom);
//udpate variables in frame
f = new JFrame("POKEMON ADVENTURE");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.addKeyListener(player);
f.add(pFinal);
f.pack();
f.setMaximumSize(new Dimension(f.getWidth(),f.getHeight()));
f.setMinimumSize(new Dimension(f.getWidth(),f.getHeight()));
f.setFocusable(true);
f.setVisible(true);
f.requestFocus();
}
//updates viewable display
public void updateDisplay(BufferedImage b){
display.setIcon(new ImageIcon(b.getSubimage(player.getX()-190,player.getY()-140,400,300)));
}
public JLabel getTextBox(){
return textBox;
}
public JFrame getFrame(){
return f;
}
}