gosu-examples 1.0.4 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/bin/gosu-examples +20 -22
- data/examples/chipmunk_and_rmagick.rb +25 -28
- data/examples/chipmunk_integration.rb +45 -48
- data/examples/cptn_ruby.rb +23 -26
- data/examples/opengl_integration.rb +61 -62
- data/examples/rmagick_integration.rb +87 -88
- data/examples/text_input.rb +157 -0
- data/examples/tutorial.rb +23 -26
- data/examples/welcome.rb +20 -23
- data/lib/gosu-examples/example.rb +34 -13
- data/lib/gosu-examples/sidebar.rb +16 -16
- metadata +10 -36
- data/examples/media/BrokenPNG.png +0 -0
- data/examples/media/Cursor.png +0 -0
- data/examples/media/JingleBells.mp3 +0 -0
- data/examples/media/JingleBells.ogg +0 -0
- data/examples/media/Loop.wav +0 -0
- data/examples/media/Sample.wav +0 -0
- data/examples/media/SquareTexture.png +0 -0
- data/examples/media/Wallpaper.png +0 -0
- data/examples/media/WallpaperXXL.png +0 -0
- data/examples/media/WhiteAlpha.png +0 -0
- data/examples/media/audio_formats/aiff_32bit_float.aiff +0 -0
- data/examples/media/audio_formats/au_16bit_pcm.au +0 -0
- data/examples/media/audio_formats/caf_be_16bit_44khz.caf +0 -0
- data/examples/media/audio_formats/caf_le_16bit_44khz.caf +0 -0
- data/examples/media/audio_formats/caf_le_8bit_44khz.caf +0 -0
- data/examples/media/audio_formats/general_midi.mid +0 -0
- data/examples/media/audio_formats/impulse_tracker.it +0 -0
- data/examples/media/audio_formats/mp3_128k_stereo.mp3 +0 -0
- data/examples/media/audio_formats/mp3_avg_96kbit_jointstereo.mp3 +0 -0
- data/examples/media/audio_formats/ogg_vorbis.ogg +0 -0
- data/examples/media/audio_formats/wav_16bit_pcm.wav +0 -0
- data/examples/media/audio_formats/wav_32bit_pcm.wav +0 -0
- data/examples/media/audio_formats/wav_4bit_ms_adpcm.wav +0 -0
- data/examples/media/image_formats/test.jpg +0 -0
- data/examples/media/image_formats/test.psd +0 -0
- data/examples/media/vera.ttf +0 -0
@@ -0,0 +1,157 @@
|
|
1
|
+
# This example demonstrates use of the TextInput class with three text field widgets.
|
2
|
+
# One can cycle through them with tab, or click into the text fields and change their contents.
|
3
|
+
|
4
|
+
# The way TextInput works is that you create an instance of it, and then assign it to the text_input
|
5
|
+
# attribute of your window.
|
6
|
+
# Until you set this attribute to nil again, the TextInput object will then build a string from user
|
7
|
+
# input that can be accessed via TextInput#text.
|
8
|
+
|
9
|
+
# The TextInput object also maintains the position of the caret, which is defined as the index of
|
10
|
+
# its right neighbour character, i.e. a carent_pos of 0 is always the left-most position, and a
|
11
|
+
# caret_pos of text.length is always the right-most position.
|
12
|
+
# There is a second attribute called selection_start that is equal to caret_pos when there is no
|
13
|
+
# selection, and otherwise defines the selected range. If you set caret_pos to a different value,
|
14
|
+
# you usually want to set selection_start as well.
|
15
|
+
|
16
|
+
# A TextInput object is purely abstract. Drawing the input field is left to the user.
|
17
|
+
# In this example, we are subclassing TextInput to add this code, but you can also work with
|
18
|
+
# composition instead of inheritance.
|
19
|
+
|
20
|
+
require "gosu"
|
21
|
+
|
22
|
+
class TextField < Gosu::TextInput
|
23
|
+
FONT = Gosu::Font.new(20)
|
24
|
+
WIDTH = 350
|
25
|
+
LENGTH_LIMIT = 20
|
26
|
+
PADDING = 5
|
27
|
+
|
28
|
+
INACTIVE_COLOR = 0xcc_666666
|
29
|
+
ACTIVE_COLOR = 0xcc_ff6666
|
30
|
+
SELECTION_COLOR = 0xcc_0000ff
|
31
|
+
CARET_COLOR = 0xff_ffffff
|
32
|
+
|
33
|
+
attr_reader :x, :y
|
34
|
+
|
35
|
+
def initialize(window, x, y)
|
36
|
+
# It's important to call the inherited constructor.
|
37
|
+
super()
|
38
|
+
|
39
|
+
@window, @x, @y = window, x, y
|
40
|
+
|
41
|
+
# Start with a self-explanatory text in each field.
|
42
|
+
self.text = "Click to edit"
|
43
|
+
end
|
44
|
+
|
45
|
+
# In this example, we use the filter method to prevent the user from entering a text that exceeds
|
46
|
+
# the length limit. However, you can also use this to blacklist certain characters, etc.
|
47
|
+
def filter(new_text)
|
48
|
+
allowed_length = [LENGTH_LIMIT - text.length, 0].max
|
49
|
+
new_text[0, allowed_length]
|
50
|
+
end
|
51
|
+
|
52
|
+
def draw(z)
|
53
|
+
# Change the background colour if this is the currently selected text field.
|
54
|
+
if @window.text_input == self
|
55
|
+
color = ACTIVE_COLOR
|
56
|
+
else
|
57
|
+
color = INACTIVE_COLOR
|
58
|
+
end
|
59
|
+
Gosu.draw_rect x - PADDING, y - PADDING, WIDTH + 2 * PADDING, height + 2 * PADDING, color, z
|
60
|
+
|
61
|
+
# Calculate the position of the caret and the selection start.
|
62
|
+
pos_x = x + FONT.text_width(self.text[0...self.caret_pos])
|
63
|
+
sel_x = x + FONT.text_width(self.text[0...self.selection_start])
|
64
|
+
sel_w = pos_x - sel_x
|
65
|
+
|
66
|
+
# Draw the selection background, if any. (If not, sel_x and pos_x will be
|
67
|
+
# the same value, making this a no-op call.)
|
68
|
+
Gosu.draw_rect sel_x, y, sel_w, height, SELECTION_COLOR, z
|
69
|
+
|
70
|
+
# Draw the caret if this is the currently selected field.
|
71
|
+
if @window.text_input == self
|
72
|
+
Gosu.draw_line pos_x, y, CARET_COLOR, pos_x, y + height, CARET_COLOR, z
|
73
|
+
end
|
74
|
+
|
75
|
+
# Finally, draw the text itself!
|
76
|
+
FONT.draw_text self.text, x, y, z
|
77
|
+
end
|
78
|
+
|
79
|
+
def height
|
80
|
+
FONT.height
|
81
|
+
end
|
82
|
+
|
83
|
+
# Hit-test for selecting a text field with the mouse.
|
84
|
+
def under_mouse?
|
85
|
+
@window.mouse_x > x - PADDING and @window.mouse_x < x + WIDTH + PADDING and
|
86
|
+
@window.mouse_y > y - PADDING and @window.mouse_y < y + height + PADDING
|
87
|
+
end
|
88
|
+
|
89
|
+
# Tries to move the caret to the position specifies by mouse_x
|
90
|
+
def move_caret_to_mouse
|
91
|
+
# Test character by character
|
92
|
+
1.upto(self.text.length) do |i|
|
93
|
+
if @window.mouse_x < x + FONT.text_width(text[0...i])
|
94
|
+
self.caret_pos = self.selection_start = i - 1
|
95
|
+
return
|
96
|
+
end
|
97
|
+
end
|
98
|
+
# Default case: user must have clicked the right edge
|
99
|
+
self.caret_pos = self.selection_start = self.text.length
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class TextInputDemo < (Example rescue Gosu::Window)
|
104
|
+
def initialize
|
105
|
+
super 640, 480
|
106
|
+
self.caption = "Text Input Demo"
|
107
|
+
|
108
|
+
text =
|
109
|
+
"This demo explains (in the source code) how to use the Gosu::TextInput API by building a little TextField class around it.
|
110
|
+
|
111
|
+
Each text field can take up to 30 characters, and you can use Tab to switch between them.
|
112
|
+
|
113
|
+
As in every example, press <b>E</b> to look at the source code."
|
114
|
+
|
115
|
+
# Remove all leading spaces so the text is left-aligned
|
116
|
+
text.gsub! /^ +/, ""
|
117
|
+
|
118
|
+
@text = Gosu::Image.from_markup text, 20, width: 540
|
119
|
+
|
120
|
+
# Set up an array of three text fields.
|
121
|
+
@text_fields = Array.new(3) { |index| TextField.new(self, 50, 300 + index * 50) }
|
122
|
+
end
|
123
|
+
|
124
|
+
def needs_cursor?
|
125
|
+
true
|
126
|
+
end
|
127
|
+
|
128
|
+
def draw
|
129
|
+
@text.draw 50, 50, 0
|
130
|
+
@text_fields.each { |tf| tf.draw(0) }
|
131
|
+
end
|
132
|
+
|
133
|
+
def button_down(id)
|
134
|
+
if id == Gosu::KB_TAB
|
135
|
+
# Tab key will not be 'eaten' by text fields; use for switching through
|
136
|
+
# text fields.
|
137
|
+
index = @text_fields.index(self.text_input) || -1
|
138
|
+
self.text_input = @text_fields[(index + 1) % @text_fields.size]
|
139
|
+
elsif id == Gosu::KB_ESCAPE
|
140
|
+
# Escape key will not be 'eaten' by text fields; use for deselecting.
|
141
|
+
if self.text_input
|
142
|
+
self.text_input = nil
|
143
|
+
else
|
144
|
+
close
|
145
|
+
end
|
146
|
+
elsif id == Gosu::MS_LEFT
|
147
|
+
# Mouse click: Select text field based on mouse position.
|
148
|
+
self.text_input = @text_fields.find { |tf| tf.under_mouse? }
|
149
|
+
# Also move caret to clicked position
|
150
|
+
self.text_input.move_caret_to_mouse unless self.text_input.nil?
|
151
|
+
else
|
152
|
+
super
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
TextInputDemo.new.show if __FILE__ == $0
|
data/examples/tutorial.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'gosu'
|
1
|
+
require "gosu"
|
5
2
|
|
6
3
|
module ZOrder
|
7
4
|
BACKGROUND, STARS, PLAYER, UI = *0..3
|
@@ -9,45 +6,45 @@ end
|
|
9
6
|
|
10
7
|
class Player
|
11
8
|
attr_reader :score
|
12
|
-
|
9
|
+
|
13
10
|
def initialize
|
14
11
|
@image = Gosu::Image.new("media/starfighter.bmp")
|
15
12
|
@beep = Gosu::Sample.new("media/beep.wav")
|
16
13
|
@x = @y = @vel_x = @vel_y = @angle = 0.0
|
17
14
|
@score = 0
|
18
15
|
end
|
19
|
-
|
16
|
+
|
20
17
|
def warp(x, y)
|
21
18
|
@x, @y = x, y
|
22
19
|
end
|
23
|
-
|
20
|
+
|
24
21
|
def turn_left
|
25
22
|
@angle -= 4.5
|
26
23
|
end
|
27
|
-
|
24
|
+
|
28
25
|
def turn_right
|
29
26
|
@angle += 4.5
|
30
27
|
end
|
31
|
-
|
28
|
+
|
32
29
|
def accelerate
|
33
30
|
@vel_x += Gosu.offset_x(@angle, 0.5)
|
34
31
|
@vel_y += Gosu.offset_y(@angle, 0.5)
|
35
32
|
end
|
36
|
-
|
33
|
+
|
37
34
|
def move
|
38
35
|
@x += @vel_x
|
39
36
|
@y += @vel_y
|
40
37
|
@x %= 640
|
41
38
|
@y %= 480
|
42
|
-
|
39
|
+
|
43
40
|
@vel_x *= 0.95
|
44
41
|
@vel_y *= 0.95
|
45
42
|
end
|
46
|
-
|
43
|
+
|
47
44
|
def draw
|
48
45
|
@image.draw_rot(@x, @y, ZOrder::PLAYER, @angle)
|
49
46
|
end
|
50
|
-
|
47
|
+
|
51
48
|
def collect_stars(stars)
|
52
49
|
stars.reject! do |star|
|
53
50
|
if Gosu.distance(@x, @y, star.x, star.y) < 35
|
@@ -63,7 +60,7 @@ end
|
|
63
60
|
|
64
61
|
class Star
|
65
62
|
attr_reader :x, :y
|
66
|
-
|
63
|
+
|
67
64
|
def initialize(animation)
|
68
65
|
@animation = animation
|
69
66
|
@color = Gosu::Color::BLACK.dup
|
@@ -73,11 +70,11 @@ class Star
|
|
73
70
|
@x = rand * 640
|
74
71
|
@y = rand * 480
|
75
72
|
end
|
76
|
-
|
73
|
+
|
77
74
|
def draw
|
78
75
|
img = @animation[Gosu.milliseconds / 100 % @animation.size]
|
79
76
|
img.draw(@x - img.width / 2.0, @y - img.height / 2.0,
|
80
|
-
|
77
|
+
ZOrder::STARS, 1, 1, @color, :add)
|
81
78
|
end
|
82
79
|
end
|
83
80
|
|
@@ -85,18 +82,18 @@ class Tutorial < (Example rescue Gosu::Window)
|
|
85
82
|
def initialize
|
86
83
|
super 640, 480
|
87
84
|
self.caption = "Tutorial Game"
|
88
|
-
|
89
|
-
@background_image = Gosu::Image.new("media/space.png", :
|
90
|
-
|
85
|
+
|
86
|
+
@background_image = Gosu::Image.new("media/space.png", tileable: true)
|
87
|
+
|
91
88
|
@player = Player.new
|
92
89
|
@player.warp(320, 240)
|
93
|
-
|
90
|
+
|
94
91
|
@star_anim = Gosu::Image::load_tiles("media/star.png", 25, 25)
|
95
92
|
@stars = Array.new
|
96
|
-
|
93
|
+
|
97
94
|
@font = Gosu::Font.new(20)
|
98
95
|
end
|
99
|
-
|
96
|
+
|
100
97
|
def update
|
101
98
|
if Gosu.button_down? Gosu::KB_LEFT or Gosu.button_down? Gosu::GP_LEFT
|
102
99
|
@player.turn_left
|
@@ -109,19 +106,19 @@ class Tutorial < (Example rescue Gosu::Window)
|
|
109
106
|
end
|
110
107
|
@player.move
|
111
108
|
@player.collect_stars(@stars)
|
112
|
-
|
109
|
+
|
113
110
|
if rand(100) < 4 and @stars.size < 25
|
114
111
|
@stars.push(Star.new(@star_anim))
|
115
112
|
end
|
116
113
|
end
|
117
|
-
|
114
|
+
|
118
115
|
def draw
|
119
116
|
@background_image.draw(0, 0, ZOrder::BACKGROUND)
|
120
117
|
@player.draw
|
121
118
|
@stars.each { |star| star.draw }
|
122
|
-
@font.
|
119
|
+
@font.draw_text("Score: #{@player.score}", 10, 10, ZOrder::UI, 1.0, 1.0, Gosu::Color::YELLOW)
|
123
120
|
end
|
124
|
-
|
121
|
+
|
125
122
|
def button_down(id)
|
126
123
|
if id == Gosu::KB_ESCAPE
|
127
124
|
close
|
data/examples/welcome.rb
CHANGED
@@ -1,55 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'gosu'
|
1
|
+
require "gosu"
|
5
2
|
|
6
3
|
WIDTH, HEIGHT = 640, 480
|
7
4
|
|
8
5
|
class Welcome < (Example rescue Gosu::Window)
|
9
6
|
PADDING = 20
|
10
|
-
|
7
|
+
|
11
8
|
def initialize
|
12
9
|
super WIDTH, HEIGHT
|
13
|
-
|
10
|
+
|
14
11
|
self.caption = "Welcome!"
|
15
|
-
|
12
|
+
|
16
13
|
text =
|
17
14
|
"<b>Welcome to the Gosu Example Box!</b>
|
18
|
-
|
15
|
+
|
19
16
|
This little tool lets you launch any of Gosu’s example games from the list on the right hand side of the screen.
|
20
|
-
|
17
|
+
|
21
18
|
Every example can be run both from this tool <i>and</i> from the terminal/command line as a stand-alone Ruby script.
|
22
|
-
|
19
|
+
|
23
20
|
Keyboard shortcuts:
|
24
|
-
|
21
|
+
|
25
22
|
• To see the source code of an example or feature demo, press <b>E</b>.
|
26
23
|
• To open the ‘examples’ folder, press <b>O</b>.
|
27
24
|
• To quit this tool, press <b>Esc</b>.
|
28
25
|
• To toggle fullscreen mode, press <b>Alt+Enter</b> (Windows, Linux) or <b>cmd+F</b> (macOS).
|
29
|
-
|
30
|
-
Why not take a look at the code for this example right now? Simply press <b>
|
31
|
-
|
26
|
+
|
27
|
+
Why not take a look at the code for this example right now? Simply press <b>E</b>."
|
28
|
+
|
32
29
|
# Remove all leading spaces so the text is left-aligned
|
33
|
-
text.gsub! /^ +/,
|
34
|
-
|
35
|
-
@text = Gosu::Image.
|
36
|
-
|
30
|
+
text.gsub! /^ +/, ""
|
31
|
+
|
32
|
+
@text = Gosu::Image.from_markup text, 20, width: WIDTH - 2 * PADDING
|
33
|
+
|
37
34
|
@background = Gosu::Image.new "media/space.png"
|
38
35
|
end
|
39
|
-
|
36
|
+
|
40
37
|
def draw
|
41
38
|
draw_rotating_star_backgrounds
|
42
|
-
|
39
|
+
|
43
40
|
@text.draw PADDING, PADDING, 0
|
44
41
|
end
|
45
|
-
|
42
|
+
|
46
43
|
def draw_rotating_star_backgrounds
|
47
44
|
# Disregard the math in this method, it doesn't look as good as I thought it
|
48
45
|
# would. =(
|
49
|
-
|
46
|
+
|
50
47
|
angle = Gosu.milliseconds / 50.0
|
51
48
|
scale = (Gosu.milliseconds % 1000) / 1000.0
|
52
|
-
|
49
|
+
|
53
50
|
[1, 0].each do |extra_scale|
|
54
51
|
@background.draw_rot WIDTH * 0.5, HEIGHT * 0.75, 0, angle, 0.5, 0.5,
|
55
52
|
scale + extra_scale, scale + extra_scale
|
@@ -1,57 +1,78 @@
|
|
1
1
|
class Example
|
2
2
|
attr_accessor :caption
|
3
3
|
attr_reader :width, :height
|
4
|
-
|
4
|
+
attr_writer :parent_window
|
5
|
+
|
5
6
|
def initialize(width, height, *options)
|
6
7
|
@width, @height = width, height
|
7
8
|
end
|
8
|
-
|
9
|
+
|
9
10
|
def draw
|
10
11
|
end
|
11
|
-
|
12
|
+
|
12
13
|
def update
|
13
14
|
end
|
14
|
-
|
15
|
+
|
15
16
|
def button_down(id)
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
def button_up(id)
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
def close
|
22
23
|
# no-op, examples cannot close the containing window.
|
23
24
|
end
|
24
25
|
|
26
|
+
def mouse_x
|
27
|
+
@parent_window && @parent_window.mouse_x
|
28
|
+
end
|
29
|
+
|
30
|
+
def mouse_y
|
31
|
+
@parent_window && @parent_window.mouse_y
|
32
|
+
end
|
33
|
+
|
34
|
+
def text_input
|
35
|
+
@parent_window && @parent_window.text_input
|
36
|
+
end
|
37
|
+
|
38
|
+
def text_input=(text_input)
|
39
|
+
@parent_window && @parent_window.text_input = text_input
|
40
|
+
end
|
41
|
+
|
25
42
|
def self.current_source_file
|
26
43
|
@current_source_file
|
27
44
|
end
|
28
|
-
|
45
|
+
|
29
46
|
def self.current_source_file=(current_source_file)
|
30
47
|
@current_source_file = current_source_file
|
31
48
|
end
|
32
|
-
|
49
|
+
|
33
50
|
def self.inherited(subclass)
|
34
51
|
@@examples ||= {}
|
35
52
|
@@examples[subclass] = self.current_source_file
|
36
53
|
end
|
37
|
-
|
54
|
+
|
38
55
|
def self.examples
|
39
56
|
@@examples.keys
|
40
57
|
end
|
41
|
-
|
58
|
+
|
42
59
|
def self.source_file
|
43
60
|
@@examples[self]
|
44
61
|
end
|
45
|
-
|
62
|
+
|
63
|
+
def self.initial_example
|
64
|
+
@@examples.keys.find { |cls| cls.name.end_with? "::Welcome" }
|
65
|
+
end
|
66
|
+
|
46
67
|
def self.load_examples(pattern)
|
47
|
-
Dir.glob(pattern) do |file|
|
68
|
+
Dir.glob(pattern) do |file|
|
48
69
|
begin
|
49
70
|
# Remember which file we are loading.
|
50
71
|
Example.current_source_file = File.expand_path(file)
|
51
72
|
|
52
73
|
# Load the example in a sandbox module (second parameter to load()). This way, examples can
|
53
74
|
# define classes and constants with the same names, and they will not collide.
|
54
|
-
#
|
75
|
+
#
|
55
76
|
# load() does not let us refer to the anonymous module it creates, but we can enumerate all
|
56
77
|
# loaded examples using Example.examples thanks to the "inherited" callback above.
|
57
78
|
load file, true
|
@@ -2,57 +2,57 @@ class Sidebar
|
|
2
2
|
WIDTH = 300
|
3
3
|
HEIGHT = 600
|
4
4
|
FONT = Gosu::Font.new(20)
|
5
|
-
HEADER = Gosu::Image.new("media/header@2x.psd", :
|
6
|
-
|
5
|
+
HEADER = Gosu::Image.new("media/header@2x.psd", tileable: true)
|
6
|
+
|
7
7
|
class Button
|
8
8
|
HEIGHT = 25
|
9
9
|
SPACING = 5
|
10
10
|
TOP_Y = HEADER.height / 2 + 15
|
11
|
-
|
11
|
+
|
12
12
|
attr_reader :filename
|
13
|
-
|
13
|
+
|
14
14
|
def initialize(top, filename, &handler)
|
15
15
|
@top, @filename, @handler = top, filename, handler
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def draw(is_current)
|
19
19
|
text_color = Gosu::Color::BLACK
|
20
|
-
|
20
|
+
|
21
21
|
if is_current
|
22
|
-
Gosu.draw_rect 0, @top, Sidebar::WIDTH, HEIGHT, 0xff_1565e5
|
22
|
+
Gosu.draw_rect 0, @top, Sidebar::WIDTH, HEIGHT, 0xff_1565e5
|
23
23
|
text_color = Gosu::Color::WHITE
|
24
24
|
end
|
25
|
-
|
26
|
-
FONT.
|
25
|
+
|
26
|
+
FONT.draw_text File.basename(@filename), 13, @top + 2, 0, 1, 1, text_color
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def click
|
30
30
|
@handler.call
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def initialize
|
35
35
|
y = Button::TOP_Y - Button::HEIGHT - Button::SPACING
|
36
|
-
|
36
|
+
|
37
37
|
@buttons = Example.examples.map do |example|
|
38
38
|
y += (Button::HEIGHT + Button::SPACING)
|
39
|
-
|
39
|
+
|
40
40
|
Button.new(y, example.source_file) do
|
41
41
|
yield(example)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def draw(current_filename)
|
47
47
|
Gosu.draw_rect 0, 0, WIDTH, HEIGHT, Gosu::Color::WHITE
|
48
48
|
HEADER.draw 0, 0, 0, 0.5, 0.5
|
49
|
-
|
49
|
+
|
50
50
|
@buttons.each do |button|
|
51
51
|
is_current = (button.filename == current_filename)
|
52
52
|
button.draw(is_current)
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def click(x, y)
|
57
57
|
index = (y - Button::TOP_Y).floor / (Button::HEIGHT + Button::SPACING)
|
58
58
|
@buttons[index].click if @buttons[index]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosu-examples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Raschke
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 1.0.0
|
27
27
|
description: The `gosu-examples` tool provides an easy way to run and inspect example
|
28
28
|
games written for the Gosu game development library.
|
29
29
|
email: julian@raschke.de
|
@@ -38,29 +38,6 @@ files:
|
|
38
38
|
- examples/chipmunk_and_rmagick.rb
|
39
39
|
- examples/chipmunk_integration.rb
|
40
40
|
- examples/cptn_ruby.rb
|
41
|
-
- examples/media/BrokenPNG.png
|
42
|
-
- examples/media/Cursor.png
|
43
|
-
- examples/media/JingleBells.mp3
|
44
|
-
- examples/media/JingleBells.ogg
|
45
|
-
- examples/media/Loop.wav
|
46
|
-
- examples/media/Sample.wav
|
47
|
-
- examples/media/SquareTexture.png
|
48
|
-
- examples/media/Wallpaper.png
|
49
|
-
- examples/media/WallpaperXXL.png
|
50
|
-
- examples/media/WhiteAlpha.png
|
51
|
-
- examples/media/audio_formats/aiff_32bit_float.aiff
|
52
|
-
- examples/media/audio_formats/au_16bit_pcm.au
|
53
|
-
- examples/media/audio_formats/caf_be_16bit_44khz.caf
|
54
|
-
- examples/media/audio_formats/caf_le_16bit_44khz.caf
|
55
|
-
- examples/media/audio_formats/caf_le_8bit_44khz.caf
|
56
|
-
- examples/media/audio_formats/general_midi.mid
|
57
|
-
- examples/media/audio_formats/impulse_tracker.it
|
58
|
-
- examples/media/audio_formats/mp3_128k_stereo.mp3
|
59
|
-
- examples/media/audio_formats/mp3_avg_96kbit_jointstereo.mp3
|
60
|
-
- examples/media/audio_formats/ogg_vorbis.ogg
|
61
|
-
- examples/media/audio_formats/wav_16bit_pcm.wav
|
62
|
-
- examples/media/audio_formats/wav_32bit_pcm.wav
|
63
|
-
- examples/media/audio_formats/wav_4bit_ms_adpcm.wav
|
64
41
|
- examples/media/beep.wav
|
65
42
|
- examples/media/cptn_ruby.png
|
66
43
|
- examples/media/cptn_ruby_map.txt
|
@@ -68,8 +45,6 @@ files:
|
|
68
45
|
- examples/media/explosion.wav
|
69
46
|
- examples/media/gem.png
|
70
47
|
- examples/media/header@2x.psd
|
71
|
-
- examples/media/image_formats/test.jpg
|
72
|
-
- examples/media/image_formats/test.psd
|
73
48
|
- examples/media/landscape.svg
|
74
49
|
- examples/media/large_star.png
|
75
50
|
- examples/media/smoke.png
|
@@ -78,9 +53,9 @@ files:
|
|
78
53
|
- examples/media/star.png
|
79
54
|
- examples/media/starfighter.bmp
|
80
55
|
- examples/media/tileset.png
|
81
|
-
- examples/media/vera.ttf
|
82
56
|
- examples/opengl_integration.rb
|
83
57
|
- examples/rmagick_integration.rb
|
58
|
+
- examples/text_input.rb
|
84
59
|
- examples/tutorial.rb
|
85
60
|
- examples/welcome.rb
|
86
61
|
- lib/gosu-examples/example.rb
|
@@ -88,7 +63,7 @@ files:
|
|
88
63
|
homepage: http://www.libgosu.org/
|
89
64
|
licenses: []
|
90
65
|
metadata: {}
|
91
|
-
post_install_message:
|
66
|
+
post_install_message:
|
92
67
|
rdoc_options: []
|
93
68
|
require_paths:
|
94
69
|
- lib
|
@@ -96,16 +71,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
71
|
requirements:
|
97
72
|
- - ">="
|
98
73
|
- !ruby/object:Gem::Version
|
99
|
-
version:
|
74
|
+
version: '0'
|
100
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
76
|
requirements:
|
102
77
|
- - ">="
|
103
78
|
- !ruby/object:Gem::Version
|
104
79
|
version: '0'
|
105
80
|
requirements: []
|
106
|
-
|
107
|
-
|
108
|
-
signing_key:
|
81
|
+
rubygems_version: 3.4.19
|
82
|
+
signing_key:
|
109
83
|
specification_version: 4
|
110
84
|
summary: Ruby examples for the Gosu library
|
111
85
|
test_files: []
|
Binary file
|
data/examples/media/Cursor.png
DELETED
Binary file
|
Binary file
|
Binary file
|
data/examples/media/Loop.wav
DELETED
Binary file
|
data/examples/media/Sample.wav
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|