tungsten-engine 0.0.1 → 0.0.2

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +6 -0
  3. data/LICENSE +21 -0
  4. data/lib/core/game.rb +21 -14
  5. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27921d9333ce3bedeb6fc32b8a04a1834397eace
4
- data.tar.gz: 16e385f0f877b34a409fa0142d40fc6fa2bec91c
3
+ metadata.gz: 489121b69607d85bb5441edd3ec203943e1ddb1b
4
+ data.tar.gz: 062f6b07b713fcb043947322450bbf3c8969f2a8
5
5
  SHA512:
6
- metadata.gz: b673865162cd6f03fa8889703b2f8d2e8c1cc70f5a4021da2568a3e2c1eaf45fe0cd054401bbfd35d8916ca5d0a2df53e55c1aa4d691c5d23910c9c0ec28ecef
7
- data.tar.gz: 54d3ca04c56fcdd3b4fb07b45a432954daa5de5e5eadcc9f49fae00909cff8ca4c8cfdec5c2d59d882d98d613fd9f588d080e3318ec7b24ae1b5a50e6c8dd1b0
6
+ metadata.gz: 1d0c79f7b9a39489a2c5682d65028c33ee74f2ba09b2ef85c6ec0b63bde874b81fede21dd8cb924de3cbac616f8a320c64d7ba593e2db843833c521ca8f98abb
7
+ data.tar.gz: 89ceee88ce6182593c1d9a4cc6027e47433ac3cd389c00c5889b7caeea5d94dd02944f29bb7882fb39949eabff9a7bab74d145cc1d2198251522b5768f0fd7e6
data/CHANGELOG ADDED
@@ -0,0 +1,6 @@
1
+ [Version 0.0.2]
2
+ - added this Changelog file
3
+ - added exit method to Game class
4
+
5
+ [Version 0.0.1]
6
+ - added missing fields in gemspec file
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) Thomas Meschke, 2018
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/lib/core/game.rb CHANGED
@@ -26,26 +26,29 @@ module TungstenEngine
26
26
  def run
27
27
  started = Time.now
28
28
  last_loop = Time.now
29
+ @running = true
29
30
 
30
31
  game_loop = Thread.new do
31
- now = Time.now
32
- total = TimeSpan.diff(started, now)
33
- elapsed = TimeSpan.diff(last_loop, now)
34
- spare = TimeSpan.diff(elapsed.microseconds, @target_frame_microseconds)
35
- slow = spare < 0
36
- if @fixed_time_step && !slow
37
- Thread.current.sleep(spare.seconds)
32
+ while @running
38
33
  now = Time.now
39
34
  total = TimeSpan.diff(started, now)
40
35
  elapsed = TimeSpan.diff(last_loop, now)
41
- # do not re-calculate 'slow' here, since we want to know if we
42
- # have been to slow when the loop was entered again, not if we maybe
43
- # are too slow after waiting
36
+ spare = TimeSpan.diff(elapsed.microseconds, @target_frame_microseconds)
37
+ slow = spare < 0
38
+ if @fixed_time_step && !slow
39
+ Thread.current.sleep(spare.seconds)
40
+ now = Time.now
41
+ total = TimeSpan.diff(started, now)
42
+ elapsed = TimeSpan.diff(last_loop, now)
43
+ # do not re-calculate 'slow' here, since we want to know if we
44
+ # have been to slow when the loop was entered again, not if we maybe
45
+ # are too slow after waiting
46
+ end
47
+ game_time = GameTime.new(total, elapsed, slow)
48
+ update(game_time)
49
+ render(game_time)
50
+ last_loop = now
44
51
  end
45
- game_time = GameTime.new(total, elapsed, slow)
46
- update(game_time)
47
- render(game_time)
48
- last_loop = now
49
52
  end
50
53
  game_loop.join
51
54
  end
@@ -62,6 +65,10 @@ module TungstenEngine
62
65
  end
63
66
  end
64
67
 
68
+ def exit
69
+ @running = false
70
+ end
71
+
65
72
  end
66
73
  end
67
74
  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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Meschke
@@ -16,6 +16,8 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - CHANGELOG
20
+ - LICENSE
19
21
  - lib/core/game.rb
20
22
  - lib/core/game_component.rb
21
23
  - lib/core/game_time.rb