-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
66 lines (49 loc) · 1.88 KB
/
Copy pathmain.lua
File metadata and controls
66 lines (49 loc) · 1.88 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
--- Syntax
---
--- Libraries -> alllowercase
--- Variables -> snake_case
--- Global variables -> CAPITAL_CASE
--- Query functions I.E. isStill -> camelCase()
--- Other Functions and procedures -> PascalCase()
---
love = require("love")
gametable = require("game")
scene = require("scenehandler")
function love.load()
_G.RES_X, _G.RES_Y, _ = love.window.getMode() -- The resolution of the screen in seperate variables
_G.RES = vector.new(RES_X,RES_Y) --2D vector containing the resolution of the screen (X,Y)
_G.FONT = love.graphics.setNewFont("Assets/Font/Exo/static/Exo-Thin.ttf", 60)
--Load the starting screen
LoadScene()
end
function love.resize(w, h)
--Update the screen resolution variables
_G.RES_X = w
_G.RES_Y = h
_G.RES = vector.new(w,h)
ResChangeScene()
end
function love.update(dt)
-- if the current scene has changed, load the new one
if CURRENT_SCENE ~= LAST_SCENE then
LoadScene()
else
-- otherwise just keep updating the current one
UpdateScene(dt)
end
end
function love.draw()
RenderScene()
love.graphics.line(PLAYER_SCREEN_POSITION.x,PLAYER_SCREEN_POSITION.y, love.mouse.getX(), love.mouse.getY())
love.graphics.setColor(1,0,0)
love.graphics.line(PLAYER_SCREEN_POSITION.x,PLAYER_SCREEN_POSITION.y,(GAME.player.state.speed + PLAYER_SCREEN_POSITION):unpack())
love.graphics.setColor(1,1,1)
love.graphics.printf({GAME.player.state.position.x," ",GAME.player.state.position.y}, 0, 0, RES_X, "left", 0, 1, 1, 0, 0, 0, 0)
end
function FovSizeCorrection()
return FOV_CHANGE_LIMITER(GAME.player.state.speed:dist(ZERO_VECTOR)) / (FOV_CHANGE_CALMER*ZOOM_MULT)
end
function FovPosCorrection(orgvalue)
local modifier = ( ZOOM - FOV_CHANGE_LIMITER(GAME.player.state.speed:dist(ZERO_VECTOR)) / (FOV_CHANGE_CALMER*ZOOM_MULT))/ ZOOM
return (((orgvalue - RES/2) * modifier) + RES/2)
end