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:
parent
681d8951b7
commit
0b7396242a
@ -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).
|
||||
|
@ -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)).
|
||||
].
|
||||
]
|
||||
|
||||
|
@ -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.
|
||||
]
|
||||
|
@ -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]
|
||||
].
|
||||
]
|
||||
|
@ -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 }
|
||||
|
@ -26,7 +26,7 @@ DiyaTimerNode class >> timeout: ms doOnce: aBlock [
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaTimerNode >> delta [
|
||||
^ DiyaSystemClock delta asMilliSeconds
|
||||
^ DiyaSystemClock delta
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
Loading…
Reference in New Issue
Block a user