Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FaultInOurPong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Group3
FaultInOurPong
Commits
22d9a5aa
Commit
22d9a5aa
authored
8 years ago
by
Jie Luo
Browse files
Options
Downloads
Patches
Plain Diff
eclipse game files
parent
6f9bf896
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Game_Code/src/view/Tutorial.java
+35
-0
35 additions, 0 deletions
Game_Code/src/view/Tutorial.java
Game_Code/src/view/Welcome.java
+83
-0
83 additions, 0 deletions
Game_Code/src/view/Welcome.java
with
118 additions
and
0 deletions
Game_Code/src/view/Tutorial.java
0 → 100644
+
35
−
0
View file @
22d9a5aa
package
view
;
import
java.awt.event.ActionListener
;
import
javax.swing.ImageIcon
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
public
class
Tutorial
extends
JFrame
{
private
JButton
back
;
public
Tutorial
(
ImageIcon
img
){
super
(
"FaultInOurPong - Tutorial"
);
this
.
setSize
(
700
,
500
);
this
.
setResizable
(
false
);
this
.
setLocationRelativeTo
(
null
);
this
.
add
(
new
JLabel
(
img
));
back
=
new
JButton
(
"Back"
);
//this.add(back);
this
.
setDefaultCloseOperation
(
EXIT_ON_CLOSE
);
}
public
JButton
getBack
(){
return
back
;
}
public
void
addListener
(
ActionListener
listener
){
back
.
addActionListener
(
listener
);
}
}
This diff is collapsed.
Click to expand it.
Game_Code/src/
V
iew.java
→
Game_Code/src/
v
iew
/Welcome
.java
+
83
−
0
View file @
22d9a5aa
package
view
;
import
java.awt.BorderLayout
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
javax.swing.Box
;
import
javax.swing.BoxLayout
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JPanel
;
import
javax.swing.*
;
public
class
View
extends
JFrame
{
public
class
Welcome
extends
JFrame
{
private
JButton
start
=
new
JButton
(
"Start New Game"
);
private
JButton
load
=
new
JButton
(
"Load Game"
);
...
...
@@ -17,17 +12,23 @@ public class View extends JFrame{
private
JButton
tutorial
=
new
JButton
(
"Tutorial"
);
private
JButton
exit
=
new
JButton
(
"Exit"
);
private
JButton
single
=
new
JButton
(
"Single Player Mode"
);
private
JButton
sObstacle
=
new
JButton
(
"Advanced Single Player Mode"
);
private
JButton
multi
=
new
JButton
(
"Multiplayer Mode"
);
private
JPanel
buttonPanel
;
JPanel
buttonPanel
=
new
JPanel
();
public
View
(){
public
Welcome
(){
/*
* - Set the header of the window
* - Set the size of the window
*/
super
(
"FaultInOurPong"
);
this
.
setSize
(
700
,
500
);
this
.
setResizable
(
false
);
this
.
setLocationRelativeTo
(
null
);
/*
* Add buttons on the window
*/
buttonPanel
=
new
JPanel
();
buttonPanel
.
setLayout
(
new
BoxLayout
(
buttonPanel
,
BoxLayout
.
Y_AXIS
));
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
...
...
@@ -37,94 +38,46 @@ public class View extends JFrame{
addButton
(
tutorial
);
addButton
(
exit
);
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
start
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
start
();
}
});
load
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
load
();
}
});
highScores
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
highScores
();
}
});
tutorial
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
tutorial
();
}
});
exit
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
System
.
exit
(
0
);
}
});
add
(
buttonPanel
);
this
.
setDefaultCloseOperation
(
EXIT_ON_CLOSE
);
this
.
setLocationRelativeTo
(
null
);
this
.
setVisible
(
true
);
}
public
void
addButton
(
JButton
x
)
{
x
.
setMaximumSize
(
sObstacle
.
getPreferredSize
());
x
.
setAlignmentY
(
CENTER_ALIGNMENT
);
x
.
setAlignmentX
(
CENTER_ALIGNMENT
);
buttonPanel
.
add
(
x
);
buttonPanel
.
add
(
Box
.
createVerticalStrut
(
20
));
public
JButton
getStart
(){
return
start
;
}
public
void
start
()
{
buttonPanel
.
removeAll
();
this
.
getContentPane
().
removeAll
();
this
.
repaint
();
buttonPanel
.
setLayout
(
new
BoxLayout
(
buttonPanel
,
BoxLayout
.
Y_AXIS
));
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
addButton
(
single
);
addButton
(
sObstacle
);
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
add
(
buttonPanel
);
this
.
setVisible
(
true
);
single
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
single
();
}
});
public
JButton
load
(){
return
load
;
}
public
void
single
()
{
Pong_viewAndController
view_controller
=
new
Pong_viewAndController
();
this
.
setVisible
(
false
);
public
JButton
highScores
(){
return
highScores
;
}
public
void
load
()
{
public
JButton
tutorial
(){
return
tutorial
;
}
public
void
highScores
()
{
public
JButton
exit
(){
return
exit
;
}
public
void
tutorial
()
{
public
void
addButton
(
JButton
x
)
{
x
.
setMaximumSize
(
start
.
getPreferredSize
());
x
.
setAlignmentY
(
CENTER_ALIGNMENT
);
x
.
setAlignmentX
(
CENTER_ALIGNMENT
);
buttonPanel
.
add
(
x
);
buttonPanel
.
add
(
Box
.
createVerticalStrut
(
20
));
}
public
static
void
main
(
String
[]
args
)
{
View
menuPage
=
new
View
();
public
void
addListener
(
ActionListener
buttonListener
){
start
.
addActionListener
(
buttonListener
);
load
.
addActionListener
(
buttonListener
);
highScores
.
addActionListener
(
buttonListener
);
tutorial
.
addActionListener
(
buttonListener
);
exit
.
addActionListener
(
buttonListener
);
}
}
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment