forked from Metalab/The-Flying-Camera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameWindowController.rb
43 lines (38 loc) · 934 Bytes
/
GameWindowController.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
#
# GameWindowController.rb
# CtF
#
# Created by Thomas R. Koll on 09.12.10.
# Copyright (c) 2010 ananasblau. All rights reserved.
#
framework 'Cocoa'
class GameWindowController < NSWindowController
attr_accessor :view, :game_loop, :fullscreen
def awakeFromNib
# NSSound.soundNamed('Ping').play
self.game_loop = GameLoop.new(self.view)
end
def keyDown(event)
key = event.characters[0].bytes.to_a[-1]
if key == 112
game_loop.stop = !game_loop.stop
puts game_loop.player.score.score
end
if key == 32
game_loop.stop = true
if fullscreen.active
fullscreen.active = false
fullscreen.exit_fullscreen
view.active = true
elsif view.active
view.active = false
fullscreen.go_fullscreen
fullscreen.active true
end
game_loop.stop = false
end
game_loop.player.keyDown(key)
end
def mouse_down(event)
end
end