-
Notifications
You must be signed in to change notification settings - Fork 4
/
Shot.rb
45 lines (38 loc) · 886 Bytes
/
Shot.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
#
# Shot.rb
# The Flying Camera
#
# Created by Thomas R. Koll on 12.12.10.
# Copyright (c) 2010 ananasblau. All rights reserved.
#
class Shot
include Movable
include Placable
attr_accessor :x, :y, :orientation
def initialize(x,y,orientation)
self.x = x
self.y = y
self.z = 0
self.speed = 20
self.orientation = orientation
# NSSound.soundNamed('Ping').play
end
def redraw
glPushMatrix
# shot is leaving view field
out_of_view = self.x > 1 || self.x < -1 || self.y > 1 || self.y < -1
place
self.move(0)
glColor3f(1,1,1)
glBegin(GL_QUADS)
glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( 0.0, 0.002, 0.0);
glVertex3f(-0.002, 0.002, 0.0);
glVertex3f(-0.002, 0.0, 0.0);
glVertex3f( 0.0, 0.0, 0.0);
glEnd
glPopMatrix
return nil if out_of_view
return self
end
end