ruby_rpg 0.1.8 → 0.1.9
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 769a91f8159d9aed38de9b6c28a54d22c689cf6d76c324c7134268c9a8ea62aa
|
|
4
|
+
data.tar.gz: e5826c1683aace32d57f1ca3b768e0053c904b13e84c79af48b370dc51f97875
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f0b7766c93a825b419e5dae5b4ad24d35064fcdb8e682b3caada78f55a74a7405373cb9da4eceea51962043c7debb3c1ec5bbb11f42e2054e56f4970a1fd0bb
|
|
7
|
+
data.tar.gz: f8a43c50a9eb8f65dc8d7acd8eaf1eab538af371e5545afd2cf1c8d30c20563084bacb1d8da2e0e3cfca110188b2b153fe49660ec0950b7ee2396a82f3cfde28
|
|
@@ -7,10 +7,9 @@ module Engine::Components
|
|
|
7
7
|
attr_reader :mesh, :texture
|
|
8
8
|
|
|
9
9
|
def awake
|
|
10
|
-
# Original vertex order for ear-clipping, UVs flipped for Y-down camera
|
|
11
10
|
@mesh = Engine::PolygonMesh.new(
|
|
12
11
|
[Vector[-0.5, 0.5], Vector[0.5, 0.5], Vector[0.5, -0.5], Vector[-0.5, -0.5]],
|
|
13
|
-
[[0,
|
|
12
|
+
[[0, 0], [1, 0], [1, 1], [0, 1]]
|
|
14
13
|
)
|
|
15
14
|
@texture = @font.texture.texture
|
|
16
15
|
end
|
|
@@ -98,12 +98,11 @@ module Engine::Components
|
|
|
98
98
|
return if @cached_rect == rect
|
|
99
99
|
@cached_rect = rect
|
|
100
100
|
|
|
101
|
-
# UV V=1 at screen bottom, V=0 at screen top (matches PNG top-to-bottom storage)
|
|
102
101
|
vertices = [
|
|
103
|
-
rect.left, rect.bottom, 0, 0,
|
|
104
|
-
rect.right, rect.bottom, 0, 1,
|
|
105
|
-
rect.right, rect.top, 0, 1,
|
|
106
|
-
rect.left, rect.top, 0, 0,
|
|
102
|
+
rect.left, rect.bottom, 0, 0, 0, # bottom-left
|
|
103
|
+
rect.right, rect.bottom, 0, 1, 0, # bottom-right
|
|
104
|
+
rect.right, rect.top, 0, 1, 1, # top-right
|
|
105
|
+
rect.left, rect.top, 0, 0, 1 # top-left
|
|
107
106
|
]
|
|
108
107
|
|
|
109
108
|
Engine::GL.BindBuffer(Engine::GL::ARRAY_BUFFER, @vbo)
|
data/lib/engine/font.rb
CHANGED
|
@@ -89,7 +89,9 @@ module Engine
|
|
|
89
89
|
next
|
|
90
90
|
end
|
|
91
91
|
offsets << [horizontal_offset, vertical_offset]
|
|
92
|
-
|
|
92
|
+
idx = index_table[char]
|
|
93
|
+
original_idx = (idx / GLYPH_COUNT) * GLYPH_COUNT + (GLYPH_COUNT - 1 - idx % GLYPH_COUNT)
|
|
94
|
+
horizontal_offset += 30 * scale_factor * font_metrics[original_idx.to_s]["width"]
|
|
93
95
|
end
|
|
94
96
|
offsets
|
|
95
97
|
end
|
|
@@ -116,8 +118,8 @@ module Engine
|
|
|
116
118
|
GLYPH_COUNT.times.each do |y|
|
|
117
119
|
index = x * GLYPH_COUNT + y
|
|
118
120
|
next if index >= 255
|
|
119
|
-
|
|
120
|
-
hash[character] =
|
|
121
|
+
flipped_index = x * GLYPH_COUNT + (GLYPH_COUNT - 1 - y)
|
|
122
|
+
hash[character(index)] = flipped_index
|
|
121
123
|
end
|
|
122
124
|
end
|
|
123
125
|
hash
|
|
@@ -6,13 +6,13 @@ module Engine
|
|
|
6
6
|
def vertex_data
|
|
7
7
|
@vertex_data ||= [
|
|
8
8
|
# top-left
|
|
9
|
-
-0.5, 0.5, 0.0, 0.0,
|
|
9
|
+
-0.5, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
|
10
10
|
# top-right
|
|
11
|
-
0.5, 0.5, 0.0, 1.0,
|
|
11
|
+
0.5, 0.5, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
|
12
12
|
# bottom-right
|
|
13
|
-
0.5, -0.5, 0.0, 1.0,
|
|
13
|
+
0.5, -0.5, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
|
14
14
|
# bottom-left
|
|
15
|
-
-0.5, -0.5, 0.0, 0.0,
|
|
15
|
+
-0.5, -0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
|
16
16
|
]
|
|
17
17
|
end
|
|
18
18
|
|
data/lib/engine/texture.rb
CHANGED
|
@@ -7,11 +7,11 @@ module Engine
|
|
|
7
7
|
attr_reader :texture, :source
|
|
8
8
|
|
|
9
9
|
def self.from_serializable_data(data)
|
|
10
|
-
self.for(data[:path],
|
|
10
|
+
self.for(data[:path], source: (data[:source] || :game).to_sym)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def serializable_data
|
|
14
|
-
{ path: @relative_path,
|
|
14
|
+
{ path: @relative_path, source: @source }
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def awake
|
|
@@ -19,13 +19,13 @@ module Engine
|
|
|
19
19
|
load_texture
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def self.for(path,
|
|
22
|
+
def self.for(path, source: :game)
|
|
23
23
|
full_path = if source == :engine
|
|
24
24
|
File.expand_path(File.join(ENGINE_DIR, "assets", path))
|
|
25
25
|
else
|
|
26
26
|
File.expand_path(File.join(GAME_DIR, path))
|
|
27
27
|
end
|
|
28
|
-
texture_cache[[path,
|
|
28
|
+
texture_cache[[path, source]] ||= create(relative_path: path, file_path: full_path, source: source)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def self.texture_cache
|
|
@@ -42,21 +42,20 @@ module Engine
|
|
|
42
42
|
Engine::GL.TexParameteri(Engine::GL::TEXTURE_2D, Engine::GL::TEXTURE_MIN_FILTER, Engine::GL::LINEAR)
|
|
43
43
|
Engine::GL.TexParameteri(Engine::GL::TEXTURE_2D, Engine::GL::TEXTURE_MAG_FILTER, Engine::GL::LINEAR)
|
|
44
44
|
|
|
45
|
-
image =
|
|
45
|
+
image = ChunkyPNG::Image.from_file(@file_path)
|
|
46
46
|
image_data = image.to_rgba_stream
|
|
47
47
|
image_width = image.width
|
|
48
48
|
image_height = image.height
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if @flip
|
|
56
|
-
ChunkyPNG::Image.from_file(@file_path).flip_horizontally
|
|
57
|
-
else
|
|
58
|
-
ChunkyPNG::Image.from_file(@file_path)
|
|
50
|
+
# Flip rows vertically so textures follow OpenGL convention (V=0 at bottom)
|
|
51
|
+
row_size = image_width * 4
|
|
52
|
+
flipped = String.new(capacity: image_data.bytesize)
|
|
53
|
+
(image_height - 1).downto(0) do |row|
|
|
54
|
+
flipped << image_data.byteslice(row * row_size, row_size)
|
|
59
55
|
end
|
|
56
|
+
|
|
57
|
+
Engine::GL.TexImage2D(Engine::GL::TEXTURE_2D, 0, Engine::GL::RGBA32F, image_width, image_height, 0, Engine::GL::RGBA, Engine::GL::UNSIGNED_BYTE, flipped)
|
|
58
|
+
Engine::GL.GenerateMipmap(Engine::GL::TEXTURE_2D)
|
|
60
59
|
end
|
|
61
60
|
end
|
|
62
61
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_rpg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Max Hatfull
|
|
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
312
312
|
- !ruby/object:Gem::Version
|
|
313
313
|
version: '0'
|
|
314
314
|
requirements: []
|
|
315
|
-
rubygems_version: 4.0.
|
|
315
|
+
rubygems_version: 4.0.6
|
|
316
316
|
specification_version: 4
|
|
317
317
|
summary: A game engine written in Ruby
|
|
318
318
|
test_files: []
|