tungsten-engine 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/core/game.rb +3 -3
- data/lib/core/time_span.rb +12 -15
- metadata +1 -2
- data/CHANGELOG +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b5dc8431a881a069a3b6871fb00af1024dd9868
|
4
|
+
data.tar.gz: 608d1b9cf139e4f315ed531ab98cfbcb2fe6eb88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3533a22827b9f55a6b7ef4571b79da434299e7c1f9cf86734e5554e123ade0c05a9e84dd9a47eb49bd523f5c5f93594001ea4f5a72be66ff969378280fd63756
|
7
|
+
data.tar.gz: b9eaba6247ac42593dfbf7cd91bf86a3b101cc85736d349feb27c60cd69fba1e67efe622ae16f5a7305b18fdf0c0ceefe92a8202820d69e7650c9b93812fd0c1
|
data/lib/core/game.rb
CHANGED
@@ -33,10 +33,10 @@ module TungstenEngine
|
|
33
33
|
now = Time.now
|
34
34
|
total = TimeSpan.diff(started, now)
|
35
35
|
elapsed = TimeSpan.diff(last_loop, now)
|
36
|
-
spare =
|
37
|
-
slow =
|
36
|
+
spare = @target_frame_microseconds - elapsed.microseconds
|
37
|
+
slow = spare < 0
|
38
38
|
if @fixed_time_step && !slow
|
39
|
-
|
39
|
+
sleep(spare / 1_000_000)
|
40
40
|
now = Time.now
|
41
41
|
total = TimeSpan.diff(started, now)
|
42
42
|
elapsed = TimeSpan.diff(last_loop, now)
|
data/lib/core/time_span.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'bigdecimal'
|
2
|
-
require 'bigdecimal/util'
|
3
|
-
|
4
1
|
module TungstenEngine
|
5
2
|
module Core
|
6
3
|
# Represents the span between two points in time
|
@@ -8,7 +5,7 @@ module TungstenEngine
|
|
8
5
|
attr_accessor :milliseconds
|
9
6
|
|
10
7
|
def self.from_microseconds(microseconds)
|
11
|
-
TimeSpan.from_milliseconds(microseconds
|
8
|
+
TimeSpan.from_milliseconds(microseconds / 1000.0)
|
12
9
|
end
|
13
10
|
|
14
11
|
def self.from_milliseconds(milliseconds)
|
@@ -18,23 +15,23 @@ module TungstenEngine
|
|
18
15
|
end
|
19
16
|
|
20
17
|
def self.from_seconds(seconds)
|
21
|
-
TimeSpan.from_milliseconds(seconds
|
18
|
+
TimeSpan.from_milliseconds(seconds * 1000)
|
22
19
|
end
|
23
20
|
|
24
21
|
def self.from_minutes(minutes)
|
25
|
-
TimeSpan.from_milliseconds(minutes
|
22
|
+
TimeSpan.from_milliseconds(minutes * 60000)
|
26
23
|
end
|
27
24
|
|
28
25
|
def self.from_hours(hours)
|
29
|
-
TimeSpan.from_milliseconds(hours
|
26
|
+
TimeSpan.from_milliseconds(hours * 3600000)
|
30
27
|
end
|
31
28
|
|
32
29
|
def self.from_days(days)
|
33
|
-
TimeSpan.from_milliseconds(days
|
30
|
+
TimeSpan.from_milliseconds(days * 86400000)
|
34
31
|
end
|
35
32
|
|
36
33
|
def self.from_years(years)
|
37
|
-
TimeSpan.from_days(years
|
34
|
+
TimeSpan.from_days(years * 365.242)
|
38
35
|
end
|
39
36
|
|
40
37
|
def self.diff(start_date_time, end_date_time)
|
@@ -42,27 +39,27 @@ module TungstenEngine
|
|
42
39
|
end
|
43
40
|
|
44
41
|
def microseconds
|
45
|
-
milliseconds
|
42
|
+
milliseconds * 1000
|
46
43
|
end
|
47
44
|
|
48
45
|
def seconds
|
49
|
-
milliseconds
|
46
|
+
milliseconds * 0.001
|
50
47
|
end
|
51
48
|
|
52
49
|
def minutes
|
53
|
-
seconds
|
50
|
+
seconds * 0.0166667
|
54
51
|
end
|
55
52
|
|
56
53
|
def hours
|
57
|
-
minutes
|
54
|
+
minutes * 0.0166667
|
58
55
|
end
|
59
56
|
|
60
57
|
def days
|
61
|
-
hours
|
58
|
+
hours * 0.0416667
|
62
59
|
end
|
63
60
|
|
64
61
|
def years
|
65
|
-
days
|
62
|
+
days * 0.00273791
|
66
63
|
end
|
67
64
|
end
|
68
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tungsten-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Meschke
|
@@ -16,7 +16,6 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
-
- CHANGELOG
|
20
19
|
- LICENSE
|
21
20
|
- lib/core/game.rb
|
22
21
|
- lib/core/game_component.rb
|
data/CHANGELOG
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
[Version 0.0.4]
|
2
|
-
- fixed bug with numeric comparison in Game class
|
3
|
-
|
4
|
-
[Version 0.0.3]
|
5
|
-
- added missing bigdecimal requirements for TimeSpan class
|
6
|
-
|
7
|
-
[Version 0.0.2]
|
8
|
-
- added this Changelog file
|
9
|
-
- added exit method to Game class
|
10
|
-
|
11
|
-
[Version 0.0.1]
|
12
|
-
- added missing fields in gemspec file
|