-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainClass.java
More file actions
133 lines (115 loc) · 3.35 KB
/
MainClass.java
File metadata and controls
133 lines (115 loc) · 3.35 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class MainClass extends JFrame
{
MainClass()
{
CardLayout cl = new CardLayout();
JPanel cards = new JPanel(cl);
setTitle("SideWinder");
setSize(737,770);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
JPanel home = new JPanel();
GridBagLayout layout = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
home.setLayout(layout);
home.setBackground(Color.BLACK);
ImageIcon icon = new ImageIcon("no step on snek.jpg");
JLabel thumb = new JLabel();
thumb.setIcon(icon);
home.add(thumb,gbc);
JLabel labelS = new JLabel(" ");
gbc.gridx = 0;
gbc.gridy = 2;
home.add(labelS ,gbc);
JLabel label = new JLabel("<html><font color='white'>WELCOME TO THE GAME OF SIDEWINDER</font></html>");
gbc.gridx = 0;
gbc.gridy = 4;
home.add(label,gbc);
JLabel label2 = new JLabel("<html><font color='red'>RED SNAKE: WASD </font></font> <font color='white'>|</font><font color='blue'> BlUE SNAKE: ARROW KEYS</html>");
gbc.gridx = 0;
gbc.gridy = 8;
home.add(label2,gbc);
JLabel labelH = new JLabel(" ");
gbc.gridx = 0;
gbc.gridy = 10;
home.add(labelH ,gbc);
JButton button = new JButton(" EASY ");
button.setBackground(Color.WHITE);
gbc.gridx = 0;
gbc.gridy = 20;
home.add(button, gbc);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SnakeBoard.setDifficulty(3);
SnakeBoard snake = new SnakeBoard();
JPanel snake1 = new SnakeBoard();
cards.add(snake1, "snakeboard");
pack();
cl.show(cards, "snakeboard");
}
});
JLabel labelE = new JLabel(" ");
gbc.gridx = 0;
gbc.gridy = 30;
home.add(labelE,gbc);
JButton button1 = new JButton("MEDIUM");
button1.setBackground(Color.WHITE);
gbc.gridx = 0;
gbc.gridy = 40;
home.add(button1, gbc);
button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SnakeBoard.setDifficulty(2);
SnakeBoard snake = new SnakeBoard();
JPanel snake1 = new SnakeBoard();
cards.add(snake1, "snakeboard");
pack();
cl.show(cards, "snakeboard");
}
});
JLabel labelM = new JLabel(" ");
gbc.gridx = 0;
gbc.gridy = 50;
home.add(labelM ,gbc);
JButton button2 = new JButton(" HARD ");
button2.setBackground(Color.WHITE);
gbc.gridx = 0;
gbc.gridy = 60;
home.add(button2, gbc);
button2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SnakeBoard.setDifficulty(1);
SnakeBoard snake = new SnakeBoard();
JPanel snake1 = new SnakeBoard();
cards.add(snake1, "snakeboard");
pack();
cl.show(cards, "snakeboard");
}
});
cards.add(home, "home");
cl.show(cards,"home");
setVisible(true);
add(cards);
}
public static void main(String[] args)
{
new MainClass();
}
}