2017-06-19 02:46:07 -04:00
|
|
|
--menu animation and info
|
|
|
|
menu = {}
|
|
|
|
|
2017-06-20 02:58:58 -04:00
|
|
|
mx,my = 1,1
|
2017-06-19 02:46:07 -04:00
|
|
|
|
2017-07-10 05:02:38 -04:00
|
|
|
menutitle = {"O","p","e","n"," ","T","e","r","r","a","r","i","u","m"," ","0",".","0",".","1"}
|
|
|
|
menu_char = {}
|
|
|
|
for i, v in ipairs(menutitle) do
|
|
|
|
--print(i)
|
|
|
|
menu_char[i] = 0
|
|
|
|
end
|
|
|
|
print(menutitle[1])
|
2017-06-19 02:46:07 -04:00
|
|
|
menutimer = 0
|
2017-07-10 05:02:38 -04:00
|
|
|
characters = table.getn(menutitle)
|
2017-06-19 02:46:07 -04:00
|
|
|
pause = false
|
|
|
|
|
|
|
|
letter = 1
|
|
|
|
|
|
|
|
function menu.animate()
|
|
|
|
if pause == false then
|
|
|
|
menutimer = menutimer + 1
|
|
|
|
end
|
2017-07-10 05:02:38 -04:00
|
|
|
if menutimer > 10 then
|
|
|
|
--push up
|
|
|
|
menu_char[letter] = menu_char[letter] + 2
|
|
|
|
if menutimer >= 20 then
|
2017-06-19 02:46:07 -04:00
|
|
|
menutimer = 0
|
|
|
|
letter = letter + 1
|
2017-07-10 05:02:38 -04:00
|
|
|
--skip spaces
|
|
|
|
if menutitle[letter] == " " then
|
|
|
|
letter = letter + 1
|
|
|
|
end
|
|
|
|
if letter > characters then
|
2017-06-19 02:46:07 -04:00
|
|
|
letter = 1
|
|
|
|
end
|
|
|
|
end
|
2017-07-10 05:02:38 -04:00
|
|
|
elseif menutimer <= 10 then
|
|
|
|
--push down
|
|
|
|
menu_char[letter] = menu_char[letter] - 2
|
2017-06-19 02:46:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-07 02:43:21 -04:00
|
|
|
selected_chunkx,selected_chunky = 0,0
|
|
|
|
|
2017-06-19 02:46:07 -04:00
|
|
|
function menu.draw()
|
2017-06-20 02:58:58 -04:00
|
|
|
|
|
|
|
menu.cursor()
|
2017-07-10 05:02:38 -04:00
|
|
|
love.graphics.setFont(font)
|
|
|
|
love.graphics.setColor(255,0,0,255)
|
|
|
|
for i = 1,characters do
|
|
|
|
love.graphics.print(menutitle[i], screenwidth-260+(12*i),screenheight-10+menu_char[i] )
|
|
|
|
|
|
|
|
end
|
2017-07-09 19:51:07 -04:00
|
|
|
--redo this as a table
|
|
|
|
--love.graphics.setFont(fontbig)
|
|
|
|
--love.graphics.setColor(255,0,0,255)
|
|
|
|
--love.graphics.print("D", 400, menutitle.g)
|
|
|
|
--love.graphics.print("I", 440, menutitle.a)
|
|
|
|
--love.graphics.print("G", 480, menutitle.m)
|
|
|
|
--love.graphics.print("!", 520, menutitle.e)
|
|
|
|
local xxer = 600
|
2017-06-19 02:46:07 -04:00
|
|
|
--score debug
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.setFont(font)
|
2017-06-19 02:46:07 -04:00
|
|
|
love.graphics.setColor(255,255,255,255)
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("Score:"..tostring(score),xxer,12)
|
2017-06-20 02:16:21 -04:00
|
|
|
|
2017-06-20 01:40:29 -04:00
|
|
|
|
2017-06-20 02:16:21 -04:00
|
|
|
--debug mining
|
|
|
|
if player.mining == true then
|
|
|
|
love.graphics.setColor(255,0,0,255)
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("Mining", xxer,24)
|
2017-06-20 02:16:21 -04:00
|
|
|
love.graphics.setColor(128,128,128,255)
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("Placing", xxer+80,24)
|
2017-06-20 02:16:21 -04:00
|
|
|
|
|
|
|
elseif player.mining == false then
|
|
|
|
love.graphics.setColor(128,128,128,255)
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("Mining", xxer,24)
|
2017-06-20 02:16:21 -04:00
|
|
|
love.graphics.setColor(255,0,0,255)
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("Placing", xxer+80,24)
|
|
|
|
|
|
|
|
--love.graphics.print("PosX:"..player.playerx.." PosY:"..player.playery, 400,150)
|
2017-06-20 02:16:21 -04:00
|
|
|
end
|
2017-06-20 01:40:29 -04:00
|
|
|
--debug player's pos
|
2017-06-20 02:16:21 -04:00
|
|
|
love.graphics.setColor(255,255,255,255)
|
2017-07-09 20:35:07 -04:00
|
|
|
love.graphics.print("PosX:"..(player.playerx+(chunkx*map_max)).." PosY:"..((map_max-player.playery)+(chunky*map_max)), 5,5)
|
2017-06-20 02:58:58 -04:00
|
|
|
--debug mouse's pos
|
|
|
|
love.graphics.setColor(255,255,255,255)
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("MX:"..mx.." MY:"..my, xxer,36)
|
2017-06-20 04:16:34 -04:00
|
|
|
--debug selected item
|
|
|
|
love.graphics.setColor(255,255,255,255)
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("ITEM:", xxer,48) love.graphics.draw(texture_table[player.selected],xxer+60,45,0,0.8,0.8)
|
2017-07-07 04:04:42 -04:00
|
|
|
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("Chunkx:"..chunkx, xxer,60)
|
|
|
|
love.graphics.print("Chunky:"..chunky, xxer,72)
|
2017-07-08 01:55:47 -04:00
|
|
|
|
2017-07-09 19:51:07 -04:00
|
|
|
love.graphics.print("Current FPS:"..tostring(love.timer.getFPS( )), xxer, 84)
|
2017-07-10 00:34:00 -04:00
|
|
|
|
|
|
|
love.graphics.print("Intx:"..tostring(player.inertiax), xxer, 96)
|
|
|
|
love.graphics.print("Inty:"..tostring(player.inertiay), xxer, 108)
|
2017-07-10 04:41:19 -04:00
|
|
|
|
|
|
|
love.graphics.print("Deaths:"..tostring(deaths), xxer, 250)
|
2017-07-10 00:34:00 -04:00
|
|
|
|
2017-06-20 02:58:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
function menu.cursor()
|
|
|
|
local x, y = love.mouse.getPosition( )
|
2017-07-05 03:19:06 -04:00
|
|
|
|
|
|
|
|
2017-07-05 04:28:00 -04:00
|
|
|
--love.graphics.circle( "fill", player_drawnx, player_drawny, 4 )
|
2017-07-05 03:19:06 -04:00
|
|
|
|
|
|
|
--local xx,yy = math.floor(x/scale),math.floor((y+3)/scale)
|
|
|
|
local xx,yy = math.floor((x-player_drawnx)/scale)*scale,math.floor((y-player_drawny)/scale)*scale
|
|
|
|
|
|
|
|
|
|
|
|
mx,my = player.playerx + (xx/scale),player.playery + (yy/scale)
|
|
|
|
|
2017-07-07 02:43:21 -04:00
|
|
|
selected_chunkx,selected_chunky = 0,0
|
2017-07-05 03:19:06 -04:00
|
|
|
--only change and draw if in boundaries
|
|
|
|
if ((mx >= 1 and mx <= map_max) and (my >= 1 and my <= map_max)) and (math.abs(player.playerx-mx) <=5 and math.abs(player.playery-my) <=5) then
|
2017-07-09 20:10:01 -04:00
|
|
|
love.graphics.rectangle("line", player_drawnx+xx, player_drawny+yy, scale, scale )
|
2017-07-07 02:43:21 -04:00
|
|
|
|
|
|
|
--reach outside of chunk
|
|
|
|
elseif (math.abs(player.playerx-mx) <=5 and math.abs(player.playery-my) <=5) then
|
|
|
|
|
|
|
|
--ocal chunkex,chunkey = math.floor(mx/map_max),math.floor(my/map_max)
|
|
|
|
|
|
|
|
--overreach x
|
|
|
|
if mx > map_max then
|
|
|
|
mx = mx - map_max
|
|
|
|
selected_chunkx = 1
|
|
|
|
elseif mx < 1 then
|
|
|
|
mx = mx + map_max
|
|
|
|
selected_chunkx = -1
|
|
|
|
else
|
|
|
|
--mx = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--overreach y
|
|
|
|
if my < 1 then
|
|
|
|
my = my + map_max
|
|
|
|
selected_chunky = 1
|
2017-07-07 03:02:20 -04:00
|
|
|
--print("up")
|
2017-07-07 02:43:21 -04:00
|
|
|
elseif my > map_max then
|
|
|
|
my = my - map_max
|
|
|
|
selected_chunky = -1
|
2017-07-07 03:02:20 -04:00
|
|
|
--print("down")
|
2017-07-07 02:43:21 -04:00
|
|
|
--else
|
|
|
|
--my = 0
|
|
|
|
end
|
|
|
|
--print("chunkey:"..chunkey.."|my:"..my)
|
|
|
|
|
|
|
|
--print(selected_chunkx, selected_chunky)
|
2017-07-09 20:10:01 -04:00
|
|
|
love.graphics.rectangle("line", player_drawnx+xx, player_drawny+yy, scale, scale )
|
2017-07-07 02:43:21 -04:00
|
|
|
|
2017-06-20 02:58:58 -04:00
|
|
|
else
|
2017-06-20 03:19:57 -04:00
|
|
|
mx,my = -1,-1
|
2017-06-20 02:58:58 -04:00
|
|
|
end
|
2017-07-05 03:19:06 -04:00
|
|
|
|
|
|
|
|
2017-06-20 02:58:58 -04:00
|
|
|
|
2017-06-19 02:46:07 -04:00
|
|
|
end
|