-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouse.rb
43 lines (36 loc) · 948 Bytes
/
mouse.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
class Mouse
SPEED = 30000
def initialize (window)
@window = window
@vehicle_vertical = @vehicle_horizontal = 0
end
def update (key_input = nil)
vehicle_vertical = vehicle_horizontal = 0
fire_main = triple_shot = false
if key_input == Gosu::MsLeft then
fire_main = true
end
if key_input == Gosu::MsRight then
triple_shot = true
end
if @window.button_down? Gosu::KbW then
vehicle_vertical = -SPEED
end
if @window.button_down? Gosu::KbA then
vehicle_horizontal = -SPEED
end
if @window.button_down? Gosu::KbS then
vehicle_vertical = SPEED
end
if @window.button_down? Gosu::KbD then
vehicle_horizontal = SPEED
end
return {input: :mouse,
actions: {
fire_main: fire_main,
triple_shot: triple_shot,
movement_crosshair: {horizontal: @window.mouse_x, vertical: @window.mouse_y},
movement_vehicle: {horizontal: vehicle_horizontal, vertical: vehicle_vertical}
}}
end
end