1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2024-12-27 03:48:21 +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 } { #category : #initialization }
DiyaApplicationLauncher >> main [ DiyaApplicationLauncher >> main [
| fps delta| | fps delta|
delta := DiyaSystemClock delta asMilliSeconds. delta := DiyaSystemClock delta.
fps := DiyaSystemSettings maxFPS. fps := DiyaSystemSettings maxFPS.
delta = 0 ifFalse:[ fps := (1000/ delta) asInteger]. delta = 0 ifFalse:[ fps := (1000/ delta) asInteger].
txtFPS data: ('FPS:', fps asString). txtFPS data: ('FPS:', fps asString).

View File

@ -108,7 +108,7 @@ DiyaBoot >> render [
DiyaRenderer render. DiyaRenderer render.
SDL2 delay: SDL2 delay:
(0 max: (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 [ DiyaClock >> initialize [
monotonic := DateAndTime now. monotonic := DateAndTime now.
lastTick := monotonic. lastTick := monotonic.
lapTime := 0 asDuration. lapTime := 0.
] ]
{ #category : #initialization } { #category : #initialization }
DiyaClock >> lapDelta [ DiyaClock >> lapDelta [
^ ((DateAndTime now) - lastTick) ^ ((DateAndTime now) - lastTick) asMilliSeconds
] ]
{ #category : #initialization } { #category : #initialization }
@ -38,6 +38,6 @@ DiyaClock >> lapTime [
{ #category : #initialization } { #category : #initialization }
DiyaClock >> tick [ DiyaClock >> tick [
lapTime := (DateAndTime now) - lastTick. lapTime := self lapDelta.
lastTick := DateAndTime now. lastTick := DateAndTime now.
] ]

View File

@ -330,7 +330,6 @@ DiyaNode >> trigger: evt [
handler value: evt]. handler value: evt].
children ifNil: [^self]. children ifNil: [^self].
evt enable ifTrue: [ evt enable ifTrue: [
"evt mapped triggableOn: children first."
children select: [:node | evt mapped triggableOn: node ] thenDo:[:node| node trigger: evt] 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 ]. (Q isEmpty and: R isEmpty) ifTrue: [ ^false ].
DiyaSystemSettings renderAtOnce ifTrue: [ ^ true ]. DiyaSystemSettings renderAtOnce ifTrue: [ ^ true ].
^(DiyaSystemClock lapDelta asMilliSeconds < maxProcessingTime) ^(DiyaSystemClock lapDelta < maxProcessingTime)
] ]
{ #category : #accessing } { #category : #accessing }

View File

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