-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
86 lines (63 loc) · 2.23 KB
/
main.lua
File metadata and controls
86 lines (63 loc) · 2.23 KB
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
w = 1280
h = 720
scale = 10 --pixels per meter
require ("constants")
require ("player")
require ("draw")
function mapKeystoAcceleration()
if keys.up then
player.accel = 6
elseif keys.down then
player.accel = -6
else
player.accel = 0
end
end
function love.load()
keys = {}
pedal = {}
pedal.x = 640
pedal.y = 680
pedal.w = 180
pedal.h = 40
pedal.innerWidth = 0
pedal.innerHeight = 30
maxSteerAngle = math.pi * 0.33
pedal.maxWidth = (pedal.w - 10) / 2
tireWidth = scale/2
tireHeight = scale
end
function love.update(dt)
mouseX = love.mouse.getX()
mouseY = love.mouse.getY()
checkKeys()
updatePedal()
player:updatePlayer(dt)
end
function love.draw()
love.graphics.setColor(200, 200, 200)
love.graphics.setColor(255, 0, 0)
love.graphics.push()--227, 252, 236
love.graphics.translate(player.x, player.y)
love.graphics.rotate(player.direction)
--love.graphics.rectangle("fill", - player.width/2, -player.height, player.width, player.height)
love.graphics.rectangle("fill", 0, -player.width/2, player.height, player.width)
love.graphics.setColor(love.math.colorFromBytes(227, 252, 236))
love.graphics.rectangle("fill", -tireHeight/2, -player.width/2 - tireWidth/2, tireHeight, tireWidth)
love.graphics.rectangle("fill", -tireHeight/2, player.width/2 - tireWidth/2, tireHeight, tireWidth)
--love.graphics.rectangle("fill", 0, -player.width/2, player.height, player.width)
love.graphics.push()--left tire
love.graphics.translate(player.height, - player.width/2)
love.graphics.rotate(player.steerAngle)
love.graphics.rectangle("fill",-tireHeight/2,-tireWidth/2,tireHeight,tireWidth)
love.graphics.pop()
love.graphics.push()--right tire
love.graphics.translate(player.height,player.width/2)
love.graphics.rotate(player.steerAngle)
love.graphics.rectangle("fill",-tireHeight/2,- tireWidth/2,tireHeight,tireWidth)
love.graphics.pop()
love.graphics.pop()
printVectors(player.x,player.y)
printStats(10,10)
drawPedal()
end