1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2024-12-26 03:18:22 +01:00

Refactor code on System clock

This commit is contained in:
Dany LE 2022-08-14 22:49:36 +02:00
parent 681d8951b7
commit 0b7396242a
6 changed files with 7 additions and 8 deletions

View File

@ -62,7 +62,7 @@ DiyaApplicationLauncher >> launch: app [
{ #category : #initialization }
DiyaApplicationLauncher >> main [
| fps delta|
delta := DiyaSystemClock delta asMilliSeconds.
delta := DiyaSystemClock delta.
fps := DiyaSystemSettings maxFPS.
delta = 0 ifFalse:[ fps := (1000/ delta) asInteger].
txtFPS data: ('FPS:', fps asString).

View File

@ -108,7 +108,7 @@ DiyaBoot >> render [
DiyaRenderer render.
SDL2 delay:
(0 max:
(1000/ DiyaSystemSettings maxFPS) asInteger - (DiyaSystemClock lapDelta asMilliSeconds)).
(1000/ DiyaSystemSettings maxFPS) asInteger - (DiyaSystemClock lapDelta)).
].
]

View File

@ -23,12 +23,12 @@ DiyaClock >> elapsedTime [
DiyaClock >> initialize [
monotonic := DateAndTime now.
lastTick := monotonic.
lapTime := 0 asDuration.
lapTime := 0.
]
{ #category : #initialization }
DiyaClock >> lapDelta [
^ ((DateAndTime now) - lastTick)
^ ((DateAndTime now) - lastTick) asMilliSeconds
]
{ #category : #initialization }
@ -38,6 +38,6 @@ DiyaClock >> lapTime [
{ #category : #initialization }
DiyaClock >> tick [
lapTime := (DateAndTime now) - lastTick.
lapTime := self lapDelta.
lastTick := DateAndTime now.
]

View File

@ -330,7 +330,6 @@ DiyaNode >> trigger: evt [
handler value: evt].
children ifNil: [^self].
evt enable ifTrue: [
"evt mapped triggableOn: children first."
children select: [:node | evt mapped triggableOn: node ] thenDo:[:node| node trigger: evt]
].
]

View File

@ -112,7 +112,7 @@ DiyaRootNode >> spinOnce: maxProcessingTime [
].
(Q isEmpty and: R isEmpty) ifTrue: [ ^false ].
DiyaSystemSettings renderAtOnce ifTrue: [ ^ true ].
^(DiyaSystemClock lapDelta asMilliSeconds < maxProcessingTime)
^(DiyaSystemClock lapDelta < maxProcessingTime)
]
{ #category : #accessing }

View File

@ -26,7 +26,7 @@ DiyaTimerNode class >> timeout: ms doOnce: aBlock [
{ #category : #accessing }
DiyaTimerNode >> delta [
^ DiyaSystemClock delta asMilliSeconds
^ DiyaSystemClock delta
]
{ #category : #accessing }