ruby_armor 0.0.2alpha → 0.0.3alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +36 -0
- data/config/gui/schema.yml +3 -3
- data/lib/ruby_armor/floating_text.rb +2 -2
- data/lib/ruby_armor/states/choose_profile.rb +56 -0
- data/lib/ruby_armor/states/play.rb +192 -63
- data/lib/ruby_armor/version.rb +1 -1
- data/lib/ruby_armor/window.rb +2 -2
- data/lib/ruby_armor.rb +2 -0
- data/media/fonts/Licence.txt +7 -0
- data/media/fonts/ProggyCleanSZ.ttf +0 -0
- data/media/images/tiles.png +0 -0
- metadata +14 -13
- data/bin/ruby_armour +0 -3
- data/media/fonts/MONACO.TTF +0 -0
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Ruby Armor
|
2
|
+
==========
|
3
|
+
|
4
|
+
A graphical front-end for [RubyWarrior](https://github.com/ryanb/ruby-warrior). Make sure your Ruby Warrior is wearing Ruby Armor!
|
5
|
+
|
6
|
+
* Author: Spooner / Bil Bas (bil.bagpuss@gmail.com)
|
7
|
+
* License: MIT
|
8
|
+
* Website: http://spooner.github.com/games/ruby_armor/
|
9
|
+
* Project: https://github.com/Spooner/ruby_armor
|
10
|
+
|
11
|
+
Installation
|
12
|
+
------------
|
13
|
+
|
14
|
+
gem install ruby_armor --pre
|
15
|
+
|
16
|
+
Play
|
17
|
+
----
|
18
|
+
|
19
|
+
ruby_armor
|
20
|
+
|
21
|
+
Credits
|
22
|
+
-------
|
23
|
+
|
24
|
+
* A myriad thanks to ryanb for making such an inspiring game as RubyWarrior!
|
25
|
+
* Thanks to jlnr and RomyRomy for play-testing and suggestions.
|
26
|
+
|
27
|
+
|
28
|
+
Third party assets used
|
29
|
+
-----------------------
|
30
|
+
|
31
|
+
* Font: [ProggyCleanSZ.ttf](http://proggyfonts.com)
|
32
|
+
* Sprites made by Oryx from his [LOFI Sprite Pack](http://cgbarrett.squarespace.com/sprites/). [![CC BY-NC-ND](http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png)](http://creativecommons.org/licenses/by-nc-nd/3.0/)
|
33
|
+
* [Gosu](http://libgosu.org/) game development library
|
34
|
+
* [Chingu](http://ippa.se/chingu) game library (extending Gosu)
|
35
|
+
* [Fidgit](https://github.com/Spooner/fidgit) gui library (extending Chingu)
|
36
|
+
* [RubyWarrior](https://github.com/ryanb/ruby-warrior) gem
|
data/config/gui/schema.yml
CHANGED
@@ -13,8 +13,8 @@
|
|
13
13
|
|
14
14
|
:elements:
|
15
15
|
:Element:
|
16
|
-
:font_name:
|
17
|
-
:font_height:
|
16
|
+
:font_name: ProggyCleanSZ.ttf
|
17
|
+
:font_height: 16
|
18
18
|
:color: ?text
|
19
19
|
:background_color: ?none
|
20
20
|
:border_color: ?light_background
|
@@ -58,7 +58,7 @@
|
|
58
58
|
:TextArea:
|
59
59
|
:color: ?text
|
60
60
|
:background_color: ?dark_background
|
61
|
-
:font_height:
|
61
|
+
:font_height: 14
|
62
62
|
|
63
63
|
:ScrollBar: # < Composite
|
64
64
|
:rail_width: 14
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module RubyArmor
|
2
2
|
class FloatingText < GameObject
|
3
|
-
FONT_SIZE =
|
3
|
+
FONT_SIZE = 20
|
4
4
|
|
5
5
|
def initialize(text, options = {})
|
6
6
|
super(options)
|
7
7
|
|
8
8
|
@final_y = y - 60
|
9
9
|
@text = text
|
10
|
-
@font = Font["
|
10
|
+
@font = Font["ProggyCleanSZ.ttf", FONT_SIZE]
|
11
11
|
end
|
12
12
|
|
13
13
|
def update
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module RubyArmor
|
2
|
+
class ChooseProfile < Fidgit::GuiState
|
3
|
+
def setup
|
4
|
+
super
|
5
|
+
|
6
|
+
# Create the game.
|
7
|
+
@game = RubyWarrior::Game.new
|
8
|
+
|
9
|
+
vertical align_h: :center, spacing: 50 do
|
10
|
+
label "RubyArmor", align: :center, font_height: 120, padding_top: 50
|
11
|
+
|
12
|
+
button_options = { width: 400, align: :center, justify: :center }
|
13
|
+
|
14
|
+
# Use existing profile.
|
15
|
+
vertical padding: 0, align_h: :center do
|
16
|
+
@game.profiles.each do |profile|
|
17
|
+
title = "#{profile.warrior_name.ljust(20)} #{profile.tower.name.rjust(12)}:#{profile.level_number} #{profile.score.to_s.rjust(5)}"
|
18
|
+
tip = "Play as #{profile.warrior_name} - #{profile.tower.name} - level #{profile.level_number} - score #{profile.score}"
|
19
|
+
# Can be disabled because of a bug in RubyWarrior paths.
|
20
|
+
button title, button_options.merge(tip: tip, enabled: File.directory?(profile.tower_path)) do
|
21
|
+
play profile
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Option to create a new profile.
|
27
|
+
horizontal align: :center, padding: 0 do
|
28
|
+
@new_name = text_area width: 300, max_height: 60, font_height: 24 do |_, text|
|
29
|
+
duplicate = @game.profiles.any? {|p| p.warrior_name.downcase == text.downcase }
|
30
|
+
@new_profile_button.enabled = !(text.empty? or duplicate)
|
31
|
+
end
|
32
|
+
|
33
|
+
@new_profile_button = button "New", button_options.merge(width: 90, tip: "Create a new profile") do
|
34
|
+
play new_profile(@new_name.text)
|
35
|
+
end
|
36
|
+
|
37
|
+
new_name = File.basename File.expand_path("~")
|
38
|
+
new_name = "Player" if new_name.empty?
|
39
|
+
@new_name.text = new_name
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def play(profile)
|
45
|
+
@game.instance_variable_set :@profile, profile
|
46
|
+
push_game_state Play.new(@game)
|
47
|
+
end
|
48
|
+
|
49
|
+
def new_profile(name)
|
50
|
+
new_profile = RubyWarrior::Profile.new
|
51
|
+
new_profile.tower_path = @game.towers[0].path
|
52
|
+
new_profile.warrior_name = name
|
53
|
+
new_profile
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -2,27 +2,55 @@ module RubyArmor
|
|
2
2
|
class Play < Fidgit::GuiState
|
3
3
|
FLOOR_COLOR = Color.rgba(255, 255, 255, 125)
|
4
4
|
|
5
|
+
TILE_WIDTH, TILE_HEIGHT = 8, 12
|
6
|
+
SPRITE_WIDTH, SPRITE_HEIGHT = 8, 8
|
7
|
+
SPRITE_OFFSET_X, SPRITE_OFFSET_Y = 64, 64
|
8
|
+
SPRITE_SCALE = 5
|
9
|
+
|
10
|
+
ENEMY_TYPES = [
|
11
|
+
RubyWarrior::Units::Wizard,
|
12
|
+
RubyWarrior::Units::ThickSludge,
|
13
|
+
RubyWarrior::Units::Sludge,
|
14
|
+
RubyWarrior::Units::Archer,
|
15
|
+
]
|
16
|
+
WARRIOR_TYPES = [
|
17
|
+
RubyWarrior::Units::Warrior,
|
18
|
+
RubyWarrior::Units::Golem,
|
19
|
+
]
|
20
|
+
FRIEND_TYPES = [
|
21
|
+
RubyWarrior::Units::Captive,
|
22
|
+
]
|
23
|
+
|
5
24
|
trait :timer
|
6
25
|
|
26
|
+
def initialize(game)
|
27
|
+
@game = game
|
28
|
+
super()
|
29
|
+
end
|
30
|
+
|
7
31
|
def setup
|
8
32
|
super
|
9
33
|
|
10
34
|
RubyWarrior::UI.proxy = self
|
11
35
|
|
12
|
-
@tiles = SpriteSheet.new "tiles.png",
|
13
|
-
@sprites = SpriteSheet.new "characters.png",
|
14
|
-
@max_turns =
|
36
|
+
@tiles = SpriteSheet.new "tiles.png", TILE_WIDTH, TILE_HEIGHT, 8
|
37
|
+
@sprites = SpriteSheet.new "characters.png", SPRITE_WIDTH, SPRITE_HEIGHT, 4
|
38
|
+
@max_turns = 100 # Just to recognise a stalemate ;)
|
15
39
|
|
16
40
|
vertical spacing: 0, padding: 10 do
|
17
41
|
horizontal padding: 0, height: $window.height * 0.5, width: 780 do
|
42
|
+
# Space for the game graphics.
|
18
43
|
vertical padding: 0, height: $window.height * 0.5, align_h: :fill
|
44
|
+
|
19
45
|
vertical padding: 0, height: $window.height * 0.5, width: 100 do
|
46
|
+
# Labels at top-right.
|
20
47
|
@tower_label = label ""
|
21
48
|
@level_label = label "Level:"
|
22
49
|
@turn_label = label "Turn:"
|
23
50
|
@health_label = label "Health:"
|
24
51
|
|
25
|
-
|
52
|
+
# Buttons underneath them.
|
53
|
+
button_options = { :width => 70, :justify => :center, shortcut: :auto, border_thickness: 0, }
|
26
54
|
@start_button = button "Start", button_options do
|
27
55
|
start_level
|
28
56
|
end
|
@@ -32,31 +60,69 @@ module RubyArmor
|
|
32
60
|
end
|
33
61
|
|
34
62
|
@hint_button = button "Hint", button_options do
|
35
|
-
message level.tip
|
63
|
+
message replace_syntax(level.tip)
|
36
64
|
end
|
37
65
|
|
38
66
|
@continue_button = button "Continue", button_options do
|
39
67
|
@game.prepare_next_level
|
40
68
|
prepare_level
|
41
69
|
end
|
70
|
+
|
71
|
+
# Choose turn-duration with a slider.
|
72
|
+
horizontal padding: 0, spacing: 0 do
|
73
|
+
@turn_duration_label = label "", font_height: 12
|
74
|
+
@turn_duration_slider = slider width: 55, range: 0..1000, tip: "Turn duration (ms)" do |_, value|
|
75
|
+
@turn_duration = value * 0.001
|
76
|
+
@turn_duration_label.text = "%4dms" % value.to_s
|
77
|
+
end
|
78
|
+
@turn_duration_slider.value = 500
|
79
|
+
end
|
42
80
|
end
|
43
81
|
end
|
44
82
|
|
83
|
+
# Text areas at the bottom.
|
45
84
|
horizontal padding: 0, spacing: 10 do
|
46
|
-
|
47
|
-
|
48
|
-
|
85
|
+
# Tabs to contain README and player code to the left.
|
86
|
+
vertical padding: 0, spacing: 0 do
|
87
|
+
@tabs_group = group do
|
88
|
+
@tab_buttons = horizontal padding: 0, spacing: 4 do
|
89
|
+
%w[README player.rb].each do |name|
|
90
|
+
radio_button(name.to_s, name, border_thickness: 0, tip: "View #{name}")
|
91
|
+
end
|
92
|
+
|
93
|
+
horizontal padding: 0, padding_left: 70 do
|
94
|
+
# Default editor for Windows.
|
95
|
+
ENV['EDITOR'] = "notepad" if Gem.win_platform? and ENV['EDITOR'].nil?
|
96
|
+
|
97
|
+
tip = ENV['EDITOR'] ? "Edit file in #{ ENV['EDITOR']}" : "ENV['EDITOR'] not set"
|
98
|
+
button "edit", tip: tip, enabled: ENV['EDITOR'], font_height: 12, border_thickness: 0 do
|
99
|
+
command = %<"#{ENV['EDITOR']}" "#{File.join(level.player_path, @tabs_group.value)}">
|
100
|
+
$stdout.puts "SYSTEM: #{command}"
|
101
|
+
Thread.new { system command }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
subscribe :changed do |_, value|
|
107
|
+
current = @tab_buttons.find {|elem| elem.value == value }
|
108
|
+
@tab_buttons.each {|t| t.enabled = (t != current) }
|
109
|
+
current.color, current.background_color = current.background_color, current.color
|
110
|
+
|
111
|
+
@tab_contents.clear
|
112
|
+
@tab_contents.add @tab_windows[value]
|
113
|
+
end
|
49
114
|
end
|
50
|
-
@readme_window.background_color = @readme_display.background_color
|
51
115
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
116
|
+
# Contents of those tabs.
|
117
|
+
@tab_contents = vertical padding: 0, width: 380, spacing: 10, height: $window.height * 0.45
|
118
|
+
|
119
|
+
create_tab_windows
|
120
|
+
@tabs_group.value = "README"
|
56
121
|
end
|
57
122
|
|
58
|
-
|
59
|
-
|
123
|
+
# Log on the right
|
124
|
+
vertical padding: 0, width: 380, height: 278 do
|
125
|
+
@log_window = scroll_window width: 380, height: 278 do
|
60
126
|
@log_display = text_area width: 368, editable: false
|
61
127
|
end
|
62
128
|
@log_window.background_color = @log_display.background_color
|
@@ -67,6 +133,19 @@ module RubyArmor
|
|
67
133
|
prepare_level
|
68
134
|
end
|
69
135
|
|
136
|
+
def create_tab_windows
|
137
|
+
@tab_windows = {}
|
138
|
+
@tab_windows["README"] = Fidgit::ScrollWindow.new width: 380, height: 250 do
|
139
|
+
@readme_display = text_area width: 368, editable: false
|
140
|
+
end
|
141
|
+
@tab_windows["README"].background_color = @readme_display.background_color
|
142
|
+
|
143
|
+
@tab_windows["player.rb"] = Fidgit::ScrollWindow.new width: 380, height: 250 do
|
144
|
+
@code_display = text_area width: 368, editable: false
|
145
|
+
end
|
146
|
+
@tab_windows["player.rb"].background_color = @code_display.background_color
|
147
|
+
end
|
148
|
+
|
70
149
|
def prepare_level
|
71
150
|
@log_display.text = ""
|
72
151
|
@continue_button.enabled = false
|
@@ -74,33 +153,27 @@ module RubyArmor
|
|
74
153
|
@reset_button.enabled = false
|
75
154
|
@start_button.enabled = true
|
76
155
|
|
77
|
-
|
78
|
-
@game = RubyWarrior::Game.new
|
79
|
-
|
80
|
-
# Create brand new profile or use the first of those already set.
|
81
|
-
profile_to_use = if @game.profiles.empty?
|
82
|
-
new_profile = RubyWarrior::Profile.new
|
83
|
-
new_profile.tower_path = @game.towers[0].path
|
84
|
-
new_profile.warrior_name = "Ruby"
|
85
|
-
new_profile
|
86
|
-
else
|
87
|
-
@game.profiles[0]
|
88
|
-
end
|
89
|
-
|
90
|
-
@game.instance_variable_set :@profile, profile_to_use
|
156
|
+
@exception = nil
|
91
157
|
|
92
158
|
@game.prepare_next_level unless profile.current_level.number > 0
|
93
159
|
|
94
|
-
#
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
@readme_display.text = replace_syntax File.read(File.join(level.player_path, "README"))
|
100
|
-
every(100) do
|
160
|
+
# Continually poll the player code file to see when it is edited.
|
161
|
+
stop_timer :refresh_code
|
162
|
+
converted_line_endings = false
|
163
|
+
every(100, :name => :refresh_code) do
|
101
164
|
begin
|
102
|
-
|
103
|
-
|
165
|
+
player_file = File.join level.player_path, "player.rb"
|
166
|
+
player_code = File.read player_file
|
167
|
+
unless @code_display.stripped_text.strip == player_code.strip
|
168
|
+
# Rewrite file as Windows text file if it is the default (a unix file).
|
169
|
+
if !converted_line_endings and Gem.win_platform? and
|
170
|
+
(File.open(player_file, "rb", &:read).strip == player_code.strip)
|
171
|
+
|
172
|
+
File.open(player_file, "w") {|f| f.puts player_code }
|
173
|
+
$stdout.puts "Converted to Windows line endings: #{player_file}"
|
174
|
+
end
|
175
|
+
converted_line_endings = true # Either will have or don't need to.
|
176
|
+
|
104
177
|
@code_display.text = player_code
|
105
178
|
prepare_level
|
106
179
|
end
|
@@ -109,12 +182,28 @@ module RubyArmor
|
|
109
182
|
end
|
110
183
|
end
|
111
184
|
|
112
|
-
|
113
|
-
@tile_set = %w[beginner intermediate].index(profile.tower.name) || 2 # We don't know what the last tower will be called.
|
185
|
+
@_level = profile.current_level
|
114
186
|
@turn = 0
|
115
187
|
@playing = false
|
188
|
+
level.load_level
|
189
|
+
|
190
|
+
@readme_display.text = replace_syntax File.read(File.join(level.player_path, "README"))
|
191
|
+
|
192
|
+
print "#{profile.warrior_name} climbs up to level #{level.number}\n"
|
193
|
+
@tile_set = %w[beginner intermediate].index(profile.tower.name) || 2 # We don't know what the last tower will be called.
|
194
|
+
|
195
|
+
warrior = floor.units.find {|u| u.is_a? RubyWarrior::Units::Warrior }
|
196
|
+
@entry_x, @entry_y = warrior.position.x, warrior.position.y
|
116
197
|
|
117
198
|
refresh_labels
|
199
|
+
|
200
|
+
# Load the player's own code, which might explode!
|
201
|
+
begin
|
202
|
+
level.load_player
|
203
|
+
rescue SyntaxError, StandardError => ex
|
204
|
+
handle_exception ex
|
205
|
+
return
|
206
|
+
end
|
118
207
|
end
|
119
208
|
|
120
209
|
def refresh_labels
|
@@ -128,18 +217,36 @@ module RubyArmor
|
|
128
217
|
@reset_button.enabled = true
|
129
218
|
@start_button.enabled = false
|
130
219
|
@playing = true
|
131
|
-
@take_next_turn_at = Time.now +
|
220
|
+
@take_next_turn_at = Time.now + @turn_duration
|
132
221
|
refresh_labels
|
133
222
|
end
|
134
223
|
|
135
224
|
def replace_syntax(string)
|
136
|
-
|
225
|
+
# Used in readme.
|
226
|
+
string.gsub!(/warrior\.[^! \n]+./) do |s|
|
137
227
|
if s[-1, 1] == '!'
|
138
|
-
"<c=
|
228
|
+
"<c=eeee00>#{s}</c>" # Commands.
|
139
229
|
else
|
140
230
|
"<c=00ff00>#{s}</c>" # Queries.
|
141
231
|
end
|
142
232
|
end
|
233
|
+
|
234
|
+
replace_log string
|
235
|
+
end
|
236
|
+
|
237
|
+
def replace_log(string)
|
238
|
+
@enemy_pattern ||= /([asw])/i #Archer, sludge, thick sludge, wizard.
|
239
|
+
@friend_pattern ||= /([C])/
|
240
|
+
@warrior_pattern ||= /([@G])/ # Player and golem
|
241
|
+
|
242
|
+
# Used in log.
|
243
|
+
string.gsub(/\|(.*)\|/i) {|c|
|
244
|
+
c.gsub(@enemy_pattern, '<c=ff0000>\1</c>')
|
245
|
+
.gsub(@friend_pattern, '<c=00dd00>\1</c>')
|
246
|
+
.gsub(@warrior_pattern, '<c=aaaaff>\1</c>')
|
247
|
+
}
|
248
|
+
.gsub(/^(#{profile.warrior_name}.*)/, '<c=aaaaff>\1</c>') # Player doing stuff.
|
249
|
+
.gsub(/(\-{3,}| \| )/, '<c=777777>\1</c>') # Walls.
|
143
250
|
end
|
144
251
|
|
145
252
|
def profile; @game.profile; end
|
@@ -150,12 +257,18 @@ module RubyArmor
|
|
150
257
|
self.puts "- turn #{@turn+1} -"
|
151
258
|
self.print floor.character
|
152
259
|
|
153
|
-
|
154
|
-
|
260
|
+
begin
|
261
|
+
floor.units.each(&:prepare_turn)
|
262
|
+
floor.units.each(&:perform_turn)
|
263
|
+
rescue => ex
|
264
|
+
handle_exception ex
|
265
|
+
return
|
266
|
+
end
|
267
|
+
|
155
268
|
@turn += 1
|
156
269
|
level.time_bonus -= 1 if level.time_bonus > 0
|
157
270
|
|
158
|
-
@take_next_turn_at = Time.now +
|
271
|
+
@take_next_turn_at = Time.now + @turn_duration
|
159
272
|
|
160
273
|
refresh_labels
|
161
274
|
|
@@ -176,39 +289,52 @@ module RubyArmor
|
|
176
289
|
end
|
177
290
|
end
|
178
291
|
|
292
|
+
def handle_exception(exception)
|
293
|
+
return if @exception and exception.message == @exception.message
|
294
|
+
|
295
|
+
self.puts "\n#{profile.warrior_name} was eaten by a #{exception.class}!\n"
|
296
|
+
self.puts exception.message
|
297
|
+
self.puts
|
298
|
+
self.puts exception.backtrace.join("\n")
|
299
|
+
|
300
|
+
exception.message =~ /:(\d+):/
|
301
|
+
exception_line = $1.to_i - 1
|
302
|
+
code_lines = @code_display.text.split "\n"
|
303
|
+
code_lines[exception_line] = "<c=ff0000>#{code_lines[exception_line]}</c>"
|
304
|
+
@code_display.text = code_lines.join "\n"
|
305
|
+
@exception = exception
|
306
|
+
end
|
307
|
+
|
179
308
|
def out_of_time?
|
180
309
|
@turn > @max_turns
|
181
310
|
end
|
182
311
|
|
183
|
-
def puts(message)
|
184
|
-
print message
|
312
|
+
def puts(message = "")
|
313
|
+
print "#{message}\n"
|
185
314
|
end
|
186
315
|
|
187
316
|
def print(message)
|
188
|
-
|
189
|
-
@log_display.text += message
|
317
|
+
#$stdout.puts message
|
318
|
+
@log_display.text += replace_log message
|
190
319
|
@log_window.offset_y = Float::INFINITY
|
191
320
|
end
|
192
321
|
|
193
|
-
SPRITE_WIDTH, SPRITE_HEIGHT = 8, 8
|
194
|
-
SPRITE_OFFSET_X, SPRITE_OFFSET_Y = 64, 64
|
195
|
-
SPRITE_SCALE = 7
|
196
|
-
|
197
322
|
def draw
|
198
323
|
super
|
199
324
|
|
200
325
|
$window.translate SPRITE_OFFSET_X, SPRITE_OFFSET_Y do
|
201
326
|
$window.scale SPRITE_SCALE do
|
202
|
-
# Draw walls.
|
327
|
+
# Draw horizontal walls.
|
203
328
|
floor.width.times do |x|
|
204
329
|
light = x % 2
|
205
330
|
light = 2 if light == 1 and (Gosu::milliseconds / 500) % 2 == 0
|
206
331
|
@tiles[light + 3, @tile_set].draw x * SPRITE_WIDTH, -SPRITE_HEIGHT, 0
|
207
|
-
@tiles[3, @tile_set].draw x * SPRITE_WIDTH, floor.height * SPRITE_HEIGHT,
|
332
|
+
@tiles[3, @tile_set].draw x * SPRITE_WIDTH, floor.height * SPRITE_HEIGHT, floor.height
|
208
333
|
end
|
209
|
-
|
210
|
-
|
211
|
-
@tiles[3, @tile_set].draw
|
334
|
+
# Draw vertical walls.
|
335
|
+
(-1..floor.height).each do |y|
|
336
|
+
@tiles[3, @tile_set].draw -SPRITE_WIDTH, y * SPRITE_HEIGHT, y
|
337
|
+
@tiles[3, @tile_set].draw floor.width * SPRITE_WIDTH, y * SPRITE_HEIGHT, y
|
212
338
|
end
|
213
339
|
|
214
340
|
# Draw floor
|
@@ -218,9 +344,12 @@ module RubyArmor
|
|
218
344
|
end
|
219
345
|
end
|
220
346
|
|
221
|
-
# Draw stairs
|
347
|
+
# Draw stairs (exit)
|
222
348
|
@tiles[2, @tile_set].draw floor.stairs_location[0] * SPRITE_WIDTH, floor.stairs_location[1] * SPRITE_HEIGHT, 0
|
223
349
|
|
350
|
+
# Draw trapdoor (entrance)
|
351
|
+
@tiles[6, @tile_set].draw @entry_x * SPRITE_WIDTH, @entry_y * SPRITE_HEIGHT, 0
|
352
|
+
|
224
353
|
# Draw units.
|
225
354
|
floor.units.each do |unit|
|
226
355
|
sprite = case unit
|
@@ -242,10 +371,10 @@ module RubyArmor
|
|
242
371
|
raise "unknown unit: #{unit.class}"
|
243
372
|
end
|
244
373
|
|
245
|
-
sprite.draw unit.position.x * SPRITE_WIDTH, unit.position.y * SPRITE_HEIGHT,
|
374
|
+
sprite.draw unit.position.x * SPRITE_WIDTH, unit.position.y * SPRITE_HEIGHT, unit.position.y
|
246
375
|
|
247
376
|
if unit.bound?
|
248
|
-
@sprites[2, 2].draw unit.position.x * SPRITE_WIDTH, unit.position.y * SPRITE_HEIGHT,
|
377
|
+
@sprites[2, 2].draw unit.position.x * SPRITE_WIDTH, unit.position.y * SPRITE_HEIGHT, unit.position.y
|
249
378
|
end
|
250
379
|
end
|
251
380
|
end
|
@@ -264,7 +393,7 @@ module RubyArmor
|
|
264
393
|
def update
|
265
394
|
super
|
266
395
|
|
267
|
-
if @playing and Time.now >= @take_next_turn_at and not (level.passed? || level.failed? || out_of_time?)
|
396
|
+
if @playing and Time.now >= @take_next_turn_at and not (level.passed? || level.failed? || out_of_time? || @exception)
|
268
397
|
play_turn
|
269
398
|
end
|
270
399
|
end
|
data/lib/ruby_armor/version.rb
CHANGED
data/lib/ruby_armor/window.rb
CHANGED
data/lib/ruby_armor.rb
CHANGED
@@ -15,8 +15,10 @@ require "ruby_armor/ruby_warrior_ext/position"
|
|
15
15
|
require "ruby_armor/ruby_warrior_ext/ui"
|
16
16
|
require "ruby_armor/ruby_warrior_ext/units/base"
|
17
17
|
require "ruby_armor/ruby_warrior_ext/abilities/rest"
|
18
|
+
|
18
19
|
require "ruby_armor/floating_text"
|
19
20
|
require "ruby_armor/sprite_sheet"
|
21
|
+
require "ruby_armor/states/choose_profile"
|
20
22
|
require "ruby_armor/states/play"
|
21
23
|
require "ruby_armor/window"
|
22
24
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2004, 2005 Tristan Grimmer
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Binary file
|
data/media/images/tiles.png
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_armor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3alpha
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubywarrior
|
16
|
-
requirement: &
|
16
|
+
requirement: &28574112 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.1.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *28574112
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: gosu
|
27
|
-
requirement: &
|
27
|
+
requirement: &28573560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.7.41
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *28573560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: chingu
|
38
|
-
requirement: &
|
38
|
+
requirement: &28573128 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.9rc7
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *28573128
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: fidgit
|
49
|
-
requirement: &
|
49
|
+
requirement: &28572804 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,12 +54,11 @@ dependencies:
|
|
54
54
|
version: 0.2.1
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *28572804
|
58
58
|
description:
|
59
59
|
email:
|
60
60
|
- bil.bagpuss@gmail.com
|
61
61
|
executables:
|
62
|
-
- ruby_armour
|
63
62
|
- ruby_armor
|
64
63
|
extensions: []
|
65
64
|
extra_rdoc_files: []
|
@@ -71,14 +70,16 @@ files:
|
|
71
70
|
- lib/ruby_armor/ruby_warrior_ext/ui.rb
|
72
71
|
- lib/ruby_armor/ruby_warrior_ext/units/base.rb
|
73
72
|
- lib/ruby_armor/sprite_sheet.rb
|
73
|
+
- lib/ruby_armor/states/choose_profile.rb
|
74
74
|
- lib/ruby_armor/states/play.rb
|
75
75
|
- lib/ruby_armor/version.rb
|
76
76
|
- lib/ruby_armor/window.rb
|
77
77
|
- lib/ruby_armor.rb
|
78
|
-
- media/fonts/
|
78
|
+
- media/fonts/Licence.txt
|
79
|
+
- media/fonts/ProggyCleanSZ.ttf
|
79
80
|
- media/images/characters.png
|
80
81
|
- media/images/tiles.png
|
81
|
-
-
|
82
|
+
- README.md
|
82
83
|
- bin/ruby_armor
|
83
84
|
homepage: http://spooner.github.com/libraries/ruby_armor/
|
84
85
|
licenses:
|
@@ -95,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
96
|
version: '0'
|
96
97
|
segments:
|
97
98
|
- 0
|
98
|
-
hash:
|
99
|
+
hash: 39949075
|
99
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
101
|
none: false
|
101
102
|
requirements:
|
data/bin/ruby_armour
DELETED
data/media/fonts/MONACO.TTF
DELETED
Binary file
|