Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
vishnukap-project-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vishnudutt Kappagantula
vishnukap-project-1
Commits
048427a6
Commit
048427a6
authored
3 years ago
by
roguecomp
Browse files
Options
Downloads
Patches
Plain Diff
Implementing win and lose screens
parent
864ddd93
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ShadowFlap.java
+32
-3
32 additions, 3 deletions
src/ShadowFlap.java
with
32 additions
and
3 deletions
src/ShadowFlap.java
+
32
−
3
View file @
048427a6
...
@@ -12,9 +12,12 @@ public class ShadowFlap extends AbstractGame {
...
@@ -12,9 +12,12 @@ public class ShadowFlap extends AbstractGame {
private
Image
Background
;
private
Image
Background
;
private
Bird
bird
;
private
Bird
bird
;
private
Pipe
pipe
;
private
Pipe
pipe
;
private
static
String
gameState
=
"mainMenu"
;
private
int
score
=
0
;
private
String
gameState
=
"mainMenu"
,
temp
=
""
;
private
final
String
startString
=
"PRESS SPACE TO START"
;
private
final
String
startString
=
"PRESS SPACE TO START"
;
private
final
String
outOfBounds
=
"Out Of Bounds"
;
private
final
String
outOfBounds
=
"GAME OVER!"
;
private
final
String
finalScore
=
"Final Score: "
;
private
final
String
winFont
=
"CONGRATULATIONS!"
;
private
final
Font
font
=
new
Font
(
"res/slkscr.ttf"
,
48
);
private
final
Font
font
=
new
Font
(
"res/slkscr.ttf"
,
48
);
public
ShadowFlap
()
{
public
ShadowFlap
()
{
...
@@ -53,13 +56,39 @@ public class ShadowFlap extends AbstractGame {
...
@@ -53,13 +56,39 @@ public class ShadowFlap extends AbstractGame {
bird
.
Render
();
bird
.
Render
();
Point
birdPos
=
new
Point
(
bird
.
x
,
bird
.
y
);
Point
birdPos
=
new
Point
(
bird
.
x
,
bird
.
y
);
pipe
.
Render
(
bird
.
birdWingDown
.
getBoundingBoxAt
(
birdPos
));
temp
=
pipe
.
Render
(
bird
.
birdWingDown
.
getBoundingBoxAt
(
birdPos
));
if
(
temp
==
null
)
{
temp
=
""
;
}
else
{
gameState
=
temp
;
}
if
(
bird
.
x
>
pipe
.
pos
)
{
this
.
score
=
1
;
}
if
(
pipe
.
pos
<=
0
)
{
this
.
gameState
=
"win"
;
}
}
}
else
if
(
gameState
==
"outOfBounds"
)
{
else
if
(
gameState
==
"outOfBounds"
)
{
Background
.
draw
(
Window
.
getWidth
()
/
2.0
,
Window
.
getHeight
()
/
2.0
);
Background
.
draw
(
Window
.
getWidth
()
/
2.0
,
Window
.
getHeight
()
/
2.0
);
font
.
drawString
(
outOfBounds
,
font
.
drawString
(
outOfBounds
,
(
Window
.
getWidth
()
/
2.0
)
-
(
font
.
getWidth
(
outOfBounds
)
/
2.0
),
(
Window
.
getWidth
()
/
2.0
)
-
(
font
.
getWidth
(
outOfBounds
)
/
2.0
),
Window
.
getHeight
()
/
2.0
);
Window
.
getHeight
()
/
2.0
);
font
.
drawString
(
finalScore
+
String
.
valueOf
(
this
.
score
),
(
Window
.
getWidth
()
/
2.0
)
-
(
font
.
getWidth
(
finalScore
+
String
.
valueOf
(
this
.
score
))
/
2.0
),
(
Window
.
getHeight
()
/
2.0
)
+
75
);
}
else
if
(
gameState
==
"win"
)
{
Background
.
draw
(
Window
.
getWidth
()
/
2.0
,
Window
.
getHeight
()
/
2.0
);
font
.
drawString
(
winFont
,
(
Window
.
getWidth
()
/
2.0
)
-
(
font
.
getWidth
(
winFont
)
/
2.0
),
Window
.
getHeight
()
/
2.0
);
font
.
drawString
(
finalScore
+
String
.
valueOf
(
this
.
score
),
(
Window
.
getWidth
()
/
2.0
)
-
(
font
.
getWidth
(
finalScore
+
String
.
valueOf
(
this
.
score
))
/
2.0
),
(
Window
.
getHeight
()
/
2.0
)
+
75
);
}
}
else
{
else
{
/* loading screen */
/* loading screen */
...
...
This diff is collapsed.
Click to expand it.
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