essytas 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README +3 -0
- data/Rakefile +44 -0
- data/bin/essytas +2 -0
- data/lib/animation.rb +74 -0
- data/lib/config.rb +63 -0
- data/lib/core.rb +242 -0
- data/lib/cursor.rb +43 -0
- data/lib/def/animations/explosion1.anim +103 -0
- data/lib/def/characters.def +132 -0
- data/lib/def/de/dialogues/test.dlg +4 -0
- data/lib/def/de/enemies.trans +6 -0
- data/lib/def/de/items.trans +84 -0
- data/lib/def/de/skills.trans +48 -0
- data/lib/def/de/spells.trans +31 -0
- data/lib/def/en/dialogues/test.dlg +4 -0
- data/lib/def/en/enemies.trans +6 -0
- data/lib/def/en/items.trans +78 -0
- data/lib/def/en/skills.trans +48 -0
- data/lib/def/en/spells.trans +31 -0
- data/lib/def/enemies.def +8 -0
- data/lib/def/enemies/wolf.bhv +11 -0
- data/lib/def/init.def +5 -0
- data/lib/def/items.def +153 -0
- data/lib/def/loot.def +2 -0
- data/lib/def/particles.def +66 -0
- data/lib/def/recipies.def +18 -0
- data/lib/def/skills.def +40 -0
- data/lib/def/spells.def +42 -0
- data/lib/def/spells.rb +16 -0
- data/lib/def/weapons.def +9 -0
- data/lib/ext/astar/AMap.rb +146 -0
- data/lib/ext/astar/node.rb +72 -0
- data/lib/ext/astar/priority_queue.rb +44 -0
- data/lib/ext/shader.rb +116 -0
- data/lib/game/alchemy/recipe.rb +26 -0
- data/lib/game/character.rb +102 -0
- data/lib/game/combat/bar.rb +119 -0
- data/lib/game/combat/battle.rb +345 -0
- data/lib/game/combat/control.rb +18 -0
- data/lib/game/combat/gui.rb +190 -0
- data/lib/game/combat/gui/select_item.rb +11 -0
- data/lib/game/combat/gui/select_spell.rb +38 -0
- data/lib/game/constitution.rb +48 -0
- data/lib/game/equipment.rb +34 -0
- data/lib/game/inventory.rb +37 -0
- data/lib/game/item.rb +54 -0
- data/lib/game/magic.rb +33 -0
- data/lib/game/map/events.rb +29 -0
- data/lib/game/map/fog.rb +41 -0
- data/lib/game/map/map.rb +247 -0
- data/lib/game/map/map_animation.rb +26 -0
- data/lib/game/map/map_loader.rb +177 -0
- data/lib/game/map/map_object.rb +208 -0
- data/lib/game/map/map_particle.rb +27 -0
- data/lib/game/map/player.rb +78 -0
- data/lib/game/map/tile.rb +35 -0
- data/lib/game/mind.rb +24 -0
- data/lib/game/npc/behaviour.rb +45 -0
- data/lib/game/npc/bubble.rb +28 -0
- data/lib/game/npc/goal.rb +93 -0
- data/lib/game/npc/npc.rb +95 -0
- data/lib/game/npc/task.rb +73 -0
- data/lib/game/osd/magic.rb +24 -0
- data/lib/game/party.rb +42 -0
- data/lib/game/skills.rb +64 -0
- data/lib/game/spell.rb +35 -0
- data/lib/game_window.rb +95 -0
- data/lib/glsl/contrast.frag +12 -0
- data/lib/glsl/fade.frag +11 -0
- data/lib/glsl/mezzotint.frag +20 -0
- data/lib/glsl/noise.frag +20 -0
- data/lib/glsl/pixelate.frag +42 -0
- data/lib/glsl/radialblur.frag +28 -0
- data/lib/glsl/sepia.frag +15 -0
- data/lib/glsl/shockwave.frag +24 -0
- data/lib/glsl/tv_screen.frag +17 -0
- data/lib/graphics/animations/credits.txt +1 -0
- data/lib/graphics/animations/explosion2.png +0 -0
- data/lib/graphics/backgrounds/white_ties_grass.png +0 -0
- data/lib/graphics/chars/ejera.png +0 -0
- data/lib/graphics/chars/salyjea.png +0 -0
- data/lib/graphics/chars/tharat.png +0 -0
- data/lib/graphics/combat/tharat.png +0 -0
- data/lib/graphics/cursors/normal.png +0 -0
- data/lib/graphics/fog/clouds1.png +0 -0
- data/lib/graphics/gui/bar_center.png +0 -0
- data/lib/graphics/gui/bar_left.png +0 -0
- data/lib/graphics/gui/bar_right.png +0 -0
- data/lib/graphics/gui/button_background.png +0 -0
- data/lib/graphics/gui/button_close.png +0 -0
- data/lib/graphics/gui/button_close_hi.png +0 -0
- data/lib/graphics/gui/button_highlight.png +0 -0
- data/lib/graphics/gui/charequip_background.png +0 -0
- data/lib/graphics/gui/charselect_background.png +0 -0
- data/lib/graphics/gui/container_background.png +0 -0
- data/lib/graphics/gui/drop_item.png +0 -0
- data/lib/graphics/gui/equip_Etarae.png +0 -0
- data/lib/graphics/gui/equip_Mensch.png +0 -0
- data/lib/graphics/gui/equipslot_background.png +0 -0
- data/lib/graphics/gui/iteminfo_background.png +0 -0
- data/lib/graphics/gui/msg_background.png +0 -0
- data/lib/graphics/gui/scrollbar_background.png +0 -0
- data/lib/graphics/gui/scroller.png +0 -0
- data/lib/graphics/gui/tile_32.png +0 -0
- data/lib/graphics/gui/tile_32_highlight.png +0 -0
- data/lib/graphics/icons/items/arrow.png +0 -0
- data/lib/graphics/icons/items/bandage.png +0 -0
- data/lib/graphics/icons/items/boots_leather.png +0 -0
- data/lib/graphics/icons/items/bow.png +0 -0
- data/lib/graphics/icons/items/credits.txt +8 -0
- data/lib/graphics/icons/items/harness_leather.png +0 -0
- data/lib/graphics/icons/items/knife.png +0 -0
- data/lib/graphics/icons/items/shirt_linen.png +0 -0
- data/lib/graphics/items/none.png +0 -0
- data/lib/graphics/menu/ingame_background.png +0 -0
- data/lib/graphics/menu/ingame_background.xcf +0 -0
- data/lib/graphics/menu/start_background.png +0 -0
- data/lib/graphics/missing.png +0 -0
- data/lib/graphics/osd/magic_bg.png +0 -0
- data/lib/graphics/particles/leaf.png +0 -0
- data/lib/graphics/particles/smoke.png +0 -0
- data/lib/graphics/pixel.png +0 -0
- data/lib/graphics/tiles/test.png +0 -0
- data/lib/gui/base.rb +278 -0
- data/lib/gui/button.rb +93 -0
- data/lib/gui/char_equip.rb +118 -0
- data/lib/gui/char_selector.rb +54 -0
- data/lib/gui/context_menu.rb +115 -0
- data/lib/gui/draggable.rb +18 -0
- data/lib/gui/grid.rb +118 -0
- data/lib/gui/image.rb +17 -0
- data/lib/gui/inventory.rb +42 -0
- data/lib/gui/item_info.rb +33 -0
- data/lib/gui/slider.rb +10 -0
- data/lib/gui/textfield.rb +57 -0
- data/lib/layer.rb +64 -0
- data/lib/load.rb +31 -0
- data/lib/main.rb +18 -0
- data/lib/maps/def/test.bhv +26 -0
- data/lib/maps/def/test.rb +14 -0
- data/lib/maps/test.tmx +133 -0
- data/lib/maps/test2.tmx +94 -0
- data/lib/maps/test3.tmx +29 -0
- data/lib/maps/test3_lower.tmx +25 -0
- data/lib/maps/test3_upper.tmx +25 -0
- data/lib/maps/test_left.tmx +25 -0
- data/lib/maps/test_upper.tmx +25 -0
- data/lib/music/Butterfly Tea - A New Hope 2K11.mp3 +0 -0
- data/lib/music/Greendjohn - Rebirth.mp3 +0 -0
- data/lib/music/credits.txt +8 -0
- data/lib/parse.rb +605 -0
- data/lib/parse_tmx.rb +114 -0
- data/lib/particles.rb +127 -0
- data/lib/sample.rb +29 -0
- data/lib/save.rb +44 -0
- data/lib/song.rb +41 -0
- data/lib/sounds/click1.wav +0 -0
- data/lib/sounds/credits.txt +2 -0
- data/lib/sounds/error1.wav +0 -0
- data/lib/sprite.rb +35 -0
- data/lib/states/menus.rb +17 -0
- data/lib/states/menus/alchemy.rb +53 -0
- data/lib/states/menus/equip.rb +79 -0
- data/lib/states/menus/ingame.rb +34 -0
- data/lib/states/menus/magic.rb +31 -0
- data/lib/states/menus/options.rb +54 -0
- data/lib/states/menus/start.rb +38 -0
- data/lib/states/states.rb +154 -0
- data/lib/tileset.rb +42 -0
- data/lib/tools/world.rb +103 -0
- data/lib/tools/worldmap_editor.rb +221 -0
- data/lib/translate.rb +368 -0
- metadata +255 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Rylius Kejides (ryliusk@gmail.com)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rubygems/package_task'
|
6
|
+
require 'rdoc/task'
|
7
|
+
|
8
|
+
spec = Gem::Specification.new do |s|
|
9
|
+
s.name = 'essytas'
|
10
|
+
s.version = '0.0.1'
|
11
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
12
|
+
s.summary = "2D open world RPG"
|
13
|
+
s.description = "The game takes place in a huge fictional world, \'Essytas\'. Unlike other games, your goal is not to rescue the world from all evil but to lead a young man and his family through their lives. Your decisions control the fate of the characters.
|
14
|
+
As you may have guessed, there isn\'t a real storyline. Instead, not long into the game a fire will destroy your village, forcing you to find a new shelter. What happens next is completely up to you.
|
15
|
+
The game doesn\'t have an end, it ends when your character dies."
|
16
|
+
s.authors = ['Rylius Kejides']
|
17
|
+
s.email = 'ryliusk@gmail.com'
|
18
|
+
s.homepage = 'http://rylius.hazewood.de/wp/essytas/'
|
19
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
20
|
+
s.require_path = "lib"
|
21
|
+
s.bindir = "bin"
|
22
|
+
s.platform = Gem::Platform::RUBY
|
23
|
+
s.add_development_dependency("awesome_print")
|
24
|
+
s.add_runtime_dependency("gosu", "~> 0.7", ">= 0.7.0")
|
25
|
+
s.required_ruby_version = '>= 1.9.2'
|
26
|
+
s.requirements.push("1 GHz processor")
|
27
|
+
s.requirements.push("Decent graphics card")
|
28
|
+
s.license = "MIT"
|
29
|
+
s.executables.push("essytas")
|
30
|
+
end
|
31
|
+
|
32
|
+
Gem::PackageTask.new(spec) do |p|
|
33
|
+
p.gem_spec = spec
|
34
|
+
p.need_tar = true
|
35
|
+
end
|
36
|
+
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
files =['README', 'LICENSE', 'lib/**/*.rb']
|
39
|
+
rdoc.rdoc_files.add(files)
|
40
|
+
rdoc.main = "README" # page to start on
|
41
|
+
rdoc.title = "Essytas Documentation"
|
42
|
+
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
43
|
+
rdoc.options << '--line-numbers'
|
44
|
+
end
|
data/bin/essytas
ADDED
data/lib/animation.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
module Core
|
3
|
+
|
4
|
+
def self.animations
|
5
|
+
return @animations
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.animations=(hsh)
|
9
|
+
@animations = hsh
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.anim(anim)
|
13
|
+
return animations[anim].clone
|
14
|
+
end
|
15
|
+
|
16
|
+
class Animation
|
17
|
+
attr_accessor :x, :y
|
18
|
+
def initialize(graphic, sx, sy, repeat, frames)
|
19
|
+
@anim_frames = Core.tiles("animations/#{graphic}", sx, sy, false)
|
20
|
+
@repeat = repeat
|
21
|
+
@frames = frames
|
22
|
+
@index = 0
|
23
|
+
@time = 0
|
24
|
+
@x, @y = 0
|
25
|
+
@remove = false
|
26
|
+
end
|
27
|
+
|
28
|
+
def frame
|
29
|
+
return @frames[@index]
|
30
|
+
end
|
31
|
+
|
32
|
+
def play(x, y, z)
|
33
|
+
@x, @y, @z = x, y, z
|
34
|
+
end
|
35
|
+
|
36
|
+
def draw
|
37
|
+
return if remove?
|
38
|
+
@anim_frames[@index].draw(@x + frame.x, @y + frame.y, @z, 1, 1, frame.color, frame.mode)
|
39
|
+
@time += 1
|
40
|
+
if @time >= frame.length
|
41
|
+
@time = 0
|
42
|
+
next_frame
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def remove?
|
47
|
+
return @remove
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def next_frame
|
53
|
+
@index += 1
|
54
|
+
if @index >= @frames.size
|
55
|
+
if @repeat
|
56
|
+
@index = 0
|
57
|
+
else
|
58
|
+
@remove = true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class Frame
|
65
|
+
attr_reader :length, :color, :x, :y, :mode
|
66
|
+
def initialize
|
67
|
+
@length = 1
|
68
|
+
@color = Gosu::Color::WHITE
|
69
|
+
@x, @y = 0, 0
|
70
|
+
@mode = :default
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/lib/config.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
|
2
|
+
module Core
|
3
|
+
|
4
|
+
class Config
|
5
|
+
|
6
|
+
attr_reader :hash
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@hash = {
|
10
|
+
:opengl => true,
|
11
|
+
:language => "de",
|
12
|
+
:volume => 0.5, # 0 = normal, 1 = twice as loud
|
13
|
+
:contrast => 1.0, # 1.0 = off
|
14
|
+
:log => true, # whether to log to file or print everything on stdout
|
15
|
+
:text_speed => 5, # higher = slower
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def load(file=Core::DEFAULT_CONFIG)
|
20
|
+
if !File.exists?(Core::HOME_PATH + file)
|
21
|
+
File.new(Core::HOME_PATH + file, "w")
|
22
|
+
else
|
23
|
+
if File.size(Core::HOME_PATH + file) > 0
|
24
|
+
begin
|
25
|
+
@hash = Marshal.load(File.open(Core::HOME_PATH + file, "r"))
|
26
|
+
validate
|
27
|
+
rescue TypeError
|
28
|
+
puts("WARNING: Corrupted config file (#{file}), reverting to default")
|
29
|
+
rescue NoMethodError # this is likely caused by outdated configs
|
30
|
+
warn("WARNING: Config file #{file} is outdated, deleting")
|
31
|
+
File.delete(Core::HOME_PATH + file)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def save(file=Core::DEFAULT_CONFIG)
|
38
|
+
validate
|
39
|
+
Marshal.dump(@hash, File.open(Core::HOME_PATH + file, "w"))
|
40
|
+
rescue NoMethodError # this is likely caused by outdated configs
|
41
|
+
warn("WARNING: Config file #{file} is outdated, deleting")
|
42
|
+
File.delete(Core::HOME_PATH + file)
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate
|
46
|
+
if !["en", "de"].include?(@hash[:language])
|
47
|
+
@hash[:language] = "de"
|
48
|
+
end
|
49
|
+
vol = @hash[:volume]
|
50
|
+
if vol < 0
|
51
|
+
@hash[:volume] = 0.0
|
52
|
+
elsif vol > 1
|
53
|
+
@hash[:volume] = 1.0
|
54
|
+
end
|
55
|
+
speed = @hash[:text_speed]
|
56
|
+
if speed < 1
|
57
|
+
@hash[:text_speed] = 1
|
58
|
+
elsif speed > 10
|
59
|
+
@hash[:text_speed] = 10
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/core.rb
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
|
2
|
+
# General system interface and common convenience functions
|
3
|
+
|
4
|
+
require "gosu"
|
5
|
+
|
6
|
+
# Main entrance point of the engine
|
7
|
+
module Core
|
8
|
+
# Source locations
|
9
|
+
LIBRARY_PATH = File.dirname(__FILE__)
|
10
|
+
# For storing saves and updates in case the source folder is write protected
|
11
|
+
HOME_PATH = "#{ENV["HOME"]}/.essytas/"
|
12
|
+
if !File.directory?(HOME_PATH)
|
13
|
+
Dir.mkdir("#{ENV["HOME"]}/.essytas")
|
14
|
+
end
|
15
|
+
if !File.directory?("#{HOME_PATH}saves")
|
16
|
+
Dir.mkdir("#{HOME_PATH}saves")
|
17
|
+
end
|
18
|
+
SAVE_DIR = "#{HOME_PATH}saves/"
|
19
|
+
|
20
|
+
VERSION = 0.1
|
21
|
+
RELEASE = false
|
22
|
+
|
23
|
+
#--
|
24
|
+
# Game
|
25
|
+
MAP_Z = 1
|
26
|
+
MAPOBJECT_Z = 50
|
27
|
+
CURSOR_Z = 1000000
|
28
|
+
GUI_Z = 9999
|
29
|
+
PARTICLE_Z = 5000
|
30
|
+
FOG_Z = 6000
|
31
|
+
|
32
|
+
DEFAULT_FONT = "arial"
|
33
|
+
|
34
|
+
DEFAULT_CONFIG = "default.cfg"
|
35
|
+
|
36
|
+
def self.silently(&block)
|
37
|
+
lvl = $VERBOSE
|
38
|
+
$VERBOSE = nil
|
39
|
+
result = block.call
|
40
|
+
$VERBOSE = lvl
|
41
|
+
return result
|
42
|
+
end
|
43
|
+
|
44
|
+
@window = nil
|
45
|
+
# Returns the global Gosu::Window instance
|
46
|
+
def self.window
|
47
|
+
return @window
|
48
|
+
end
|
49
|
+
# Globally sets the Gosu::Window instance
|
50
|
+
def self.window=(w)
|
51
|
+
@window = w
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.inside?(x, y, startx, starty, endx, endy)
|
55
|
+
if x >= startx && x < endx && y >= starty && y < endy
|
56
|
+
return true
|
57
|
+
end
|
58
|
+
return false
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.mouse_inside?(x, y, ex, ey)
|
62
|
+
return inside?(Core.window.mouse_x, Core.window.mouse_y, x, y, ex, ey)
|
63
|
+
end
|
64
|
+
|
65
|
+
# a between b and c
|
66
|
+
def self.between?(a, b, c)
|
67
|
+
if a > b and a < c
|
68
|
+
return true
|
69
|
+
end
|
70
|
+
return false
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.multiline(text, width, font)
|
74
|
+
ret = []
|
75
|
+
lines = text.split("\n")
|
76
|
+
lines.each { |line|
|
77
|
+
ary = line.split(" ")
|
78
|
+
str = ""
|
79
|
+
ary.each { |word|
|
80
|
+
if font.text_width(str + word) < width - 18
|
81
|
+
str += "#{word} "
|
82
|
+
else
|
83
|
+
str.rstrip!
|
84
|
+
if str != ""
|
85
|
+
ret.push(str)
|
86
|
+
end
|
87
|
+
str = "#{word} "
|
88
|
+
end
|
89
|
+
if word == ary.last
|
90
|
+
str.rstrip!
|
91
|
+
ret.push(str)
|
92
|
+
end
|
93
|
+
}
|
94
|
+
}
|
95
|
+
return ret
|
96
|
+
end
|
97
|
+
|
98
|
+
@@fonts = {}
|
99
|
+
|
100
|
+
# Returns a cached font instance
|
101
|
+
def self.font(name, size)
|
102
|
+
if @@fonts["#{name}-#{size}".to_sym]
|
103
|
+
return @@fonts["#{name}-#{size}".to_sym]
|
104
|
+
else
|
105
|
+
@@fonts["#{name}-#{size}".to_sym] = Gosu::Font.new(Core.window, name, size)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
require_relative "config.rb"
|
110
|
+
|
111
|
+
@config = Config.new
|
112
|
+
@config.load
|
113
|
+
def self.config
|
114
|
+
return @config.hash
|
115
|
+
end
|
116
|
+
|
117
|
+
if RELEASE
|
118
|
+
if config[:log]
|
119
|
+
puts("INFO: Redirecting further output to log files")
|
120
|
+
$stdout.reopen("#{Core::HOME_PATH}/info.log", "w")
|
121
|
+
$stderr.reopen("#{Core::HOME_PATH}/error.log", "w")
|
122
|
+
end
|
123
|
+
if $DEBUG
|
124
|
+
$DEBUG = false
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
begin
|
129
|
+
require "gl"
|
130
|
+
rescue LoadError
|
131
|
+
warn("WARNING: OpenGL gem not found, disabling shader support")
|
132
|
+
config[:opengl] = false
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
# Graceful exit
|
137
|
+
def self.exit(int)
|
138
|
+
@config.save
|
139
|
+
puts("INFO: Shutting down")
|
140
|
+
Kernel.exit(int)
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
begin
|
146
|
+
require "awesome_print"
|
147
|
+
rescue LoadError
|
148
|
+
puts("INFO: awesome_print gem not found, using 'inspect' fallback")
|
149
|
+
def awesome_print(obj)
|
150
|
+
puts(obj.inspect)
|
151
|
+
end
|
152
|
+
alias ap awesome_print
|
153
|
+
end
|
154
|
+
|
155
|
+
# Few helper functions
|
156
|
+
class Numeric
|
157
|
+
def even?
|
158
|
+
if self % 2 == 0
|
159
|
+
return true
|
160
|
+
end
|
161
|
+
return false
|
162
|
+
end
|
163
|
+
def to_b
|
164
|
+
if self == 0
|
165
|
+
return false
|
166
|
+
else
|
167
|
+
return true
|
168
|
+
end
|
169
|
+
end
|
170
|
+
def inc
|
171
|
+
+ 1
|
172
|
+
end
|
173
|
+
def dec
|
174
|
+
- 1
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
class String
|
179
|
+
def to_b
|
180
|
+
if self == "true"
|
181
|
+
return true
|
182
|
+
else
|
183
|
+
return false
|
184
|
+
end
|
185
|
+
end
|
186
|
+
def to_pos
|
187
|
+
ary = []
|
188
|
+
ary.push(self.gsub(/\|\d+/, "").to_i)
|
189
|
+
ary.push(self.gsub(/\d+\|/, "").to_i)
|
190
|
+
return ary
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
class TrueClass
|
195
|
+
def to_i
|
196
|
+
return 1
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
class FalseClass
|
201
|
+
def to_i
|
202
|
+
return 0
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
class Array
|
207
|
+
def to_color
|
208
|
+
return Gosu::Color.new(self[0], self[1], self[2], self[3])
|
209
|
+
end
|
210
|
+
def x
|
211
|
+
return self[0]
|
212
|
+
end
|
213
|
+
def y
|
214
|
+
return self[1]
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
class Object
|
219
|
+
alias ivg instance_variable_get
|
220
|
+
alias ivs instance_variable_set
|
221
|
+
end
|
222
|
+
|
223
|
+
puts("INFO: Loaded core module (v#{Core::VERSION})\nINFO: LIB #{Core::LIBRARY_PATH}\nINFO: HOME #{Core::HOME_PATH}")
|
224
|
+
|
225
|
+
if !File.exists?("#{Core::LIBRARY_PATH}/graphics/missing.png")
|
226
|
+
puts("FATAL: Couldn't find graphics, exiting.")
|
227
|
+
Core.exit(1)
|
228
|
+
end
|
229
|
+
|
230
|
+
require_relative "translate.rb"
|
231
|
+
require_relative "parse.rb"
|
232
|
+
require_relative "parse_tmx.rb"
|
233
|
+
require_relative "sample.rb"
|
234
|
+
require_relative "song.rb"
|
235
|
+
require_relative "sprite.rb"
|
236
|
+
require_relative "gui/base.rb"
|
237
|
+
require_relative "states/menus.rb"
|
238
|
+
require_relative "game/map/player.rb"
|
239
|
+
require_relative "game/npc/npc.rb"
|
240
|
+
require_relative "game/combat/battle.rb"
|
241
|
+
require_relative "save.rb"
|
242
|
+
require_relative "load.rb"
|