-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
84 lines (69 loc) · 1.64 KB
/
main.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
Storage = require( "lib/storage" )
json = require( "lib/json" )
require( "graphics" )
require( "map" )
require( "deployables" )
require( "projectiles" )
require( "entities" )
require( "weapons" )
require( "keys" )
require( "player" )
Version = "ECA-2-7-5"
function TranslateX( x )
return ( ( mousex - 1.35 ) / 1.35 ) - ( ( width / 2.65 ) - player.Position.x )
end
function TranslateY( y )
return ( ( mousey - 1.35 ) / 1.35 ) - ( ( height / 2.65 ) - player.Position.y )
end
-- nerd stuff --
function lerp(a,b,t) return (1-t)*a + t*b end
function lerp2(a,b,t) return a+(b-a)*t end
function TranslatePosition( Position )
return {
x = TranslateX( Position.x ),
y = TranslateY( Position.y )
}
end
function CloneObject( obj )
local res = {}
for k, v in pairs( obj ) do
res[ k ] = v
end
return res
end
function love.load()
love.mouse.setVisible( false )
Map = InitMap()
player = InitPlayer( 0, nil )
end
function love.draw()
Camera()
DrawMap()
DrawBullets()
DrawPlayer( player )
DrawEntities()
EndCamera()
DrawHUD()
end
function love.update( d )
width, height = love.graphics.getDimensions()
mousex, mousey = love.mouse.getPosition()
dt = d
mousext = TranslateX( mousex )
mouseyt = TranslateY( mousey )
for key, func in pairs( player.RepeatControls ) do
if ( love.keyboard.isDown( key ) ) then
player.RepeatControls[ key ]()
end
end
UpdateMap()
UpdatePlayers()
EntityBehaviour()
end
function love.keypressed( key, scancode, isrepeat )
for k, func in pairs( player.Controls ) do
if ( key == k ) then
player.Controls[ k ]()
end
end
end