2017-07-10 04:49:16 -04:00
|
|
|
|
2017-07-19 00:41:56 -04:00
|
|
|
--for i = 1,100 do
|
2017-07-18 23:53:53 -04:00
|
|
|
|
2017-07-19 00:41:56 -04:00
|
|
|
-- print("Fix collision detection on chunk border")
|
2017-07-18 23:53:53 -04:00
|
|
|
|
2017-07-19 00:41:56 -04:00
|
|
|
--end
|
2017-07-10 04:49:16 -04:00
|
|
|
|
2017-07-07 04:14:22 -04:00
|
|
|
--textures: https://github.com/minetest-texturepacks/Good-Morning-Craft-Minetest
|
|
|
|
|
2017-06-22 02:27:43 -04:00
|
|
|
--the directory
|
2017-07-10 04:08:16 -04:00
|
|
|
debugGraph = require 'modules.debugGraph.debugGraph'
|
2017-06-20 01:40:29 -04:00
|
|
|
|
2017-06-22 03:38:12 -04:00
|
|
|
math.randomseed(os.time())
|
|
|
|
|
2017-07-10 04:08:16 -04:00
|
|
|
|
2017-06-22 02:27:43 -04:00
|
|
|
dofile("tserial.lua")
|
2017-07-18 04:29:28 -04:00
|
|
|
dofile("pause.lua")
|
2017-06-28 02:21:20 -04:00
|
|
|
dofile("ore.lua")
|
2017-06-19 02:15:21 -04:00
|
|
|
dofile("map.lua")
|
2017-06-19 02:46:07 -04:00
|
|
|
dofile("menu.lua")
|
2017-06-22 03:38:12 -04:00
|
|
|
dofile("player.lua")
|
2017-07-10 00:34:00 -04:00
|
|
|
dofile("collision.lua")
|
2017-07-09 22:23:40 -04:00
|
|
|
dofile("physics.lua")
|
2017-07-19 00:41:56 -04:00
|
|
|
dofile("inventory.lua")
|
2017-06-20 01:40:29 -04:00
|
|
|
|
|
|
|
--the scale of the map
|
2017-07-18 04:37:03 -04:00
|
|
|
scale = 150
|
2017-06-19 02:15:21 -04:00
|
|
|
|
2017-07-08 02:00:44 -04:00
|
|
|
screenwidth = love.graphics.getWidth( )
|
|
|
|
|
|
|
|
screenheight = love.graphics.getHeight( )
|
|
|
|
|
2017-06-19 02:15:21 -04:00
|
|
|
function love.draw()
|
|
|
|
maplib.draw()
|
2017-06-19 02:46:07 -04:00
|
|
|
player.draw()
|
2017-07-10 00:34:00 -04:00
|
|
|
menu.draw()
|
2017-07-10 04:08:16 -04:00
|
|
|
fpsGraph:draw()
|
|
|
|
memGraph:draw()
|
|
|
|
dtGraph:draw()
|
2017-07-10 04:16:19 -04:00
|
|
|
player.draw_health()
|
2017-07-19 00:41:56 -04:00
|
|
|
render_inventory()
|
2017-06-19 02:15:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.load()
|
2017-07-19 00:41:56 -04:00
|
|
|
load_inventory_textures()
|
2017-07-18 02:30:34 -04:00
|
|
|
|
|
|
|
love.graphics.setDefaultFilter( "nearest", "nearest", 0 )
|
|
|
|
|
2017-07-18 03:28:12 -04:00
|
|
|
load_mining_textured()
|
|
|
|
|
2017-07-18 02:30:34 -04:00
|
|
|
load_player_textures()
|
|
|
|
|
2017-07-10 04:08:16 -04:00
|
|
|
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)
|
|
|
|
|
2017-06-19 02:15:21 -04:00
|
|
|
maplib.createmap()
|
2017-06-20 01:59:18 -04:00
|
|
|
|
2017-06-19 02:46:07 -04:00
|
|
|
font = love.graphics.newFont("font.ttf", 12)
|
|
|
|
fontmed = love.graphics.newFont("font.ttf", 22)
|
|
|
|
fontbig = love.graphics.newFont("font.ttf", 35)
|
2017-06-20 01:59:18 -04:00
|
|
|
|
2017-06-19 02:46:07 -04:00
|
|
|
love.graphics.setFont(font)
|
2017-06-20 01:59:18 -04:00
|
|
|
|
2017-06-20 02:16:21 -04:00
|
|
|
|
2017-07-18 04:34:06 -04:00
|
|
|
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")
|
2017-07-08 01:55:47 -04:00
|
|
|
menu_music = love.audio.newSource("sounds/menu_music.ogg")
|
|
|
|
menu_music:setLooping(true)
|
|
|
|
|
2017-07-07 03:42:19 -04:00
|
|
|
|
|
|
|
texture_table = {}
|
|
|
|
local i = 1
|
|
|
|
for key,value in pairs(ore) do
|
|
|
|
texture_table[i] = love.graphics.newImage("textures/"..value.image)
|
|
|
|
i = i + 1
|
|
|
|
end
|
|
|
|
|
2017-07-18 02:30:34 -04:00
|
|
|
--playertexture = love.graphics.newImage("textures/player.png")
|
2017-07-10 04:16:19 -04:00
|
|
|
heart = love.graphics.newImage("textures/heart.png")
|
2017-07-07 04:10:42 -04:00
|
|
|
|
2017-07-18 23:53:53 -04:00
|
|
|
--menu_music:play()
|
2017-06-19 02:15:21 -04:00
|
|
|
end
|
|
|
|
|
2017-06-20 03:09:33 -04:00
|
|
|
function love.quit( )
|
|
|
|
print("Thanks for playing!")
|
|
|
|
return nil
|
2017-06-20 02:58:58 -04:00
|
|
|
end
|
2017-06-19 02:15:21 -04:00
|
|
|
|
|
|
|
function love.update(dt)
|
2017-07-12 05:25:10 -04:00
|
|
|
|
2017-07-18 04:29:28 -04:00
|
|
|
pause_game()
|
|
|
|
|
2017-07-12 05:25:10 -04:00
|
|
|
maplib.load_chunks()
|
2017-07-10 04:08:16 -04:00
|
|
|
fpsGraph:update(dt)
|
|
|
|
memGraph:update(dt)
|
|
|
|
-- Update our custom graph
|
|
|
|
dtGraph:update(dt, math.floor(dt * 1000))
|
|
|
|
dtGraph.label = 'DT: ' .. dt
|
|
|
|
|
2017-06-19 02:46:07 -04:00
|
|
|
menu.animate()
|
2017-07-18 03:28:12 -04:00
|
|
|
mine(key,dt)
|
2017-07-07 01:13:55 -04:00
|
|
|
player.move_camera(dt)
|
2017-07-07 04:56:18 -04:00
|
|
|
maplib.liquid_flow(dt)
|
2017-07-07 02:43:21 -04:00
|
|
|
--debug
|
|
|
|
if love.keyboard.isDown("space") then
|
|
|
|
print("clear")
|
|
|
|
end
|
2017-07-08 04:37:48 -04:00
|
|
|
move(dt)
|
2017-07-09 22:23:40 -04:00
|
|
|
physics.player_x_apply(dt)
|
2017-07-10 00:34:00 -04:00
|
|
|
physics.gravity()
|
2017-07-09 22:23:40 -04:00
|
|
|
maplib.new_block(player.playerx,player.playery)
|
2017-06-19 02:15:21 -04:00
|
|
|
end
|