Open-Terrarium/main.lua

159 lines
3.3 KiB
Lua
Raw Normal View History

2017-07-10 04:49:16 -04:00
2017-07-23 21:31:36 -04:00
--for i = 1,100 do
2017-07-18 23:53:53 -04:00
2017-07-23 21:31:36 -04:00
--print("do function to play sounds at random pitches")
2017-07-18 23:53:53 -04:00
2017-07-23 21:31:36 -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
--the directory
2017-07-10 04:08:16 -04:00
debugGraph = require 'modules.debugGraph.debugGraph'
2017-06-22 03:38:12 -04:00
math.randomseed(os.time())
2017-07-24 05:20:44 -04:00
debugger = false
2017-07-10 04:08:16 -04:00
2017-07-23 17:56:39 -04:00
dofile("math.lua")
2017-08-04 05:12:51 -04:00
dofile("terminal.lua")
dofile("sound.lua")
2017-07-23 21:31:36 -04:00
dofile("schematics.lua")
dofile("tserial.lua")
2017-07-18 04:29:28 -04:00
dofile("pause.lua")
2017-07-24 03:55:15 -04:00
dofile("items.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-07-24 04:51:33 -04:00
dofile("crafting.lua")
2017-07-22 22:15:24 -04:00
dofile("entity.lua")
2017-07-23 20:19:54 -04:00
dofile("particles.lua")
--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()
2017-08-04 03:40:48 -04:00
if pause == true then
2017-08-04 04:32:42 -04:00
maplib.draw()
player.draw()
entity.render_entity()
particle.render_particle()
2017-08-04 03:40:48 -04:00
render_pause_menu()
2017-08-04 04:18:05 -04:00
else
maplib.draw()
player.draw()
player.draw_health()
entity.render_entity()
particle.render_particle()
crafting.render_crafting()
menu.draw()
render_inventory()
2017-08-04 03:40:48 -04:00
end
2017-08-04 05:12:51 -04:00
if terminal == true then
render_terminal()
end
2017-08-04 04:18:05 -04:00
2017-06-19 02:15:21 -04:00
end
function love.load()
2017-07-19 02:57:36 -04:00
player_restore()
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-08-04 03:40:48 -04:00
hugefont = love.graphics.newFont("font.ttf", 100)
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-23 18:04:30 -04:00
item_magnet_pickup = love.audio.newSource("sounds/item_magnet.ogg", "static")
2017-07-08 01:55:47 -04:00
menu_music = love.audio.newSource("sounds/menu_music.ogg")
menu_music:setLooping(true)
2017-12-28 00:20:08 -05:00
--wonder_music = love.audio.newSource("sounds/wonder.ogg")
--wonder_music:setLooping(true)
--wonder_music:play()
2017-07-07 03:42:19 -04:00
texture_table = {}
local i = 1
2017-07-19 02:32:24 -04:00
for key,value in pairs(blocks) do
2017-07-07 03:42:19 -04:00
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-12-28 00:20:08 -05:00
2017-06-19 02:15:21 -04:00
end
2017-06-20 03:09:33 -04:00
function love.quit( )
2017-12-28 00:20:08 -05:00
--print("Thanks for playing!")
2017-06-20 03:09:33 -04:00
return nil
2017-06-20 02:58:58 -04:00
end
2017-06-19 02:15:21 -04:00
2017-08-04 03:34:38 -04:00
function love.update(dt)
2017-08-04 05:12:51 -04:00
if pause ~= true and terminal ~= true then
2017-08-04 03:34:38 -04:00
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)
2017-08-04 05:12:51 -04:00
elseif pause == true then
2017-08-04 04:32:42 -04:00
pause_game()
2017-08-04 05:12:51 -04:00
elseif terminal == true then
terminal_logic(dt)
2017-08-04 03:34:38 -04:00
end
2017-07-19 04:32:18 -04:00
2017-06-19 02:15:21 -04:00
end