-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.lua
158 lines (118 loc) · 3.32 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
--for i = 1,100 do
--print("do function to play sounds at random pitches")
--end
--textures: https://github.com/minetest-texturepacks/Good-Morning-Craft-Minetest
--the directory
debugGraph = require 'modules.debugGraph.debugGraph'
math.randomseed(os.time())
debugger = false
dofile("math.lua")
dofile("terminal.lua")
dofile("sound.lua")
dofile("schematics.lua")
dofile("tserial.lua")
dofile("pause.lua")
dofile("items.lua")
dofile("map.lua")
dofile("menu.lua")
dofile("player.lua")
dofile("collision.lua")
dofile("physics.lua")
dofile("inventory.lua")
dofile("crafting.lua")
dofile("entity.lua")
dofile("particles.lua")
--the scale of the map
scale = 150
screenwidth = love.graphics.getWidth( )
screenheight = love.graphics.getHeight( )
function love.draw()
if pause == true then
maplib.draw()
player.draw()
entity.render_entity()
particle.render_particle()
render_pause_menu()
else
maplib.draw()
player.draw()
player.draw_health()
entity.render_entity()
particle.render_particle()
crafting.render_crafting()
menu.draw()
render_inventory()
end
if terminal == true then
render_terminal()
end
end
function love.load()
player_restore()
load_inventory_textures()
love.graphics.setDefaultFilter( "nearest", "nearest", 0 )
load_mining_textured()
load_player_textures()
fpsGraph = debugGraph:new('fps', 600, 120,100,50,0.01)
memGraph = debugGraph:new('mem', 600, 160,100,50,0.01)
dtGraph = debugGraph:new('custom', 600, 190,100,50,0.01)
maplib.createmap()
font = love.graphics.newFont("font.ttf", 12)
fontmed = love.graphics.newFont("font.ttf", 22)
fontbig = love.graphics.newFont("font.ttf", 35)
hugefont = love.graphics.newFont("font.ttf", 100)
love.graphics.setFont(font)
minesound = love.audio.newSource("sounds/mine.ogg", "static")
placesound = love.audio.newSource("sounds/place.ogg", "static")
stepsound = love.audio.newSource("sounds/step.ogg", "static")
oof = love.audio.newSource("sounds/oof.ogg", "static")
item_magnet_pickup = love.audio.newSource("sounds/item_magnet.ogg", "static")
menu_music = love.audio.newSource("sounds/menu_music.ogg")
menu_music:setLooping(true)
--wonder_music = love.audio.newSource("sounds/wonder.ogg")
--wonder_music:setLooping(true)
--wonder_music:play()
texture_table = {}
local i = 1
for key,value in pairs(blocks) do
texture_table[i] = love.graphics.newImage("textures/"..value.image)
i = i + 1
end
--playertexture = love.graphics.newImage("textures/player.png")
heart = love.graphics.newImage("textures/heart.png")
end
function love.quit( )
--print("Thanks for playing!")
return nil
end
function love.update(dt)
if pause ~= true and terminal ~= true then
physics.gravity()
move(dt)
physics.player_x_apply(dt)
maplib.load_chunks()
fpsGraph:update(dt)
memGraph:update(dt)
-- Update our custom graph
dtGraph:update(dt, math.floor(dt * 1000))
dtGraph.label = 'DT: ' .. dt
menu.animate()
mine(key,dt)
player.move_camera(dt)
maplib.liquid_flow(dt)
--debug
if love.keyboard.isDown("space") then
print("clear")
end
entity.gravity()
entity.physics_apply(dt)
particle.gravity()
particle.physics_apply(dt)
crafting.move_items()
maplib.new_block(player.playerx,player.playery)
elseif pause == true then
pause_game()
elseif terminal == true then
terminal_logic(dt)
end
end