-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor.rb
executable file
·57 lines (46 loc) · 1 KB
/
editor.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'rubygems'
require 'gosu'
require 'level.rb'
class EditorWindow < Gosu::Window
def initialize
super(864, 672, false)
self.caption = "MouseTrap Mania"
@level = Level.new(self,ARGV[0])
@pointer = Gosu::Image.new(self, "resources/pointer.png", true)
@font = Gosu::Font.new(self, Gosu::default_font_name, 20)
end
def update
end
def draw
@level.draw
@pointer.draw(mouse_x,mouse_y,0)
end
def button_down(id)
case id
when Gosu::Button::KbEscape
close
when 1 #this is 's', I do not understand why
@level.save
when 37 #this is 'l'
@level.load
draw
when Gosu::Button::MsLeft
c = mouse_x.to_i / 48
r = mouse_y.to_i / 48
@level.toggle(c,r,'l')
@level.cache_tiles
when Gosu::Button::MsRight
c = mouse_x.to_i / 48
r = mouse_y.to_i / 48
@level.toggle(c,r,'r')
@level.cache_tiles
end
end
end
#PROGRAM START
if ARGV[0].nil? then
puts "Usage: ruby editor.rb <levelname>"
else
window = EditorWindow.new
window.show
end