From 0b7396242a0ca84b6d3ae86c577231c5f2f197a3 Mon Sep 17 00:00:00 2001 From: Dany LE Date: Sun, 14 Aug 2022 22:49:36 +0200 Subject: [PATCH] Refactor code on System clock --- Diya/DiyaApplicationLauncher.class.st | 2 +- Diya/DiyaBoot.class.st | 2 +- Diya/DiyaClock.class.st | 6 +++--- Diya/DiyaNode.class.st | 1 - Diya/DiyaRootNode.class.st | 2 +- Diya/DiyaTimerNode.class.st | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Diya/DiyaApplicationLauncher.class.st b/Diya/DiyaApplicationLauncher.class.st index ddae651..35428f6 100644 --- a/Diya/DiyaApplicationLauncher.class.st +++ b/Diya/DiyaApplicationLauncher.class.st @@ -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). diff --git a/Diya/DiyaBoot.class.st b/Diya/DiyaBoot.class.st index 79e64f5..40bc337 100644 --- a/Diya/DiyaBoot.class.st +++ b/Diya/DiyaBoot.class.st @@ -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)). ]. ] diff --git a/Diya/DiyaClock.class.st b/Diya/DiyaClock.class.st index 203db19..a99b8f0 100644 --- a/Diya/DiyaClock.class.st +++ b/Diya/DiyaClock.class.st @@ -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. ] diff --git a/Diya/DiyaNode.class.st b/Diya/DiyaNode.class.st index 61f84b6..9f9b9dd 100644 --- a/Diya/DiyaNode.class.st +++ b/Diya/DiyaNode.class.st @@ -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] ]. ] diff --git a/Diya/DiyaRootNode.class.st b/Diya/DiyaRootNode.class.st index 9d1ddb4..78505d0 100644 --- a/Diya/DiyaRootNode.class.st +++ b/Diya/DiyaRootNode.class.st @@ -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 } diff --git a/Diya/DiyaTimerNode.class.st b/Diya/DiyaTimerNode.class.st index 7fe3bf0..2fca32d 100644 --- a/Diya/DiyaTimerNode.class.st +++ b/Diya/DiyaTimerNode.class.st @@ -26,7 +26,7 @@ DiyaTimerNode class >> timeout: ms doOnce: aBlock [ { #category : #accessing } DiyaTimerNode >> delta [ - ^ DiyaSystemClock delta asMilliSeconds + ^ DiyaSystemClock delta ] { #category : #accessing }