44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/robotsfindkitten/client.rb', line 44
def start
Curses.init_screen
Curses.start_color
Curses.crmode
Curses.noecho
Curses.stdscr.keypad = true
Curses.curs_set(0)
Curses.clear
Curses.setpos(0, 0)
Curses.addstr(<<eos)
robotsfindkitten #{RobotsFindKitten::VERSION}
By the illustrious Rob Steward (C) 2014
Based on robotfindskitten by Leonard Richardson
In this game, you are robot (#). Your job is to find kitten. This task
is complicated by the existence of various things which are not kitten.
Robot must touch items to determine if they are kitten or not. The game
does not end when robotfindskitten. You may end the game by hitting the
q key or a good old-fashioned Ctrl-C.
See the documentation for more information.
Press any key to start.
eos
Curses.getch
Curses.clear
Curses.timeout = 0
update_interval = 1.0 / 60.0
until @exit
start_time = Time.now
update
draw
input
end_time = Time.now
diff = (end_time - start_time)
if start_time <= end_time && diff < update_interval
sleep(update_interval - diff)
end
end
ensure
@server.leave(@robot)
Curses.close_screen
end
|