-
Notifications
You must be signed in to change notification settings - Fork 4
/
input.lua
101 lines (64 loc) · 1.2 KB
/
input.lua
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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
-- set mouse and keyboard options
function input_init()
mo.setVisible(false)
ke.setKeyRepeat(.1, .1)
end
function input_stream(dt)
-- stabilize dt
local dt = dt < .1 and dt or .1
if ke.isDown("r")
and factor_h/factor_w < 2 then
camera_rotate(1, dt)
elseif ke.isDown("e")
and factor_h/factor_w > 1/2 then
camera_rotate(-1, dt)
end
if ke.isDown("t")
and zoom < 2 then
camera_zoom(1, dt)
elseif ke.isDown("y")
and zoom > 1/2 then
camera_zoom(-1, dt)
end
end
function input_keypressed(k)
if k == "d" then
player:move(0, 0, 1)
elseif k == "s" then
player:move(0, 0, -1)
end
if k == "right" then
player:move(1, 0, 0)
elseif k == "left" then
player:move(-1, 0, 0)
end
if k == "down" then
player:move(0, 1, 0)
elseif k == "up" then
player:move(0, -1, 0)
end
if k == "escape"
or k == "return" then
love.event.quit()
end
-- set camera var to default
if k == "f" then
factor_w,
factor_h,
factor_z,
zoom = nil
tile_update()
end
if k == "g" then
switch_light = not switch_light
end
if k == "h" then
switch_line = not switch_line
end
if k == "j" then
map_rotate(-1)
end
if k == "k" then
map_rotate(1)
end
end