-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
127 lines (80 loc) · 2.27 KB
/
Copy pathmain.lua
File metadata and controls
127 lines (80 loc) · 2.27 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
require('content')
require('tools')
require('map')
require('camera')
require('player')
require('collision')
-- The main class for the game Ulysse.B
playerControl = true
local todraw = {}
local option = false
TMap = {}
ratio = 1
screenRefx = 1920
screenRefy = 1080
function love.load()
--success = love.window.setFullscreen( true )
love.window.setMode(1366,768)
print("Game Start")
if(loadContent()) then
print("Content is load")
end
LoadAllMap()
print("Maps are load")
print ("Loading Camera")
CreateScreen(love.graphics.getWidth(),love.graphics.getHeight())
print("Get ratio")
ratio = getRatio( screenRefx,screenRefy )
print ("Loading Objects of the map")
TMap = getCurrentMap()
print("Loading Map like in object")
loadMapInObject(TMap,ratio)
print("Loading Player")
LoadPlayer(ratio)
print("Loading Collision System")
LoadCollisionSystem(TMap[2],ratio) -- Collision is the number 2
end
function love.draw()
camera = getCam()
for i=1,#todraw do
love.graphics.draw(todraw[i].img,todraw[i].x + camera.x,todraw[i].y + camera.y,0,ratio.x,ratio.y)
end
if (option == false) then
--Load Point of collision
local obj = getPointCollision(ratio)
love.graphics.print(tostring(#todraw).. " " .. love.timer.getFPS() .. " Collision point: X/Y : " .. tostring(obj.x) .. ";" .. tostring(obj.y) ,0,0)
end
end
function love.update(dt)
todraw = {}
local obj = getObject()
local beload = toDrawChoice(obj,ratio)
--draw map
for i=1,#beload do
addToDraw(beload[i])
end
if(playerControl) then
controlPlayerMovement(dt,ratio)
-- add to draw Player
objPlayer = getPlayerObject()
addToDraw(objPlayer)
focusObject(objPlayer)
end
end
-- object with x , y , img and after add scale inside the image for animation
function addToDraw( obj )
local index = #todraw + 1
todraw[index] = {}
todraw[index].x = obj.x -- Initialise bedraw for add to "todraw"
todraw[index].y = obj.y
todraw[index].img = obj.img
end
function love.keypressed(key)
if key == "escape" then
love.event.quit()
end
if key=="f1" then
-- Show and remove fps ect...
option = inverseBool(option)
end
end