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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f66973dde19812498125de6276cd0f9c4223ae8
4
- data.tar.gz: a4c5bfb46558556295e14372cbeeae917496f52b
3
+ metadata.gz: 3b5dc8431a881a069a3b6871fb00af1024dd9868
4
+ data.tar.gz: 608d1b9cf139e4f315ed531ab98cfbcb2fe6eb88
5
5
  SHA512:
6
- metadata.gz: c712a4699c2f3055d8b23d1557fb81d10386735e73b4be851c625cbd25d6b88579799c46190ededc04f65df6a4bc873d577b5c357396b86d0a6ab5f2a0df2d6d
7
- data.tar.gz: 30b7bae3790171055f118b58e0fb73343a4bf2a752b2867c79fd2fc69dee501e052ca527a215a896b0cf6d77cb6bc38330cb1901755da94035a7f6126ba9c219
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 = TimeSpan.diff(elapsed.microseconds, @target_frame_microseconds)
37
- slow = (spare.milliseconds < 0)
36
+ spare = @target_frame_microseconds - elapsed.microseconds
37
+ slow = spare < 0
38
38
  if @fixed_time_step && !slow
39
- Thread.current.sleep(spare.seconds)
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)
@@ -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.to_d / 1000.0)
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.to_d * 1000)
18
+ TimeSpan.from_milliseconds(seconds * 1000)
22
19
  end
23
20
 
24
21
  def self.from_minutes(minutes)
25
- TimeSpan.from_milliseconds(minutes.to_d * 60000)
22
+ TimeSpan.from_milliseconds(minutes * 60000)
26
23
  end
27
24
 
28
25
  def self.from_hours(hours)
29
- TimeSpan.from_milliseconds(hours.to_d * 3600000)
26
+ TimeSpan.from_milliseconds(hours * 3600000)
30
27
  end
31
28
 
32
29
  def self.from_days(days)
33
- TimeSpan.from_milliseconds(days.to_d * 86400000)
30
+ TimeSpan.from_milliseconds(days * 86400000)
34
31
  end
35
32
 
36
33
  def self.from_years(years)
37
- TimeSpan.from_days(years.to_d * 365.242)
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.to_d * 1000
42
+ milliseconds * 1000
46
43
  end
47
44
 
48
45
  def seconds
49
- milliseconds.to_d * 0.001
46
+ milliseconds * 0.001
50
47
  end
51
48
 
52
49
  def minutes
53
- seconds.to_d * 0.0166667
50
+ seconds * 0.0166667
54
51
  end
55
52
 
56
53
  def hours
57
- minutes.to_d * 0.0166667
54
+ minutes * 0.0166667
58
55
  end
59
56
 
60
57
  def days
61
- hours.to_d * 0.0416667
58
+ hours * 0.0416667
62
59
  end
63
60
 
64
61
  def years
65
- days.to_d * 0.00273791
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.5
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