author_engine 0.3.1 → 0.4.0

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
  SHA256:
3
- metadata.gz: 2b0ed83b1789611ce299e93ba4c65a128c9ae850d1cc41500aa2149b9f082d5c
4
- data.tar.gz: '0932dae0bbe2861acd38afea1c78ca0a2df63635bf22315ad0dbd814f44d97d8'
3
+ metadata.gz: 694fa108a1f195431f1a2e19a9c27f23b26b1749d671f564f8cbbf4a5763b6a7
4
+ data.tar.gz: 0b366a28a323cd1dbc2fff3854ee6785fd35561ec0c0f6cf2d175dcddf5eba7d
5
5
  SHA512:
6
- metadata.gz: 941e0720e6015e6a8eb0d13db26ef7b737faeb90bbc9b2d0fb12ecfd93e44f4fde9976ff84975fcc6f91992465cdd45fdafcbefa88586e15c377a5ad82d3276d
7
- data.tar.gz: c9afb5e551586b5126f01090ff1825df1ab60303051082c736b6aa231fd8f3b125684a803b390efea3fb8ed1a9197b991ee98006c4829c6b7d0c2e37790d97c9
6
+ metadata.gz: 5516f268ab834bc8ea4b78e81a12ece30471e9dfd8a88a79bd21265067a161345bc923825572917afb17a2222cec2214b7d02768b9ec1fe4836346f007914769
7
+ data.tar.gz: f047c5ca5837b0ccac07690fb9ce939e22705bb90357837e66ca8d35bb3570ac1de98b22bbbeeb774b4cd07462334833cfb3d691054e56e1c197c20a44bb1b19
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- author_engine (0.3.1)
4
+ author_engine (0.4.0)
5
5
  coderay (~> 1.1.2)
6
6
  gosu (~> 0.14.4)
7
7
  opal (~> 0.11.4)
@@ -45,7 +45,11 @@ class AuthorEngine
45
45
  def peach; rgb(COLORS.dig(15)); end
46
46
 
47
47
  def rgb(color)
48
- return "rgb(#{color.red}, #{color.green}, #{color.blue})"
48
+ if RUBY_ENGINE == "opal"
49
+ return "rgb(#{color.red}, #{color.green}, #{color.blue})"
50
+ else
51
+ return Gosu::Color.rgb(color.red, color.green, color.blue)
52
+ end
49
53
  end
50
54
 
51
55
  def xml_color(color)
@@ -0,0 +1,30 @@
1
+ class AuthorEngine
2
+ class Part
3
+ module Common
4
+ def width
5
+ 128
6
+ end
7
+
8
+ def height
9
+ 128
10
+ end
11
+
12
+ def fps
13
+ if RUBY_ENGINE == "opal"
14
+ AuthorEngine::GameRunner.instance.fps
15
+ else
16
+ Gosu.fps
17
+ end
18
+ end
19
+
20
+ def milliseconds
21
+ if RUBY_ENGINE == "opal"
22
+ @__initial_milliseconds ||= `performance.now()`
23
+ (`performance.now()` - @__initial_milliseconds).round(3)
24
+ else
25
+ Gosu.milliseconds
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -3,8 +3,14 @@ class AuthorEngine
3
3
  include AuthorEngine::Part::Common
4
4
  include AuthorEngine::Part::CollisionDetection
5
5
  include AuthorEngine::Part::Colors
6
- include AuthorEngine::Part::Graphics
7
- include AuthorEngine::Part::Input
6
+
7
+ if RUBY_ENGINE == "opal"
8
+ include AuthorEngine::Part::OpalGraphics
9
+ include AuthorEngine::Part::OpalInput
10
+ else
11
+ include AuthorEngine::Part::GosuGraphics
12
+ include AuthorEngine::Part::GosuInput
13
+ end
8
14
 
9
15
  attr_accessor :scale, :canvas, :canvas_context
10
16
  attr_accessor :collision_detection
@@ -1,6 +1,6 @@
1
1
  class AuthorEngine
2
2
  class Part
3
- module Graphics
3
+ module GosuGraphics
4
4
  def rect(x = 0, y = 0, width = 1, height = 1, color = Gosu::Color::WHITE, z = 0)
5
5
  Gosu.draw_rect(x, y, width, height, color, z)
6
6
  end
@@ -1,6 +1,6 @@
1
1
  class AuthorEngine
2
2
  class Part
3
- module Input
3
+ module GosuInput
4
4
  BUTTONS = {
5
5
  "left" => Gosu::KbLeft,
6
6
  "right" => Gosu::KbRight,
@@ -147,8 +147,8 @@ class AuthorEngine
147
147
  return unless RUBY_ENGINE == "opal"
148
148
 
149
149
  `window.addEventListener('resize', () => { #{resize_canvas} })`
150
- `document.addEventListener('keydown', (event) => { #{AuthorEngine::Part::Input::KEY_STATES[`event.key`] = true} })`
151
- `document.addEventListener('keyup', (event) => { #{AuthorEngine::Part::Input::KEY_STATES[`event.key`] = false} })`
150
+ `document.addEventListener('keydown', (event) => { #{AuthorEngine::Part::OpalInput::KEY_STATES[`event.key`] = true} })`
151
+ `document.addEventListener('keyup', (event) => { #{AuthorEngine::Part::OpalInput::KEY_STATES[`event.key`] = false} })`
152
152
 
153
153
  `document.getElementById('loading').style.display = "none"`
154
154
  `window.requestAnimationFrame(function() {#{run_game}})`
@@ -1,6 +1,6 @@
1
1
  class AuthorEngine
2
2
  class Part
3
- module Graphics
3
+ module OpalGraphics
4
4
  def rect(x = 0, y = 0, width = 1, height = 1, color = "white", z = 0)
5
5
  `#{@canvas_context}.fillStyle = #{color}`
6
6
  `#{@canvas_context}.fillRect(#{x}, #{y}, #{width}, #{height})`
@@ -1,6 +1,6 @@
1
1
  class AuthorEngine
2
2
  class Part
3
- module Input
3
+ module OpalInput
4
4
  BUTTONS = {
5
5
  "left" => "ArrowLeft",
6
6
  "right" => "ArrowRight",
@@ -1,9 +1,9 @@
1
1
  raise "Only require \"author_engine/opal\" with Opal!" unless RUBY_ENGINE == "opal"
2
2
 
3
+ require_relative "game/common/parts/common"
3
4
  require_relative "game/common/parts/collision_detection"
5
+ require_relative "game/common/parts/colors"
4
6
 
5
- require_relative "game/opal/parts/common"
6
- require_relative "game/opal/parts/colors"
7
7
  require_relative "game/opal/parts/graphics"
8
8
  require_relative "game/opal/parts/input"
9
9
 
@@ -1,3 +1,3 @@
1
1
  class AuthorEngine
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/author_engine.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require "gosu"
2
2
  require "coderay"
3
3
 
4
+ require_relative "author_engine/game/common/parts/common"
4
5
  require_relative "author_engine/game/common/parts/collision_detection"
6
+ require_relative "author_engine/game/common/parts/colors"
5
7
 
6
- require_relative "author_engine/game/gosu/parts/common"
7
8
  require_relative "author_engine/game/gosu/parts/graphics"
8
- require_relative "author_engine/game/gosu/parts/colors"
9
9
  require_relative "author_engine/game/gosu/parts/input"
10
10
 
11
11
  require_relative "author_engine/window"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: author_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyberarm
@@ -137,15 +137,13 @@ files:
137
137
  - lib/author_engine/containers/editor.rb
138
138
  - lib/author_engine/containers/loader.rb
139
139
  - lib/author_engine/game/common/parts/collision_detection.rb
140
+ - lib/author_engine/game/common/parts/colors.rb
141
+ - lib/author_engine/game/common/parts/common.rb
140
142
  - lib/author_engine/game/game.rb
141
- - lib/author_engine/game/gosu/parts/colors.rb
142
- - lib/author_engine/game/gosu/parts/common.rb
143
143
  - lib/author_engine/game/gosu/parts/graphics.rb
144
144
  - lib/author_engine/game/gosu/parts/input.rb
145
145
  - lib/author_engine/game/opal/exporter.rb
146
146
  - lib/author_engine/game/opal/game_runner.rb
147
- - lib/author_engine/game/opal/parts/colors.rb
148
- - lib/author_engine/game/opal/parts/common.rb
149
147
  - lib/author_engine/game/opal/parts/graphics.rb
150
148
  - lib/author_engine/game/opal/parts/input.rb
151
149
  - lib/author_engine/image.rb
@@ -1,59 +0,0 @@
1
- class AuthorEngine
2
- class Part
3
- module Colors
4
- COLORS = {
5
- 0 => Gosu::Color.rgb(0,0,0),
6
- 1 => Gosu::Color.rgb(29, 43, 83),
7
- 2 => Gosu::Color.rgb(126, 37, 83),
8
- 3 => Gosu::Color.rgb(0, 135, 81),
9
-
10
- 4 => Gosu::Color.rgb(171, 82, 54),
11
- 5 => Gosu::Color.rgb(95, 87, 79),
12
- 6 => Gosu::Color.rgb(194, 195, 199),
13
- 7 => Gosu::Color.rgb(255, 241, 232),
14
-
15
- 8 => Gosu::Color.rgb(255, 0, 77),
16
- 9 => Gosu::Color.rgb(255, 163, 0),
17
- 10 => Gosu::Color.rgb(225, 236, 39),
18
- 11 => Gosu::Color.rgb(0, 228, 54),
19
-
20
- 12 => Gosu::Color.rgb(41, 173, 255),
21
- 13 => Gosu::Color.rgb(131, 118, 156),
22
- 14 => Gosu::Color.rgb(225, 119, 168),
23
- 15 => Gosu::Color.rgb(255, 204, 170)
24
- }
25
-
26
- def black; COLORS.dig(0); end
27
- def dark_blue; COLORS.dig(1); end
28
- def dark_purple; COLORS.dig(2); end
29
- def dark_green; COLORS.dig(3); end
30
-
31
- def brown; COLORS.dig(4); end
32
- def dark_gray; COLORS.dig(5); end
33
- def light_gray; COLORS.dig(6); end
34
- def white; COLORS.dig(7); end
35
-
36
- def red; COLORS.dig(8); end
37
- def orange; COLORS.dig(9); end
38
- def yellow; COLORS.dig(10); end
39
- def green; COLORS.dig(11); end
40
-
41
- def blue; COLORS.dig(12); end
42
- def indigo; COLORS.dig(13); end
43
- def pink; COLORS.dig(14); end
44
- def peach; COLORS.dig(15); end
45
-
46
- def xml_color(color)
47
- red = color.red.to_s(16)
48
- green = color.green.to_s(16)
49
- blue = color.blue.to_s(16)
50
-
51
- red = "0#{red}" if color.red < 10
52
- green = "0#{green}" if color.green < 10
53
- blue = "0#{blue}" if color.blue < 10
54
-
55
- return "#{red}#{green}#{blue}"
56
- end
57
- end
58
- end
59
- end
@@ -1,13 +0,0 @@
1
- class AuthorEngine
2
- class Part
3
- module Common
4
- def width; Window::VIEW_WIDTH; end
5
- def height; Window::VIEW_HEIGHT; end
6
- def fps; Gosu.fps; end
7
- def milliseconds
8
- @__initial_milliseconds ||= Gosu.milliseconds
9
- Gosu.milliseconds - @__initial_milliseconds
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- class AuthorEngine
2
- class Part
3
- module Common
4
- def width; 128; end
5
- def height; 128; end
6
- def fps; AuthorEngine::GameRunner.instance.fps; end
7
- def milliseconds
8
- @__initial_milliseconds ||= `performance.now()`
9
- (`performance.now()` - @__initial_milliseconds).round(3)
10
- end
11
- end
12
- end
13
- end