chingu 0.8.1 → 0.9rc1
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.
- data/README.rdoc +28 -0
- data/Rakefile +1 -1
- data/benchmarks/benchmark_ping_localhost.rb +63 -0
- data/chingu.gemspec +24 -6
- data/examples/example12_trait_timer.rb +5 -1
- data/examples/example28_networking.rb +75 -0
- data/examples/example29_asynchronous.rb +65 -0
- data/lib/chingu.rb +3 -1
- data/lib/chingu/async/basic_task.rb +46 -0
- data/lib/chingu/async/task_builder.rb +71 -0
- data/lib/chingu/async/task_list.rb +67 -0
- data/lib/chingu/async_tasks/call.rb +48 -0
- data/lib/chingu/async_tasks/exec.rb +48 -0
- data/lib/chingu/async_tasks/move.rb +45 -0
- data/lib/chingu/async_tasks/parallel.rb +63 -0
- data/lib/chingu/async_tasks/tween.rb +73 -0
- data/lib/chingu/async_tasks/wait.rb +54 -0
- data/lib/chingu/classic_game_object.rb +1 -1
- data/lib/chingu/core_ext/range.rb +13 -0
- data/lib/chingu/game_states/enter_name.rb +21 -11
- data/lib/chingu/game_states/network_client.rb +205 -0
- data/lib/chingu/game_states/network_server.rb +262 -0
- data/lib/chingu/simple_menu.rb +10 -2
- data/lib/chingu/traits/asynchronous.rb +84 -0
- data/lib/chingu/traits/simple_sprite.rb +1 -1
- data/lib/chingu/traits/sprite.rb +1 -1
- data/lib/chingu/window.rb +1 -1
- metadata +29 -10
data/lib/chingu/simple_menu.rb
CHANGED
@@ -21,7 +21,11 @@
|
|
21
21
|
|
22
22
|
module Chingu
|
23
23
|
#
|
24
|
-
#
|
24
|
+
# When you want a quick 'n dirty menu, SimpleMenu might help.
|
25
|
+
# Basic usage:
|
26
|
+
# SimpleMenu.create(:menu_items => {"StartGame" => PlayState, "Edit" => :exit})
|
27
|
+
#
|
28
|
+
# It will catch keys :up, :down, :return and :space and navigate through the menu
|
25
29
|
#
|
26
30
|
class SimpleMenu < BasicGameObject
|
27
31
|
include Chingu::Helpers::InputClient
|
@@ -30,7 +34,8 @@ module Chingu
|
|
30
34
|
def initialize(options = {})
|
31
35
|
super
|
32
36
|
|
33
|
-
@
|
37
|
+
# @font_size = options.delete(:font_size) || 30
|
38
|
+
@menu_items = options.delete(:menu_items)
|
34
39
|
@x = options.delete(:x) || $window.width/2
|
35
40
|
@y = options.delete(:y) || 100
|
36
41
|
@spacing = options.delete(:spacing) || 100
|
@@ -64,6 +69,9 @@ module Chingu
|
|
64
69
|
self.input = {:up => lambda{step(-1)}, :down => lambda{step(1)}, [:return, :space] => :select}
|
65
70
|
end
|
66
71
|
|
72
|
+
#
|
73
|
+
# Moves selection within the menu. Can be called with negative or positive values. -1 and 1 makes most sense.
|
74
|
+
#
|
67
75
|
def step(value)
|
68
76
|
selected.options[:on_deselect].call(selected)
|
69
77
|
@selected += value
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Chingu -- OpenGL accelerated 2D game framework for Ruby
|
4
|
+
# Copyright (C) 2009 ippa / ippa@rubylicio.us
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
#
|
20
|
+
#++
|
21
|
+
|
22
|
+
module Chingu
|
23
|
+
module Traits
|
24
|
+
|
25
|
+
#
|
26
|
+
# A chingu trait providing an asynchronous tasks queue
|
27
|
+
#
|
28
|
+
# For example:
|
29
|
+
# class Robot < GameObject
|
30
|
+
# traits :asynchronous
|
31
|
+
#
|
32
|
+
# # robot stuff
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# # later, controlling your robot...
|
36
|
+
# robot.async do |q|
|
37
|
+
# q.tween(5000, :x => 1024, :y => 64)
|
38
|
+
# q.call :explode
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# Will move the robot asynchronously from its current location to
|
42
|
+
# (1024, 64), then blow it up. The +async+ method returns immediately
|
43
|
+
# after adding tasks to the queue.
|
44
|
+
#
|
45
|
+
# The first task on the queue is processed each tick during the
|
46
|
+
# update phase, then removed from the queue when it is deemed finished.
|
47
|
+
# What constitutes "finished" is determined by the particular subclass of
|
48
|
+
# +BasicTask+.
|
49
|
+
#
|
50
|
+
|
51
|
+
module Asynchronous
|
52
|
+
|
53
|
+
attr_reader :tasks
|
54
|
+
|
55
|
+
#
|
56
|
+
# Setup
|
57
|
+
#
|
58
|
+
def setup_trait(options)
|
59
|
+
@tasks = Chingu::Async::TaskList.new
|
60
|
+
super
|
61
|
+
end
|
62
|
+
|
63
|
+
def update_trait
|
64
|
+
@tasks.update self
|
65
|
+
super
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Add a set of tasks to the task queue to be executed
|
70
|
+
# asynchronously. If no block is given, returns the TaskBuilder that
|
71
|
+
# would have been passed to the block.
|
72
|
+
#
|
73
|
+
def async
|
74
|
+
builder = Chingu::Async::TaskBuilder.new(@tasks)
|
75
|
+
if block_given?
|
76
|
+
yield builder
|
77
|
+
else
|
78
|
+
builder
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/chingu/traits/sprite.rb
CHANGED
data/lib/chingu/window.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chingu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
|
9
|
-
version: 0.8.1
|
7
|
+
- 9rc1
|
8
|
+
version: 0.9rc1
|
10
9
|
platform: ruby
|
11
10
|
authors:
|
12
11
|
- ippa
|
@@ -14,7 +13,7 @@ autorequire:
|
|
14
13
|
bindir: bin
|
15
14
|
cert_chain: []
|
16
15
|
|
17
|
-
date: 2011-
|
16
|
+
date: 2011-02-20 00:00:00 +01:00
|
18
17
|
default_executable:
|
19
18
|
dependencies:
|
20
19
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +27,8 @@ dependencies:
|
|
28
27
|
segments:
|
29
28
|
- 0
|
30
29
|
- 7
|
31
|
-
-
|
32
|
-
version: 0.7.
|
30
|
+
- 27
|
31
|
+
version: 0.7.27
|
33
32
|
type: :runtime
|
34
33
|
version_requirements: *id001
|
35
34
|
- !ruby/object:Gem::Dependency
|
@@ -122,6 +121,7 @@ files:
|
|
122
121
|
- benchmarks/benchmark4.rb
|
123
122
|
- benchmarks/benchmark5.rb
|
124
123
|
- benchmarks/benchmark6.rb
|
124
|
+
- benchmarks/benchmark_ping_localhost.rb
|
125
125
|
- benchmarks/game_object_list_benchmark.rb
|
126
126
|
- benchmarks/game_objects_benchmark.rb
|
127
127
|
- benchmarks/lookup_benchmark.rb
|
@@ -152,6 +152,8 @@ files:
|
|
152
152
|
- examples/example25_fibers_state_machine.rb
|
153
153
|
- examples/example26_splash_screen.rb
|
154
154
|
- examples/example27_console.rb
|
155
|
+
- examples/example28_networking.rb
|
156
|
+
- examples/example29_asynchronous.rb
|
155
157
|
- examples/example2_gamestate_basics.rb
|
156
158
|
- examples/example3_parallax.rb
|
157
159
|
- examples/example4_gamestates.rb
|
@@ -210,10 +212,20 @@ files:
|
|
210
212
|
- lib/chingu.rb
|
211
213
|
- lib/chingu/animation.rb
|
212
214
|
- lib/chingu/assets.rb
|
215
|
+
- lib/chingu/async/basic_task.rb
|
216
|
+
- lib/chingu/async/task_builder.rb
|
217
|
+
- lib/chingu/async/task_list.rb
|
218
|
+
- lib/chingu/async_tasks/call.rb
|
219
|
+
- lib/chingu/async_tasks/exec.rb
|
220
|
+
- lib/chingu/async_tasks/move.rb
|
221
|
+
- lib/chingu/async_tasks/parallel.rb
|
222
|
+
- lib/chingu/async_tasks/tween.rb
|
223
|
+
- lib/chingu/async_tasks/wait.rb
|
213
224
|
- lib/chingu/basic_game_object.rb
|
214
225
|
- lib/chingu/classic_game_object.rb
|
215
226
|
- lib/chingu/console.rb
|
216
227
|
- lib/chingu/core_ext/array.rb
|
228
|
+
- lib/chingu/core_ext/range.rb
|
217
229
|
- lib/chingu/fpscounter.rb
|
218
230
|
- lib/chingu/game_object.rb
|
219
231
|
- lib/chingu/game_object_list.rb
|
@@ -224,6 +236,8 @@ files:
|
|
224
236
|
- lib/chingu/game_states/edit.rb
|
225
237
|
- lib/chingu/game_states/enter_name.rb
|
226
238
|
- lib/chingu/game_states/fade_to.rb
|
239
|
+
- lib/chingu/game_states/network_client.rb
|
240
|
+
- lib/chingu/game_states/network_server.rb
|
227
241
|
- lib/chingu/game_states/pause.rb
|
228
242
|
- lib/chingu/game_states/popup.rb
|
229
243
|
- lib/chingu/gosu_ext/image.rb
|
@@ -247,6 +261,7 @@ files:
|
|
247
261
|
- lib/chingu/simple_menu.rb
|
248
262
|
- lib/chingu/text.rb
|
249
263
|
- lib/chingu/traits/animation.rb
|
264
|
+
- lib/chingu/traits/asynchronous.rb
|
250
265
|
- lib/chingu/traits/bounding_box.rb
|
251
266
|
- lib/chingu/traits/bounding_circle.rb
|
252
267
|
- lib/chingu/traits/collision_detection.rb
|
@@ -300,11 +315,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
300
315
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
301
316
|
none: false
|
302
317
|
requirements:
|
303
|
-
- - "
|
318
|
+
- - ">"
|
304
319
|
- !ruby/object:Gem::Version
|
305
320
|
segments:
|
306
|
-
-
|
307
|
-
|
321
|
+
- 1
|
322
|
+
- 3
|
323
|
+
- 1
|
324
|
+
version: 1.3.1
|
308
325
|
requirements: []
|
309
326
|
|
310
327
|
rubyforge_project: chingu
|
@@ -332,6 +349,8 @@ test_files:
|
|
332
349
|
- examples/example25_fibers_state_machine.rb
|
333
350
|
- examples/example26_splash_screen.rb
|
334
351
|
- examples/example27_console.rb
|
352
|
+
- examples/example28_networking.rb
|
353
|
+
- examples/example29_asynchronous.rb
|
335
354
|
- examples/example2_gamestate_basics.rb
|
336
355
|
- examples/example3_parallax.rb
|
337
356
|
- examples/example4_gamestates.rb
|