essytas 0.0.1

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.
Files changed (174) hide show
  1. data/LICENSE +19 -0
  2. data/README +3 -0
  3. data/Rakefile +44 -0
  4. data/bin/essytas +2 -0
  5. data/lib/animation.rb +74 -0
  6. data/lib/config.rb +63 -0
  7. data/lib/core.rb +242 -0
  8. data/lib/cursor.rb +43 -0
  9. data/lib/def/animations/explosion1.anim +103 -0
  10. data/lib/def/characters.def +132 -0
  11. data/lib/def/de/dialogues/test.dlg +4 -0
  12. data/lib/def/de/enemies.trans +6 -0
  13. data/lib/def/de/items.trans +84 -0
  14. data/lib/def/de/skills.trans +48 -0
  15. data/lib/def/de/spells.trans +31 -0
  16. data/lib/def/en/dialogues/test.dlg +4 -0
  17. data/lib/def/en/enemies.trans +6 -0
  18. data/lib/def/en/items.trans +78 -0
  19. data/lib/def/en/skills.trans +48 -0
  20. data/lib/def/en/spells.trans +31 -0
  21. data/lib/def/enemies.def +8 -0
  22. data/lib/def/enemies/wolf.bhv +11 -0
  23. data/lib/def/init.def +5 -0
  24. data/lib/def/items.def +153 -0
  25. data/lib/def/loot.def +2 -0
  26. data/lib/def/particles.def +66 -0
  27. data/lib/def/recipies.def +18 -0
  28. data/lib/def/skills.def +40 -0
  29. data/lib/def/spells.def +42 -0
  30. data/lib/def/spells.rb +16 -0
  31. data/lib/def/weapons.def +9 -0
  32. data/lib/ext/astar/AMap.rb +146 -0
  33. data/lib/ext/astar/node.rb +72 -0
  34. data/lib/ext/astar/priority_queue.rb +44 -0
  35. data/lib/ext/shader.rb +116 -0
  36. data/lib/game/alchemy/recipe.rb +26 -0
  37. data/lib/game/character.rb +102 -0
  38. data/lib/game/combat/bar.rb +119 -0
  39. data/lib/game/combat/battle.rb +345 -0
  40. data/lib/game/combat/control.rb +18 -0
  41. data/lib/game/combat/gui.rb +190 -0
  42. data/lib/game/combat/gui/select_item.rb +11 -0
  43. data/lib/game/combat/gui/select_spell.rb +38 -0
  44. data/lib/game/constitution.rb +48 -0
  45. data/lib/game/equipment.rb +34 -0
  46. data/lib/game/inventory.rb +37 -0
  47. data/lib/game/item.rb +54 -0
  48. data/lib/game/magic.rb +33 -0
  49. data/lib/game/map/events.rb +29 -0
  50. data/lib/game/map/fog.rb +41 -0
  51. data/lib/game/map/map.rb +247 -0
  52. data/lib/game/map/map_animation.rb +26 -0
  53. data/lib/game/map/map_loader.rb +177 -0
  54. data/lib/game/map/map_object.rb +208 -0
  55. data/lib/game/map/map_particle.rb +27 -0
  56. data/lib/game/map/player.rb +78 -0
  57. data/lib/game/map/tile.rb +35 -0
  58. data/lib/game/mind.rb +24 -0
  59. data/lib/game/npc/behaviour.rb +45 -0
  60. data/lib/game/npc/bubble.rb +28 -0
  61. data/lib/game/npc/goal.rb +93 -0
  62. data/lib/game/npc/npc.rb +95 -0
  63. data/lib/game/npc/task.rb +73 -0
  64. data/lib/game/osd/magic.rb +24 -0
  65. data/lib/game/party.rb +42 -0
  66. data/lib/game/skills.rb +64 -0
  67. data/lib/game/spell.rb +35 -0
  68. data/lib/game_window.rb +95 -0
  69. data/lib/glsl/contrast.frag +12 -0
  70. data/lib/glsl/fade.frag +11 -0
  71. data/lib/glsl/mezzotint.frag +20 -0
  72. data/lib/glsl/noise.frag +20 -0
  73. data/lib/glsl/pixelate.frag +42 -0
  74. data/lib/glsl/radialblur.frag +28 -0
  75. data/lib/glsl/sepia.frag +15 -0
  76. data/lib/glsl/shockwave.frag +24 -0
  77. data/lib/glsl/tv_screen.frag +17 -0
  78. data/lib/graphics/animations/credits.txt +1 -0
  79. data/lib/graphics/animations/explosion2.png +0 -0
  80. data/lib/graphics/backgrounds/white_ties_grass.png +0 -0
  81. data/lib/graphics/chars/ejera.png +0 -0
  82. data/lib/graphics/chars/salyjea.png +0 -0
  83. data/lib/graphics/chars/tharat.png +0 -0
  84. data/lib/graphics/combat/tharat.png +0 -0
  85. data/lib/graphics/cursors/normal.png +0 -0
  86. data/lib/graphics/fog/clouds1.png +0 -0
  87. data/lib/graphics/gui/bar_center.png +0 -0
  88. data/lib/graphics/gui/bar_left.png +0 -0
  89. data/lib/graphics/gui/bar_right.png +0 -0
  90. data/lib/graphics/gui/button_background.png +0 -0
  91. data/lib/graphics/gui/button_close.png +0 -0
  92. data/lib/graphics/gui/button_close_hi.png +0 -0
  93. data/lib/graphics/gui/button_highlight.png +0 -0
  94. data/lib/graphics/gui/charequip_background.png +0 -0
  95. data/lib/graphics/gui/charselect_background.png +0 -0
  96. data/lib/graphics/gui/container_background.png +0 -0
  97. data/lib/graphics/gui/drop_item.png +0 -0
  98. data/lib/graphics/gui/equip_Etarae.png +0 -0
  99. data/lib/graphics/gui/equip_Mensch.png +0 -0
  100. data/lib/graphics/gui/equipslot_background.png +0 -0
  101. data/lib/graphics/gui/iteminfo_background.png +0 -0
  102. data/lib/graphics/gui/msg_background.png +0 -0
  103. data/lib/graphics/gui/scrollbar_background.png +0 -0
  104. data/lib/graphics/gui/scroller.png +0 -0
  105. data/lib/graphics/gui/tile_32.png +0 -0
  106. data/lib/graphics/gui/tile_32_highlight.png +0 -0
  107. data/lib/graphics/icons/items/arrow.png +0 -0
  108. data/lib/graphics/icons/items/bandage.png +0 -0
  109. data/lib/graphics/icons/items/boots_leather.png +0 -0
  110. data/lib/graphics/icons/items/bow.png +0 -0
  111. data/lib/graphics/icons/items/credits.txt +8 -0
  112. data/lib/graphics/icons/items/harness_leather.png +0 -0
  113. data/lib/graphics/icons/items/knife.png +0 -0
  114. data/lib/graphics/icons/items/shirt_linen.png +0 -0
  115. data/lib/graphics/items/none.png +0 -0
  116. data/lib/graphics/menu/ingame_background.png +0 -0
  117. data/lib/graphics/menu/ingame_background.xcf +0 -0
  118. data/lib/graphics/menu/start_background.png +0 -0
  119. data/lib/graphics/missing.png +0 -0
  120. data/lib/graphics/osd/magic_bg.png +0 -0
  121. data/lib/graphics/particles/leaf.png +0 -0
  122. data/lib/graphics/particles/smoke.png +0 -0
  123. data/lib/graphics/pixel.png +0 -0
  124. data/lib/graphics/tiles/test.png +0 -0
  125. data/lib/gui/base.rb +278 -0
  126. data/lib/gui/button.rb +93 -0
  127. data/lib/gui/char_equip.rb +118 -0
  128. data/lib/gui/char_selector.rb +54 -0
  129. data/lib/gui/context_menu.rb +115 -0
  130. data/lib/gui/draggable.rb +18 -0
  131. data/lib/gui/grid.rb +118 -0
  132. data/lib/gui/image.rb +17 -0
  133. data/lib/gui/inventory.rb +42 -0
  134. data/lib/gui/item_info.rb +33 -0
  135. data/lib/gui/slider.rb +10 -0
  136. data/lib/gui/textfield.rb +57 -0
  137. data/lib/layer.rb +64 -0
  138. data/lib/load.rb +31 -0
  139. data/lib/main.rb +18 -0
  140. data/lib/maps/def/test.bhv +26 -0
  141. data/lib/maps/def/test.rb +14 -0
  142. data/lib/maps/test.tmx +133 -0
  143. data/lib/maps/test2.tmx +94 -0
  144. data/lib/maps/test3.tmx +29 -0
  145. data/lib/maps/test3_lower.tmx +25 -0
  146. data/lib/maps/test3_upper.tmx +25 -0
  147. data/lib/maps/test_left.tmx +25 -0
  148. data/lib/maps/test_upper.tmx +25 -0
  149. data/lib/music/Butterfly Tea - A New Hope 2K11.mp3 +0 -0
  150. data/lib/music/Greendjohn - Rebirth.mp3 +0 -0
  151. data/lib/music/credits.txt +8 -0
  152. data/lib/parse.rb +605 -0
  153. data/lib/parse_tmx.rb +114 -0
  154. data/lib/particles.rb +127 -0
  155. data/lib/sample.rb +29 -0
  156. data/lib/save.rb +44 -0
  157. data/lib/song.rb +41 -0
  158. data/lib/sounds/click1.wav +0 -0
  159. data/lib/sounds/credits.txt +2 -0
  160. data/lib/sounds/error1.wav +0 -0
  161. data/lib/sprite.rb +35 -0
  162. data/lib/states/menus.rb +17 -0
  163. data/lib/states/menus/alchemy.rb +53 -0
  164. data/lib/states/menus/equip.rb +79 -0
  165. data/lib/states/menus/ingame.rb +34 -0
  166. data/lib/states/menus/magic.rb +31 -0
  167. data/lib/states/menus/options.rb +54 -0
  168. data/lib/states/menus/start.rb +38 -0
  169. data/lib/states/states.rb +154 -0
  170. data/lib/tileset.rb +42 -0
  171. data/lib/tools/world.rb +103 -0
  172. data/lib/tools/worldmap_editor.rb +221 -0
  173. data/lib/translate.rb +368 -0
  174. metadata +255 -0
@@ -0,0 +1,29 @@
1
+
2
+ module Core::Game
3
+ module Events
4
+
5
+ class Event
6
+ attr_reader :object
7
+ def initialize(obj)
8
+ @object = obj
9
+ end
10
+ end
11
+
12
+ class MotionEvent < Event
13
+ attr_reader :old_pos
14
+ def initialize(npc, old_pos)
15
+ super(npc)
16
+ @old_pos = old_pos
17
+ end
18
+ end
19
+
20
+ class TriggerEvent < Event
21
+ attr_reader :other
22
+ def initialize(activator, other)
23
+ super(activator)
24
+ @other = other
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+
2
+ module Core::Game
3
+
4
+ class Fog
5
+
6
+ def initialize(file, sx, sy, a=255, r=255, g=255, b=255)
7
+ @img = Core.sprite("fog/#{file}", true)
8
+ @x = @y = 0.0
9
+ @sx, @sy = sx, sy
10
+ @color = Gosu::Color.new(a, r, g, b)
11
+ end
12
+ def update
13
+ @x += @sx
14
+ @y += @sy
15
+ if @x > 1024
16
+ @x = 0.0
17
+ elsif @x < 0
18
+ @x = 1024.0
19
+ end
20
+ if @y > 768.0
21
+ @y = 0
22
+ elsif @y < 0
23
+ @y = 768.0
24
+ end
25
+ end
26
+ def draw
27
+ @img.draw(@x, @y, Core::FOG_Z, 1, 1, @color)
28
+ if @sx != 0
29
+ @img.draw(@x-@img.width, @y, Core::FOG_Z, 1, 1, @color)
30
+ end
31
+ if @sy != 0
32
+ @img.draw(@x, @y-@img.height, Core::FOG_Z, 1, 1, @color)
33
+ end
34
+ if @sx != 0 and @sy != 0
35
+ @img.draw(@x-@img.width, @y-@img.height, Core::FOG_Z, 1, 1, @color)
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,247 @@
1
+
2
+ module Core::Game
3
+ require_relative "../../ext/astar/node.rb"
4
+ require_relative "../../ext/astar/priority_queue.rb"
5
+ require_relative "tile.rb"
6
+
7
+ class Map
8
+ attr_reader :layers, :properties, :module
9
+ attr_accessor :xoff, :yoff, :objects
10
+ def initialize(props, layers, objects, mod)
11
+ @properties = props
12
+ @layers = layers
13
+ @objects = objects
14
+ @xoff = @yoff = 0
15
+ @module = mod
16
+ create_static_collision
17
+ end
18
+
19
+ def width
20
+ return @properties[:width]
21
+ end
22
+
23
+ def height
24
+ return @properties[:height]
25
+ end
26
+
27
+ def create_static_collision
28
+ return if @layers.empty?
29
+ tiles = []
30
+ @layers.each { |l|
31
+ i = 0
32
+ l.filled.each { |row|
33
+ row.each { |tile|
34
+ if !tile
35
+ if tiles[i] == false
36
+ i += 1
37
+ next
38
+ else
39
+ tiles[i] = true
40
+ i += 1
41
+ next
42
+ end
43
+ end
44
+ tiles[i] = tile.passable?
45
+ i += 1
46
+ }
47
+ }
48
+ }
49
+ @collision = Core::CollisionLayer.new(@layers.first.filled.first.size, @layers.first.filled.size, tiles)
50
+ end
51
+
52
+ # parameters are scrolling, instance variables are world positions
53
+ def draw(xoff, yoff)
54
+ @layers.each { |l|
55
+ l.filled.each { |ary|
56
+ ary.each { |tile|
57
+ tile.draw(xoff+@xoff, yoff+@yoff) if tile
58
+ }
59
+ }
60
+ }
61
+ end
62
+
63
+ def passable?(x, y, player=false)
64
+ if !player && ((x/32) < 0 or (x/32) >= width or (y/32) < 0 or (y/32) >= height)
65
+ return false
66
+ elsif player
67
+ if (x/32).to_i >= width
68
+ if Core.window.state.map.right.passable?(0, y, true)
69
+ Core.window.state.map.load(Core.window.state.map.right.properties[:file])
70
+ Core.window.state.map.player.teleport(0, y / 32)
71
+ return true
72
+ else
73
+ return false
74
+ end
75
+ elsif (x/32).to_i < 0
76
+ if Core.window.state.map.left.passable?((Core.window.state.map.left.width - 1) * 32, y, true)
77
+ Core.window.state.map.load(Core.window.state.map.left.properties[:file])
78
+ Core.window.state.map.player.teleport(Core.window.state.map.current.width, y / 32)
79
+ return true
80
+ else
81
+ return false
82
+ end
83
+ elsif (y/32).to_i >= height
84
+ if Core.window.state.map.left.passable?(x, 0, true)
85
+ Core.window.state.map.load(Core.window.state.map.lower.properties[:file])
86
+ Core.window.state.map.player.teleport(x / 32, 0)
87
+ return true
88
+ else
89
+ return false
90
+ end
91
+ elsif (y/32).to_i < 0
92
+ if Core.window.state.map.left.passable?(x, (Core.window.state.map.upper.height - 1) * 32, true)
93
+ Core.window.state.map.load(Core.window.state.map.upper.properties[:file])
94
+ Core.window.state.map.player.teleport(x / 32, Core.window.state.map.current.height)
95
+ return true
96
+ else
97
+ return false
98
+ end
99
+ end
100
+ end
101
+ begin
102
+ p = @collision.tiles[y/32][x/32]
103
+ rescue
104
+ puts("Collision out of bounds: #{x/32}|#{y/32}")
105
+ end
106
+ if p
107
+ obj = Core.window.state.find_object(x, y)
108
+ if !obj
109
+ return true
110
+ end
111
+ p = obj.through
112
+ end
113
+ return p
114
+ end
115
+
116
+ def generate_costmap
117
+ map = []
118
+ x = 0
119
+ @collision.tiles.each { |ary|
120
+ cary = []
121
+ y = 0
122
+ ary.each { |tile|
123
+ if tile
124
+ obj = Core.window.state.find_object(y*32, x*32)
125
+ if obj and !obj.through
126
+ cary.push(0)
127
+ y += 1
128
+ next
129
+ end
130
+ cary.push(1)
131
+ else
132
+ cary.push(0)
133
+ end
134
+ y += 1
135
+ }
136
+ map.push(cary)
137
+ x += 1
138
+ }
139
+ return map
140
+ end
141
+
142
+ def generate_successor_nodes(anode, costmap)
143
+ height = costmap.size
144
+ width = costmap.first.size
145
+ # determine nodes bordering this one - only N,S,E,W for now
146
+ # no boundary condition check, eg if anode.x==-4
147
+ # considers a wall to be a 0 so therefore not allow that to be a neighbour
148
+ north = costmap[anode.y-1][anode.x] unless (anode.y-1) < 0 #boundary check for -1
149
+ south = costmap[anode.y+1][anode.x] unless (anode.y+1) > (height - 1)
150
+ east = costmap[anode.y][anode.x+1] unless (anode.x+1) > (width - 1)
151
+ west = costmap[anode.y][anode.x-1] unless (anode.x-1) < 0 #boundary check for -1
152
+
153
+ if (west && west > 0) # not on left edge, so provide a left-bordering node
154
+ newnode = AStar::Node.new((anode.x-1),anode.y,costmap[anode.y][(anode.x-1)])
155
+ yield newnode
156
+ end
157
+ if (east && east > 0) # not on right edge, so provide a right-bordering node
158
+ newnode = AStar::Node.new((anode.x+1),anode.y,costmap[anode.y][(anode.x+1)])
159
+ yield newnode
160
+ end
161
+ if (north && north > 0) # not on left edge, so provide a left-bordering node
162
+ newnode = AStar::Node.new(anode.x,(anode.y-1),costmap[(anode.y-1)][anode.x])
163
+ yield newnode
164
+ end
165
+ if (south && south > 0) # not on right edge, so provide a right-bordering node
166
+ newnode = AStar::Node.new(anode.x,(anode.y+1),costmap[(anode.y+1)][anode.x])
167
+ yield newnode
168
+ end
169
+ end
170
+
171
+ def astar(node_start, node_goal)
172
+ iterations = 0
173
+ open = AStar::PriorityQueue.new()
174
+ closed = AStar::PriorityQueue.new()
175
+ node_start.calc_h(node_goal)
176
+ open.push(node_start)
177
+ costmap = generate_costmap
178
+ while !open.empty? do
179
+ iterations += 1 #keep track of how many times this itersates
180
+ node_current = open.find_best
181
+ if node_current == node_goal
182
+ #puts("Iterations: #{iterations}")
183
+ #show_path(node_current)
184
+ return node_current
185
+ end
186
+ generate_successor_nodes(node_current, costmap) { |node_successor|
187
+ #now doing for each successor node of node_current
188
+ node_successor.calc_g(node_current)
189
+ #skip to next node_successor if better one already on open or closed list
190
+ if open_successor=open.find(node_successor) then
191
+ if open_successor<=node_successor then next end #need to account for nil result
192
+ end
193
+ if closed_successor=closed.find(node_successor) then
194
+ if closed_successor<=node_successor then next end
195
+ end
196
+ #still here, then there's no better node yet, so remove any copies of this node on open/closed lists
197
+ open.remove(node_successor)
198
+ closed.remove(node_successor)
199
+ # set the parent node of node_successor to node_current
200
+ node_successor.parent=node_current
201
+ # set h to be the estimated distance to node_goal using the heuristic
202
+ node_successor.calc_h(node_goal)
203
+ # so now we know this is the best copy of the node so far, so put it onto the open list
204
+ open.push(node_successor)
205
+ }
206
+ #now we've gone through all the successors, so the current node can be closed
207
+ closed.push(node_current)
208
+ end
209
+ end
210
+
211
+ def show_path(anode)
212
+ #shows the path back from node 'anode' by following the parent pointer
213
+ curr = anode
214
+ pathmap = generate_costmap
215
+ while curr.parent do
216
+ pathmap[curr.y][curr.x] = '*'
217
+ curr = curr.parent
218
+ end
219
+ pathmap[curr.y][curr.x] = '*'
220
+ pathstr=""
221
+ pathmap.each_index do |row|
222
+ pathmap[row].each_index do |col|
223
+ pathstr<<"|#{pathmap[row][col]}"
224
+ end
225
+ pathstr<<"|\n"
226
+ end
227
+ puts(pathstr)
228
+ end
229
+
230
+ def upper
231
+ return @properties[:upper]
232
+ end
233
+
234
+ def lower
235
+ return @properties[:lower]
236
+ end
237
+
238
+ def left
239
+ return @properties[:left]
240
+ end
241
+
242
+ def right
243
+ return @properties[:right]
244
+ end
245
+
246
+ end
247
+ end
@@ -0,0 +1,26 @@
1
+
2
+ module Core::Game
3
+
4
+ class MapAnimation < MapObject
5
+
6
+ def initialize(anim, x, y)
7
+ super(x, y, {})
8
+ @anim = Core.anim(anim)
9
+ @anim.play(x, y, @z)
10
+ end
11
+
12
+ def update
13
+ end
14
+
15
+ def draw(xoff, yoff)
16
+ @anim.x = @x + xoff
17
+ @anim.y = @y + yoff
18
+ @anim.draw
19
+ if @anim.remove?
20
+ @dead = true
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,177 @@
1
+
2
+ require_relative "fog.rb"
3
+
4
+ module Core::Game
5
+ class MapLoader
6
+
7
+ attr_reader :objects, :misc, :player
8
+ attr_accessor :xoff, :yoff
9
+
10
+ def initialize
11
+ @objects = []
12
+ @maps = []
13
+ @misc = []
14
+ @player = Core::Game::Player.new(0, 0)
15
+ @tonepic = Core.sprite("pixel", true)
16
+ @box = Core::GUI::Textfield.new(256, 480, 512, 224, "", 24, :left)
17
+ @message = false
18
+ @xoff = 496
19
+ @yoff = 360
20
+ end
21
+
22
+ def current
23
+ return @maps[4]
24
+ end
25
+
26
+ def left
27
+ return @maps[3]
28
+ end
29
+
30
+ def right
31
+ return @maps[5]
32
+ end
33
+
34
+ def upper
35
+ return @maps[1]
36
+ end
37
+
38
+ def lower
39
+ return @maps[7]
40
+ end
41
+
42
+ # 0 1 2
43
+ # 3 4 5
44
+ # 6 7 8
45
+ #
46
+ # 4 => current
47
+
48
+ def load(file)
49
+ @maps.clear
50
+ map = Core::Parse.map(file)
51
+ @objects = map.objects
52
+ @objects.push(@player)
53
+ @maps[4] = map
54
+ if map.upper
55
+ @maps[1] = Core::Parse.map(map.upper)
56
+ @maps[1].yoff = -@maps[1].height*32
57
+ if @maps[1].left
58
+ @maps[0] = Core::Parse.map(@maps[1].left)
59
+ @maps[0].xoff = -@maps[1].height*32
60
+ @maps[0].yoff = -@maps[0].height*32
61
+ end
62
+ if @maps[1].right
63
+ @maps[2] = Core::Parse.map(@maps[1].right)
64
+ @maps[2].xoff = @maps[1].height*32
65
+ @maps[2].yoff = -@maps[1].height*32
66
+ end
67
+ end
68
+ if map.right
69
+ @maps[5] = Core::Parse.map(map.right)
70
+ @maps[5].xoff = @maps[4].width*32
71
+ if @maps[5].upper
72
+ @maps[2] = Core::Parse.map(@maps[5].upper)
73
+ @maps[2].xoff = @maps[4].width*32
74
+ @maps[2].yoff = -@maps[2].height*32
75
+ end
76
+ if @maps[5].lower
77
+ @maps[8] = Core::Parse.map(@maps[5].lower)
78
+ @maps[8].xoff = @maps[4].width*32
79
+ @maps[8].yoff = @maps[4].height*32
80
+ end
81
+ end
82
+ if map.left
83
+ @maps[3] = Core::Parse.map(map.left)
84
+ @maps[3].xoff = -@maps[3].width*32
85
+ if !@maps[1].left and @maps[3].upper
86
+ @maps[0] = Core::Parse.map(@maps[3].upper)
87
+ @maps[0].xoff = -@maps[0].width*32
88
+ @maps[0].yoff = -@maps[0].height*32
89
+ end
90
+ end
91
+ if map.lower
92
+ @maps[7] = Core::Parse.map(map.lower)
93
+ @maps[7].yoff = @maps[7].height*32
94
+ if @maps[7].left
95
+ @maps[6] = Core::Parse.map(@maps[7].left)
96
+ @maps[6].xoff = -@maps[7].height*32
97
+ @maps[6].yoff = @maps[7].height*32
98
+ if !@maps[6].left and @maps[3].lower
99
+ @maps[6] = Core::Parse.map(@maps[3].lower)
100
+ @maps[6].xoff = -@maps[6].width*32
101
+ @maps[6].yoff = +@maps[6].height*32
102
+ end
103
+ end
104
+ if @maps[7].right
105
+ @maps[8] = Core::Parse.map(@maps[7].right)
106
+ @maps[8].xoff = @maps[7].height*32
107
+ @maps[8].yoff = @maps[7].height*32
108
+ end
109
+ end
110
+ if map.properties[:music]
111
+ if map.properties[:music] == "nil"
112
+ @song.stop if @song
113
+ else
114
+ @song = Core::Song.new(map.properties[:music])
115
+ @song.play(true)
116
+ end
117
+ end
118
+ if map.properties[:fog]
119
+ if map.properties[:fog] == "nil"
120
+ @fog = nil
121
+ else
122
+ @fog = Core::Game::Fog.new(map.properties[:fog], map.properties[:fogx].to_f, map.properties[:fogy].to_f, map.properties[:foga].to_i, map.properties[:fogr].to_i, map.properties[:fogg].to_i, map.properties[:fogb].to_i)
123
+ end
124
+ end
125
+ if map.properties[:tonea] or map.properties[:toner] or map.properties[:toneg] or map.properties[:toneb]
126
+ @tone = Gosu::Color.new(map.properties[:tonea].to_i, map.properties[:toner].to_i, map.properties[:toneg].to_i, map.properties[:toneb].to_i)
127
+ else
128
+ @tone = nil
129
+ end
130
+ end
131
+
132
+ def update
133
+ if !@message
134
+ @objects.each { |obj|
135
+ obj.setup if obj.do_setup?
136
+ obj.update
137
+ if obj.dead?
138
+ @objects.delete(obj)
139
+ end
140
+ }
141
+ @misc.each { |obj|
142
+ obj.update
143
+ }
144
+ @fog.update if @fog
145
+ else
146
+ if Core.window.pressed?(Gosu::KbSpace)
147
+ @message = false
148
+ end
149
+ end
150
+ end
151
+
152
+ def draw
153
+ @maps.each { |map|
154
+ map.draw(@xoff, @yoff) if map
155
+ }
156
+ @objects.each { |obj|
157
+ obj.draw(@xoff, @yoff)
158
+ }
159
+ @misc.each { |m|
160
+ m.draw
161
+ }
162
+ @fog.draw if @fog
163
+ @tonepic.draw(0, 0, 500000, 1024, 768, @tone) if @tone
164
+ if @message
165
+ @box.draw
166
+ end
167
+ end
168
+
169
+ def message(str, x=256, y=480, w=512, h=224)
170
+ @box.text = str
171
+ @message = true
172
+ @box.x, @box.y = x, y
173
+ @box.w, @box.h = w, h
174
+ end
175
+
176
+ end
177
+ end