Open-Terrarium/menu.lua

123 lines
3.0 KiB
Lua
Raw Normal View History

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
menutitle = {}
menutitle.g = 50
menutitle.a = 50
menutitle.m = 50
menutitle.e = 50
menutimer = 0
pause = false
letter = 1
function menu.animate()
if pause == false then
menutimer = menutimer + 1
end
if menutimer > 20 then
if letter == 1 then
menutitle.g = menutitle.g + 2
elseif letter == 2 then
menutitle.a = menutitle.a + 2
elseif letter == 3 then
menutitle.m = menutitle.m + 2
elseif letter == 4 then
menutitle.e = menutitle.e + 2
end
if menutimer >= 40 then
menutimer = 0
letter = letter + 1
if letter > 4 then
letter = 1
end
end
elseif menutimer <= 20 then
if letter == 1 then
menutitle.g = menutitle.g - 2
elseif letter == 2 then
menutitle.a = menutitle.a - 2
elseif letter == 3 then
menutitle.m = menutitle.m - 2
elseif letter == 4 then
menutitle.e = menutitle.e - 2
end
end
end
function menu.draw()
2017-06-20 02:58:58 -04:00
menu.cursor()
2017-06-19 02:46:07 -04:00
love.graphics.setFont(fontbig)
love.graphics.setColor(255,0,0,255)
2017-06-19 03:05:48 -04:00
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)
2017-06-19 02:46:07 -04:00
--score debug
love.graphics.setFont(fontmed)
love.graphics.setColor(255,255,255,255)
2017-07-04 02:22:32 -04:00
love.graphics.print("Score:"..tostring(score), 400,110)
2017-06-20 02:16:21 -04:00
2017-06-20 02:16:21 -04:00
--debug mining
if player.mining == true then
love.graphics.setColor(255,0,0,255)
love.graphics.print("Mining", 400,180)
love.graphics.setColor(128,128,128,255)
love.graphics.print("Placing", 560,180)
elseif player.mining == false then
love.graphics.setColor(128,128,128,255)
love.graphics.print("Mining", 400,180)
love.graphics.setColor(255,0,0,255)
love.graphics.print("Placing", 560,180)love.graphics.print("PosX:"..player.playerx.." PosY:"..player.playery, 400,150)
end
--debug player's pos
2017-06-20 02:16:21 -04:00
love.graphics.setColor(255,255,255,255)
love.graphics.print("PosX:"..player.playerx.." PosY:"..player.playery, 400,150)
2017-06-20 02:58:58 -04:00
--debug mouse's pos
love.graphics.setColor(255,255,255,255)
love.graphics.print("MX:"..mx.." MY:"..my, 400,220)
2017-06-20 04:16:34 -04:00
--debug selected item
love.graphics.setColor(255,255,255,255)
if player.selected == 1 then
love.graphics.print("ITEM: #", 400,250)
elseif player.selected == 2 then
love.graphics.print("ITEM: /", 400,250)
end
2017-06-28 02:01:48 -04:00
love.graphics.print("Chunkx:"..chunkx, 400,280)
love.graphics.print("Chunky:"..chunky, 400,320)
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
--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)
--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
love.graphics.rectangle("line", player_drawnx+xx, player_drawny+yy-3, scale, scale )
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