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
7dc8f20b
Commit
7dc8f20b
authored
3 years ago
by
roguecomp
Browse files
Options
Downloads
Patches
Plain Diff
Added Pipe and bird logic
parent
2fc6d91f
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
+46
-0
46 additions, 0 deletions
src/ShadowFlap.java
with
46 additions
and
0 deletions
src/ShadowFlap.java
+
46
−
0
View file @
7dc8f20b
...
...
@@ -8,8 +8,19 @@ import bagel.*;
* @student_id: 1180554
*/
public
class
ShadowFlap
extends
AbstractGame
{
private
Image
Background
;
private
Bird
bird
;
private
Pipe
pipe
;
private
static
String
gameState
=
"mainMenu"
;
private
final
String
startString
=
"PRESS SPACE TO START"
;
private
final
String
outOfBounds
=
"Out Of Bounds"
;
private
final
Font
font
=
new
Font
(
"res/slkscr.ttf"
,
48
);
public
ShadowFlap
()
{
super
(
1024
,
768
,
"Flappy Bird"
);
this
.
Background
=
new
Image
(
"res/background.png"
);
bird
=
new
Bird
();
pipe
=
new
Pipe
();
}
/**
...
...
@@ -26,7 +37,42 @@ public class ShadowFlap extends AbstractGame {
*/
@Override
public
void
update
(
Input
input
)
{
Background
.
draw
(
Window
.
getWidth
()
/
2.0
,
Window
.
getHeight
()
/
2.0
);
if
(
this
.
gameState
==
"started"
)
{
/* game has started */
bird
.
velocity
-=
bird
.
acceleration
;
bird
.
velocity
=
Math
.
max
(
bird
.
velocity
,
bird
.
terminalVelocity
);
/* set fall velocity limit */
bird
.
y
-=
bird
.
velocity
;
if
(
input
.
wasPressed
(
Keys
.
SPACE
))
{
bird
.
velocity
=
6
;
}
if
(
bird
.
y
>
Window
.
getHeight
()
||
bird
.
y
<
0
)
{
gameState
=
"outOfBounds"
;
};
bird
.
Render
();
pipe
.
Render
();
}
else
if
(
gameState
==
"outOfBounds"
)
{
Background
.
draw
(
Window
.
getWidth
()
/
2.0
,
Window
.
getHeight
()
/
2.0
);
font
.
drawString
(
outOfBounds
,
(
Window
.
getWidth
()
/
2.0
)
-
(
font
.
getWidth
(
outOfBounds
)
/
2.0
),
Window
.
getHeight
()
/
2.0
);
}
else
{
/* loading screen */
if
(
input
.
wasPressed
(
Keys
.
SPACE
))
{
gameState
=
"started"
;
}
/* draw font exactly in the middle of the screen */
font
.
drawString
(
startString
,
(
Window
.
getWidth
()
/
2.0
)
-
(
font
.
getWidth
(
startString
)
/
2.0
),
Window
.
getHeight
()
/
2.0
);
}
if
(
input
.
wasPressed
(
Keys
.
ESCAPE
))
{
Window
.
close
();
}
}
}
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