author_engine 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +7 -0
- data/API.md +81 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +26 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +10 -0
- data/SAVEFILE.md +23 -0
- data/assets/fonts/Connection.otf +0 -0
- data/assets/fonts/ConnectionBold.otf +0 -0
- data/assets/fonts/README.md +3 -0
- data/assets/fonts/SIL Open Font License.txt +94 -0
- data/assets/ui/bucket_icon.png +0 -0
- data/assets/ui/code_icon.png +0 -0
- data/assets/ui/error_icon.png +0 -0
- data/assets/ui/level_icon.png +0 -0
- data/assets/ui/loading_icon.png +0 -0
- data/assets/ui/lock_icon.png +0 -0
- data/assets/ui/pencil_icon.png +0 -0
- data/assets/ui/play_icon.png +0 -0
- data/assets/ui/sprite_icon.png +0 -0
- data/assets/ui/unlock_icon.png +0 -0
- data/author_engine.gemspec +41 -0
- data/bin/author_engine +4 -0
- data/lib/author_engine/button.rb +154 -0
- data/lib/author_engine/code_editor/cursor.rb +339 -0
- data/lib/author_engine/code_editor/highlighting.rb +49 -0
- data/lib/author_engine/container.rb +24 -0
- data/lib/author_engine/containers/editor.rb +97 -0
- data/lib/author_engine/containers/loader.rb +105 -0
- data/lib/author_engine/game/game.rb +26 -0
- data/lib/author_engine/game/parts/colors.rb +59 -0
- data/lib/author_engine/game/parts/common.rb +13 -0
- data/lib/author_engine/game/parts/graphics.rb +41 -0
- data/lib/author_engine/game/parts/input.rb +25 -0
- data/lib/author_engine/image.rb +53 -0
- data/lib/author_engine/palette.rb +114 -0
- data/lib/author_engine/save_file.rb +134 -0
- data/lib/author_engine/sprite.rb +4 -0
- data/lib/author_engine/sprite_picker.rb +154 -0
- data/lib/author_engine/support.rb +22 -0
- data/lib/author_engine/text.rb +41 -0
- data/lib/author_engine/version.rb +3 -0
- data/lib/author_engine/view.rb +55 -0
- data/lib/author_engine/views/code_editor.rb +154 -0
- data/lib/author_engine/views/level_editor.rb +7 -0
- data/lib/author_engine/views/play_viewer.rb +163 -0
- data/lib/author_engine/views/sprite_editor.rb +333 -0
- data/lib/author_engine/window.rb +132 -0
- data/lib/author_engine.rb +32 -0
- data/test_3.authorengine +519 -0
- data/testing.authorengine +578 -0
- metadata +169 -0
@@ -0,0 +1,132 @@
|
|
1
|
+
class AuthorEngine
|
2
|
+
class Window < Gosu::Window
|
3
|
+
def self.instance
|
4
|
+
@instance
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.instance=(_instance)
|
8
|
+
@instance = _instance
|
9
|
+
end
|
10
|
+
|
11
|
+
VIEW_WIDTH, VIEW_HEIGHT, SIZE = 128.0, 128.0, 128.0
|
12
|
+
|
13
|
+
attr_accessor :show_cursor
|
14
|
+
attr_reader :scale_x, :scale_y, :square_scale, :base_size, :container, :sprite_size
|
15
|
+
def initialize
|
16
|
+
super(512, 512, fullscreen: false)
|
17
|
+
super(512, 512, fullscreen: true) if ARGV.join.include?("--fullscreen")
|
18
|
+
# super(1280, 800, fullscreen: false)
|
19
|
+
super(Gosu.screen_width, Gosu.screen_height, fullscreen: true) if ARGV.join.include?("--native")
|
20
|
+
|
21
|
+
Window.instance = self
|
22
|
+
@container = nil
|
23
|
+
@show_cursor = true
|
24
|
+
@scale_x = 1.0
|
25
|
+
@scale_y = 1.0
|
26
|
+
@square_scale = 1.0
|
27
|
+
@base_size = SIZE
|
28
|
+
|
29
|
+
@sprite_size = 16
|
30
|
+
|
31
|
+
@close_counter = 0
|
32
|
+
|
33
|
+
calculate_scale
|
34
|
+
setup
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup
|
38
|
+
self.container=(Loader.new)
|
39
|
+
end
|
40
|
+
|
41
|
+
def container=(container)
|
42
|
+
if container.is_a?(Container)
|
43
|
+
@container = container
|
44
|
+
@container.setup
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def calculate_scale
|
49
|
+
warn "Display is to small! (was #{self.width}x#{self.height} minimum is 128x128)" if self.width < 128 || self.height < 128
|
50
|
+
|
51
|
+
@scale_x = (self.width / VIEW_WIDTH)
|
52
|
+
@scale_y = (self.height / VIEW_HEIGHT)
|
53
|
+
|
54
|
+
@square_scale = @scale_y
|
55
|
+
end
|
56
|
+
|
57
|
+
def draw
|
58
|
+
@container.draw
|
59
|
+
end
|
60
|
+
|
61
|
+
def update
|
62
|
+
@container.update
|
63
|
+
end
|
64
|
+
|
65
|
+
def needs_cursor?
|
66
|
+
@show_cursor
|
67
|
+
end
|
68
|
+
|
69
|
+
def lighten(color, amount = 25)
|
70
|
+
if defined?(color.alpha)
|
71
|
+
return Gosu::Color.rgba(color.red+amount, color.green+amount, color.blue+amount, color.alpha)
|
72
|
+
else
|
73
|
+
return Gosu::Color.rgb(color.red+amount, color.green+amount, color.blue+amount)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def darken(color, amount = 25)
|
78
|
+
if defined?(color.alpha)
|
79
|
+
return Gosu::Color.rgba(color.red-amount, color.green-amount, color.blue-amount, color.alpha)
|
80
|
+
else
|
81
|
+
return Gosu::Color.rgb(color.red-amount, color.green-amount, color.blue-amount)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def control_button_down?
|
86
|
+
(Gosu.button_down?(Gosu::KbLeftControl) || Gosu.button_down?(Gosu::KbRightControl))
|
87
|
+
end
|
88
|
+
|
89
|
+
def alt_button_down?
|
90
|
+
(Gosu.button_down?(Gosu::KbLeftAlt) || Gosu.button_down?(Gosu::KbRightAlt))
|
91
|
+
end
|
92
|
+
|
93
|
+
def shift_button_down?
|
94
|
+
(Gosu.button_down?(Gosu::KbLeftShift) || Gosu.button_down?(Gosu::KbRightShift))
|
95
|
+
end
|
96
|
+
|
97
|
+
def save_and_exit
|
98
|
+
if @container.is_a?(Editor)
|
99
|
+
@container.savefile.save
|
100
|
+
end
|
101
|
+
|
102
|
+
close!
|
103
|
+
end
|
104
|
+
|
105
|
+
def close
|
106
|
+
if @container
|
107
|
+
@container.close
|
108
|
+
else
|
109
|
+
super
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def button_down(id)
|
114
|
+
super
|
115
|
+
|
116
|
+
@container.button_down(id)
|
117
|
+
end
|
118
|
+
|
119
|
+
def button_up(id)
|
120
|
+
super
|
121
|
+
|
122
|
+
if id == Gosu::KbEscape
|
123
|
+
@close_counter += 1
|
124
|
+
save_and_exit if @close_counter == 2
|
125
|
+
else
|
126
|
+
@close_counter = 0
|
127
|
+
end
|
128
|
+
|
129
|
+
@container.button_up(id)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "gosu"
|
2
|
+
require "coderay"
|
3
|
+
|
4
|
+
require_relative "author_engine/game/parts/common"
|
5
|
+
require_relative "author_engine/game/parts/graphics"
|
6
|
+
require_relative "author_engine/game/parts/colors"
|
7
|
+
require_relative "author_engine/game/parts/input"
|
8
|
+
|
9
|
+
require_relative "author_engine/window"
|
10
|
+
require_relative "author_engine/support"
|
11
|
+
require_relative "author_engine/container"
|
12
|
+
require_relative "author_engine/view"
|
13
|
+
require_relative "author_engine/button"
|
14
|
+
require_relative "author_engine/text"
|
15
|
+
require_relative "author_engine/sprite"
|
16
|
+
require_relative "author_engine/sprite_picker"
|
17
|
+
require_relative "author_engine/palette"
|
18
|
+
require_relative "author_engine/image"
|
19
|
+
require_relative "author_engine/save_file"
|
20
|
+
|
21
|
+
require_relative "author_engine/game/game"
|
22
|
+
|
23
|
+
require_relative "author_engine/code_editor/cursor"
|
24
|
+
require_relative "author_engine/code_editor/highlighting"
|
25
|
+
|
26
|
+
require_relative "author_engine/containers/editor"
|
27
|
+
require_relative "author_engine/containers/loader"
|
28
|
+
|
29
|
+
require_relative "author_engine/views/play_viewer"
|
30
|
+
require_relative "author_engine/views/sprite_editor"
|
31
|
+
require_relative "author_engine/views/level_editor"
|
32
|
+
require_relative "author_engine/views/code_editor"
|