-
Notifications
You must be signed in to change notification settings - Fork 0
/
Princess.rb
47 lines (37 loc) · 1.16 KB
/
Princess.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
require './princess/room'
require './princess/outside'
require './princess/inside'
class ThroneRoom < Room
def setup_room
@name = "throne"
@princess = image :left => 110, :top => @app.height - 300, :width => 100
@princess.path = File.expand_path("~/.hacketyhack/princess/princess.jpg")
@king = image :left => 650, :top => @app.height - 300, :width => 100, :height => 180
@king.path = File.expand_path("~/.hacketyhack/princess/king.jpg")
@queen = image :left => 800, :top => @app.height - 300, :width => 100
@queen.path = File.expand_path("~/.hacketyhack/princess/queen.jpg")
@door = rect :fill => blue, :left => 10, :top => 420, :width => 100, :height => 250
rect :fill => red, :left => 0, :top => 670, :width => @app.width
end
def can_act?
in_door?
end
def in_door?
princess.left < (@door.left + @door.width)
end
def act!
if in_door?
Room.show("inside")
end
end
end
Shoes.app :width => 1000, :height => 800 do
Room.list.clear
@outside = Outside.new(self)
@inside = Inside.new(self)
@throne = ThroneRoom.new(self)
Room.show("outside")
keypress do |key|
Room.current.keypress(key)
end
end