Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BattleArena
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Scherbaum Maximilian
BattleArena
Commits
42b98d43
Commit
42b98d43
authored
1 year ago
by
Tran Peter
Browse files
Options
Downloads
Patches
Plain Diff
fix(game scene): fix animation timer too fast for high fps
parent
ff6e4ed5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
5 merge requests
!74
V1
,
!73
Initial commit
,
!71
Merge DataBase into Development
,
!54
Update: coreMaps.json (added new maps)
,
!49
Merge ui into development
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java
+10
-4
10 additions, 4 deletions
...stuttgart/battlearena/Controller/GameSceneController.java
with
10 additions
and
4 deletions
src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java
+
10
−
4
View file @
42b98d43
...
...
@@ -85,6 +85,8 @@ public class GameSceneController implements Initializable {
int
diffTileCount
=
30
;
int
scaledTileSize
=
48
;
private
final
Biom
biom
=
runtimeInfo
.
getMapBiom
();
private
final
long
targetFrameTime
=
1_000_000_000
/
80
;
// sets the target frame time to 12.5 ms (80fps)
private
long
lastFrame
=
0
;
@Override
public
void
initialize
(
URL
url
,
ResourceBundle
resourceBundle
)
{
...
...
@@ -142,11 +144,15 @@ public class GameSceneController implements Initializable {
AnimationTimer
gameLoop
=
new
AnimationTimer
()
{
@Override
public
void
handle
(
long
l
)
{
public
void
handle
(
long
now
)
{
if
(!
inputHandler
.
isPause
())
{
graphicsContext2D
.
clearRect
(
0
,
0
,
canvas2D
.
getWidth
(),
canvas2D
.
getHeight
());
renderContent
(
graphicsContext2D
);
updateContent
();
if
(
now
-
lastFrame
>=
targetFrameTime
)
{
// If short frame time (high fps) it will skip updateContent(). Next Frame has higher frame time and updates the frame
graphicsContext2D
.
clearRect
(
0
,
0
,
canvas2D
.
getWidth
(),
canvas2D
.
getHeight
());
renderContent
(
graphicsContext2D
);
updateContent
();
lastFrame
=
now
;
}
// remove blur
if
(
wasPaused
)
{
resume
();
}
...
...
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