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,208 @@
1
+
2
+ module Core::Game
3
+
4
+ class MapObject
5
+
6
+ attr_reader :x, :y, :z, :name, :dy, :dx, :properties, :tx, :ty
7
+ attr_accessor :through, :follow
8
+
9
+ DELIM = "\x00"
10
+
11
+ def initialize(x, y, props)
12
+ file = props[:file]
13
+ if file
14
+ @graphics = Core.tiles("chars/#{file}", -4, -4)
15
+ else
16
+ @graphics = nil
17
+ file = "unnamed"
18
+ end
19
+ @properties = props
20
+ @follow = false
21
+ @index = 0
22
+ @x, @y = x, y
23
+ @tx, @ty = x/32, y/32 # tile based position, used for collision
24
+ @z = Core::MAPOBJECT_Z
25
+ @z += props[:z] if props[:z]
26
+ @speed = 0
27
+ @speed += props[:speed] if props[:speed]
28
+ @dx = @dy = 0 # distance to move, should be multiple of @speed
29
+ @dead = false
30
+ @steps = 0
31
+ @trigger = nil
32
+ @name = "mapobject-#{file.downcase}-#{rand(1000)}"
33
+ @through = false
34
+ @setup = true
35
+ @stepped = false
36
+ end
37
+
38
+ def do_setup?
39
+ return @setup
40
+ end
41
+
42
+ def setup
43
+ if !@setup
44
+ return false
45
+ end
46
+ if @setup
47
+ @setup = false
48
+ end
49
+ return true
50
+ end
51
+
52
+ def update
53
+ update_move(Core.window.state.map.current)
54
+ end
55
+
56
+ def update_move(map)
57
+ moved = false
58
+ player = self.class == Player
59
+ tx = @tx
60
+ ty = @ty
61
+ if @dx > 0
62
+ if @stepped or @through or map.passable?((@tx*32)+@dx, @ty*32, player)
63
+ @x += @speed
64
+ @dx -= @speed
65
+ @tx += 1 if !@stepped
66
+ @stepped = true
67
+ moved = true
68
+ if @tx > Core.window.state.map.current.width
69
+ Core.window.state.map.move_right
70
+ @tx = 0
71
+ @x = @speed
72
+ end
73
+ else
74
+ @dx = 0
75
+ end
76
+ @index = 8
77
+ elsif @dx < 0
78
+ if @stepped or @through or map.passable?((@tx*32)+@dx, @ty*32, player)
79
+ @x -= @speed
80
+ @dx += @speed
81
+ @tx -= 1 if !@stepped
82
+ @stepped = true
83
+ moved = true
84
+ if @tx < 0
85
+ Core.window.state.map.move_left
86
+ @tx = Core.window.state.map.current.width
87
+ @x = (Core.window.state.map.current.width*32) - @speed
88
+ end
89
+ else
90
+ @dx = 0
91
+ end
92
+ @index = 4
93
+ end
94
+ if @dy > 0
95
+ if @stepped or @through or map.passable?(@tx*32, (@ty*32)+@dy, player)
96
+ @y += @speed
97
+ @dy -= @speed
98
+ @ty += 1 if !@stepped
99
+ @stepped = true
100
+ moved = true
101
+ else
102
+ @dy = 0
103
+ end
104
+ @index = 0
105
+ elsif @dy < 0
106
+ if @stepped or @through or map.passable?(@tx*32, (@ty*32)+@dy, player)
107
+ @y -= @speed
108
+ @dy += @speed
109
+ @ty -= 1 if !@stepped
110
+ @stepped = true
111
+ moved = true
112
+ else
113
+ @dy = 0
114
+ end
115
+ @index = 12
116
+ end
117
+ if @dx == 0 and @dy == 0 and moved
118
+ @steps += 1
119
+ @stepped = false
120
+ end
121
+ if moved
122
+ d = @dx
123
+ if d == 0
124
+ d = @dy
125
+ end
126
+ if d < 0
127
+ d *= -1
128
+ end
129
+ if Core.between?(d, 8, 25)
130
+ if @steps.even?
131
+ @index += 1
132
+ else
133
+ @index += 3
134
+ end
135
+ end
136
+ end
137
+ if tx != @tx or ty != @ty
138
+ Core.window.state.map.current.module.event(Events::MotionEvent.new(self, [tx, ty]))
139
+ end
140
+ return moved
141
+ end
142
+
143
+ def update_trigger
144
+ # look for something on current tile
145
+ obj = Core.window.state.find_object(@tx*32, @ty*32)
146
+ if !obj or obj == self
147
+ # look for something in the direction we're looking
148
+ x = y = 0
149
+ case direction
150
+ when 0
151
+ y = 32
152
+ when 1
153
+ x = -32
154
+ when 2
155
+ x = 32
156
+ else
157
+ y = -32
158
+ end
159
+ obj = Core.window.state.find_object((@tx*32)+x, (@ty*32)+y)
160
+ end
161
+ if obj
162
+ obj.trigger(self)
163
+ Core.window.state.map.current.module.event(Events::TriggerEvent.new(self, obj))
164
+ end
165
+ end
166
+
167
+ def draw(xoff, yoff)
168
+ @graphics[@index].draw(@x+xoff, @y-16+yoff, @z)
169
+ end
170
+
171
+ def dead?
172
+ return @dead
173
+ end
174
+
175
+ def trigger(other)
176
+ @trigger.call(other) if @trigger
177
+ @behaviour.on_trigger(other) if @behaviour
178
+ end
179
+
180
+ def direction
181
+ if Core.between?(@index, -1, 4)
182
+ return 0 # down
183
+ elsif Core.between?(@index, 3, 8)
184
+ return 1 # left
185
+ elsif Core.between?(@index, 7, 12)
186
+ return 2 # right
187
+ elsif Core.between?(@index, 11, 16)
188
+ return 3 # up
189
+ end
190
+ end
191
+
192
+ def to_save
193
+ str = "#{@name}#{DELIM}#{@properties.to_s}#{DELIM}#{@tx}|#{@ty}#{DELIM}"
194
+ str += "#{@x}|#{@y}#{DELIM}#{@speed}#{DELIM}#{@steps}#{DELIM}#{@through}#{DELIM}#{@stepped}#{DELIM}"
195
+ return str
196
+ end
197
+
198
+ def teleport(tx, ty)
199
+ @tx = tx
200
+ @ty = ty
201
+ @x = @tx * 32
202
+ @y = @ty * 32
203
+ end
204
+
205
+ end
206
+ end
207
+
208
+ require_relative "../npc/npc.rb"
@@ -0,0 +1,27 @@
1
+
2
+ module Core::Game
3
+
4
+ class MapParticle
5
+ attr_accessor :follow, :xoff, :yoff
6
+ def initialize(x, y, effect)
7
+ @emitter = Core::Particles.new(effect, x, y)
8
+ end
9
+
10
+ def x=(x)
11
+ @emitter.x = x
12
+ end
13
+
14
+ def y=(y)
15
+ @emitter.y = y
16
+ end
17
+
18
+ def update
19
+ @emitter.update
20
+ end
21
+
22
+ def draw(x, y)
23
+ @emitter.draw(x, y)
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,78 @@
1
+
2
+ require_relative "map_object.rb"
3
+ require_relative "map_animation.rb"
4
+
5
+ module Core::Game
6
+ class Player < MapNPC
7
+
8
+ include Gosu
9
+
10
+ attr_accessor :x, :y
11
+
12
+ def initialize(x=0, y=0)
13
+ super(x, y, {:file => Core.window.state.party.player.charset})
14
+ @speed = 2
15
+ @x, @y = x, y
16
+ @name = "player"
17
+ @gamename = Core.window.state.party.player.name
18
+ end
19
+
20
+ def update
21
+ window = Core.window
22
+ if @dx == 0 and @dy == 0
23
+ if window.button_down?(KbLeft)
24
+ @dx = -32
25
+ @dy = 0
26
+ destroy_goal
27
+ elsif window.button_down?(KbRight)
28
+ @dx = 32
29
+ @dy = 0
30
+ destroy_goal
31
+ elsif window.button_down?(KbUp)
32
+ @dx = 0
33
+ @dy = -32
34
+ destroy_goal
35
+ elsif window.button_down?(KbDown)
36
+ @dx = 0
37
+ @dy = 32
38
+ destroy_goal
39
+ end
40
+ end
41
+ if window.pressed?(KbSpace) or window.pressed?(KbReturn) or window.pressed?(KbEnter)
42
+ update_trigger
43
+ end
44
+ super
45
+ if @stepped
46
+ if @dx < 0
47
+ Core.window.state.map.xoff += @speed
48
+ elsif @dx > 0
49
+ Core.window.state.map.xoff -= @speed
50
+ end
51
+ if @dy < 0
52
+ Core.window.state.map.yoff += @speed
53
+ elsif @dy > 0
54
+ Core.window.state.map.yoff -= @speed
55
+ end
56
+ end
57
+ end
58
+
59
+ def teleport(tx, ty)
60
+ if tx < @tx
61
+ Core.window.state.map.xoff += (@tx - tx) * 32
62
+ elsif @tx < tx
63
+ Core.window.state.map.xoff -= (tx - @tx) * 32
64
+ end
65
+ if ty < @ty
66
+ Core.window.state.map.yoff += (@ty - ty) * 32
67
+ elsif @ty < ty
68
+ Core.window.state.map.yoff -= (ty - @ty) * 32
69
+ end
70
+ @tx = tx
71
+ @ty = ty
72
+ @x = @tx * 32
73
+ @y = @ty * 32
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,35 @@
1
+
2
+ # TODO move to root?
3
+
4
+ module Core::Game
5
+
6
+ class Tile
7
+
8
+ attr_reader :properties
9
+ attr_accessor :x, :y, :z
10
+
11
+ def initialize(sprite, x, y, z, props=[])
12
+ @sprite = sprite
13
+ @x, @y, @z = x, y, z
14
+ if props[:collide]
15
+ @passable = !props[:collide].to_b
16
+ else
17
+ @passable = true
18
+ end
19
+ @properties = props
20
+ end
21
+
22
+ def draw(x, y)
23
+ if @x + x + 32 < 0 or @y + y + 32 < 0 or @x + x >1024 or @y + y > 768
24
+ return
25
+ end
26
+ @sprite.draw(@x+x, @y+y, @z)
27
+ end
28
+
29
+ def passable?
30
+ return @passable
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,24 @@
1
+
2
+ module Core::Game
3
+ class Thought
4
+ attr_reader :text, :proc
5
+ def initialize(text, proc)
6
+ @text, @proc = text, proc
7
+ end
8
+ end
9
+
10
+ class Mind
11
+ def initialize
12
+ @thoughts = []
13
+ end
14
+ def contrive(thought)
15
+ @thoughts.push(thought)
16
+ end
17
+ def forget(thought)
18
+ @thoughts.delete(thought)
19
+ end
20
+ def thoughts
21
+ return @thoughts
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+
2
+ require_relative "task.rb"
3
+ require_relative "../map/map_particle.rb"
4
+
5
+ module Core::Game::NPC
6
+
7
+ class Behaviour
8
+
9
+ attr_reader :init, :trigger, :motion, :update
10
+
11
+ def initialize(npc, init, trigger, motion, update)
12
+ @self = npc
13
+ @init = init
14
+ @trigger = trigger
15
+ @motion = motion
16
+ @update = update
17
+ end
18
+
19
+ def on_init
20
+ exec_task(@init)
21
+ @self.goal.reset
22
+ exec_task(@motion)
23
+ end
24
+
25
+ def on_trigger(other)
26
+ exec_task(@trigger, other)
27
+ end
28
+
29
+ def on_update
30
+ exec_task(@update)
31
+ exec_task(@motion)
32
+ end
33
+
34
+ def exec_task(task, other=nil)
35
+ task.execute(@self, other) if !task.finished?
36
+ if task.finished?
37
+ if task.remove?
38
+ task = nil
39
+ end
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,28 @@
1
+
2
+ module Core::Game
3
+
4
+ class Bubble < Core::GUI::Textfield
5
+
6
+ def initialize(text)
7
+ super(0, 0, 0, 0, text, 20, :left, false, 256)
8
+ @age = text.gsub("\n", "").size * Core.config[:text_speed]
9
+ end
10
+
11
+ def update
12
+ if @age <= 0
13
+ @remove = true
14
+ else
15
+ @age -= 1
16
+ end
17
+ end
18
+
19
+ def draw(x, y)
20
+ @x, @y = x-(@w/2)+16, y-40-@h
21
+ super()
22
+ c = Gosu::Color::GREEN
23
+ Core.window.draw_triangle(@x+(@w/2)-4, @y+@h, c, @x+(@w/2)+4, @y+@h, c, @x+(@w/2), @y+@h+24, c, Core::MAPOBJECT_Z+100)
24
+ end
25
+
26
+ end
27
+
28
+ end