ehb_game_lib 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehb_game_lib.rb +1 -0
- data/lib/ehb_game_lib/base_state.rb +24 -1
- data/lib/ehb_game_lib/canvas.rb +20 -0
- data/lib/ehb_game_lib/version.rb +1 -1
- data/lib/ehb_game_lib/window.rb +12 -6
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf628fabf12bc43a3d54ba850cf6d084490cc06e23b33be631a4ea364257704
|
4
|
+
data.tar.gz: 78d473bffc23e2083334ef7700bedd2a9e3b56addd97c0b68e0a6efcce8cbda8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d6c8ec7b605262ff2c587f1320028dbb870c406a4cac19499eaabb1b04b4c73533491ed935834532c73a6853b20f65d36df95925603a6a888dc01cd604732e
|
7
|
+
data.tar.gz: 369d89f071d2d39dbe038fd8bc4f4d473a9256a1b417d32de18bb17129c91d7b86743a5d2df97b5d95b82423a0a2a7ba02d9998ab63620cdcb8c8eeee0008b01
|
data/lib/ehb_game_lib.rb
CHANGED
@@ -2,9 +2,32 @@
|
|
2
2
|
|
3
3
|
module EhbGameLib
|
4
4
|
class BaseState < ::Chingu::GameState
|
5
|
+
class << self
|
6
|
+
attr_writer :resize_enabled
|
7
|
+
|
8
|
+
def resize_enabled
|
9
|
+
@resize_enabled = true if @resize_enabled.nil?
|
10
|
+
@resize_enabled
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_resize_enabled(enabled)
|
14
|
+
old_value = resize_enabled
|
15
|
+
begin
|
16
|
+
self.resize_enabled = enabled
|
17
|
+
yield
|
18
|
+
ensure
|
19
|
+
self.resize_enabled = old_value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
5
24
|
def draw
|
6
25
|
super
|
7
|
-
::EhbGameLib::Globals.window.draw_resized
|
26
|
+
::EhbGameLib::Globals.window.draw_resized if resize_enabled?
|
27
|
+
end
|
28
|
+
|
29
|
+
def resize_enabled?
|
30
|
+
::EhbGameLib::BaseState.resize_enabled
|
8
31
|
end
|
9
32
|
end
|
10
33
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehb_game_lib/math/rectable_object'
|
5
|
+
|
6
|
+
module EhbGameLib
|
7
|
+
class Canvas
|
8
|
+
include ::EhbGameLib::Math::RectableObject
|
9
|
+
|
10
|
+
common_constructor :width, :height
|
11
|
+
|
12
|
+
def x
|
13
|
+
0
|
14
|
+
end
|
15
|
+
|
16
|
+
def y
|
17
|
+
0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/ehb_game_lib/version.rb
CHANGED
data/lib/ehb_game_lib/window.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehb_game_lib/canvas'
|
5
|
+
|
3
6
|
module EhbGameLib
|
4
7
|
class Window < ::Chingu::Window
|
5
8
|
attr_accessor :fit_canvas_to_window, :draw_retro
|
6
|
-
attr_reader :
|
9
|
+
attr_reader :canvas, :canvas_factor
|
7
10
|
|
8
11
|
def initialize(canvas_width, canvas_height)
|
9
|
-
@
|
10
|
-
@canvas_height = canvas_height
|
12
|
+
@canvas = ::EhbGameLib::Canvas.new(canvas_width, canvas_height)
|
11
13
|
@canvas_factor = 1
|
12
14
|
self.fit_canvas_to_window = true
|
13
15
|
self.draw_retro = true
|
@@ -15,11 +17,11 @@ module EhbGameLib
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def calculated_width
|
18
|
-
|
20
|
+
canvas.width * canvas_factor
|
19
21
|
end
|
20
22
|
|
21
23
|
def calculated_height
|
22
|
-
|
24
|
+
canvas.height * canvas_factor
|
23
25
|
end
|
24
26
|
|
25
27
|
def canvas_factor=(factor)
|
@@ -42,7 +44,11 @@ module EhbGameLib
|
|
42
44
|
private
|
43
45
|
|
44
46
|
def canvas_image_source
|
45
|
-
image_source(0, height -
|
47
|
+
image_source(0, height - canvas.height, canvas.width, canvas.height)
|
48
|
+
end
|
49
|
+
|
50
|
+
def canvas_rect_uncached
|
51
|
+
::EhbGameLib::Math::Rect.new(0, 0, canvas.width, canvas.height)
|
46
52
|
end
|
47
53
|
|
48
54
|
def image_source(x, y, w, h)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ehb_game_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.8.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: eac_ruby_utils
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.19'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.19'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: gosu
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,6 +131,7 @@ extra_rdoc_files: []
|
|
117
131
|
files:
|
118
132
|
- lib/ehb_game_lib.rb
|
119
133
|
- lib/ehb_game_lib/base_state.rb
|
134
|
+
- lib/ehb_game_lib/canvas.rb
|
120
135
|
- lib/ehb_game_lib/gfx.rb
|
121
136
|
- lib/ehb_game_lib/globals.rb
|
122
137
|
- lib/ehb_game_lib/math/circle.rb
|