Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Chess2
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sander Skogh Linnerud
Chess2
Commits
a88e6cb1
Commit
a88e6cb1
authored
1 year ago
by
Magnus Alexander Strømseng
Browse files
Options
Downloads
Patches
Plain Diff
limit and log fps
parent
4e465f19
No related branches found
No related tags found
1 merge request
!71
Resolve "Limit and log fps"
Pipeline
#275634
passed
1 year ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/com/mygdx/game/ChessGame.java
+22
-0
22 additions, 0 deletions
core/src/com/mygdx/game/ChessGame.java
with
22 additions
and
0 deletions
core/src/com/mygdx/game/ChessGame.java
+
22
−
0
View file @
a88e6cb1
package
com.mygdx.game
;
package
com.mygdx.game
;
import
com.badlogic.gdx.ApplicationAdapter
;
import
com.badlogic.gdx.ApplicationAdapter
;
import
com.badlogic.gdx.graphics.FPSLogger
;
import
com.badlogic.gdx.utils.ScreenUtils
;
import
com.badlogic.gdx.utils.ScreenUtils
;
import
com.mygdx.game.controller.SoundManager
;
import
com.mygdx.game.controller.SoundManager
;
import
com.mygdx.game.service.APIClient.APIClientProvider
;
import
com.mygdx.game.service.APIClient.APIClientProvider
;
...
@@ -8,12 +9,14 @@ import com.mygdx.game.service.APIClient.APIClientProvider;
...
@@ -8,12 +9,14 @@ import com.mygdx.game.service.APIClient.APIClientProvider;
public
class
ChessGame
extends
ApplicationAdapter
{
public
class
ChessGame
extends
ApplicationAdapter
{
public
static
final
float
WIDTH
=
540
;
public
static
final
float
WIDTH
=
540
;
public
static
final
float
HEIGHT
=
960
;
public
static
final
float
HEIGHT
=
960
;
private
int
fps
=
60
;
APIClientProvider
apiProvider
;
APIClientProvider
apiProvider
;
public
ChessGame
()
{
public
ChessGame
()
{
super
();
super
();
}
}
FPSLogger
logger
=
new
FPSLogger
();
public
ChessGame
(
APIClientProvider
apiProvider
)
{
public
ChessGame
(
APIClientProvider
apiProvider
)
{
super
();
super
();
...
@@ -29,6 +32,8 @@ public class ChessGame extends ApplicationAdapter {
...
@@ -29,6 +32,8 @@ public class ChessGame extends ApplicationAdapter {
@Override
@Override
public
void
render
()
{
public
void
render
()
{
ScreenUtils
.
clear
(
0.3f
,
0
,
0
,
1
);
ScreenUtils
.
clear
(
0.3f
,
0
,
0
,
1
);
sleep
(
fps
);
logger
.
log
();
// Log fps
GameManager
.
getInstance
().
render
();
GameManager
.
getInstance
().
render
();
}
}
...
@@ -41,4 +46,21 @@ public class ChessGame extends ApplicationAdapter {
...
@@ -41,4 +46,21 @@ public class ChessGame extends ApplicationAdapter {
public
void
resize
(
int
width
,
int
height
)
{
public
void
resize
(
int
width
,
int
height
)
{
GameManager
.
getInstance
().
resize
(
width
,
height
);
GameManager
.
getInstance
().
resize
(
width
,
height
);
}
}
private
long
diff
,
start
=
System
.
currentTimeMillis
();
public
void
sleep
(
int
fps
)
{
if
(
fps
>
0
){
diff
=
System
.
currentTimeMillis
()
-
start
;
long
targetDelay
=
1000
/
fps
;
if
(
diff
<
targetDelay
)
{
try
{
Thread
.
sleep
(
targetDelay
-
diff
);
}
catch
(
InterruptedException
e
)
{}
}
start
=
System
.
currentTimeMillis
();
}
}
}
}
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