Fish fillets remake https://glitchapp.codeberg.page/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
fish-fillets-remake/lib/netcontrols/main.lua

370 lines
15 KiB

local socket = require "socket"
-- the address and port of the server
local address, port = "localhost", 12345
local entity -- entity is what we'll be controlling
local updaterate = 0.1 -- how long to wait, in seconds, before requesting an update
local world = {} -- the empty world-state
t=1
function love.load()
--[[
--network
udp = socket.udp()
udp:settimeout(0)
udp:setpeername(address, port)
math.randomseed(os.time())
entity = tostring(math.random(99999))
local dg = string.format("%s %s %d %d", entity, 'at', 320, 240)
udp:send(dg) -- the magic line in question.
--]]
soundon=true
musicison=true
talkies=false
love.window.setMode(1920, 1080, {resizable=true, borderless=false})
--touch controls
touchcontrols1= love.graphics.newImage("interface/touchcontroltrans.png")
contcontrast= love.graphics.newImage("interface/contcontrast.png")
fishtouch1= love.graphics.newImage("interface/fishtouch1.png")
fishtouch2= love.graphics.newImage("interface/fishtouch2.png")
fishtouchcontrast= love.graphics.newImage("interface/fishtouchcontrast.png")
levelcontrol1= love.graphics.newImage("interface/level1.png")
confcontrol1= love.graphics.newImage("interface/conftrans.png")
--leditoricon= love.graphics.newImage("interface/leveleditor.png")
touchicon= love.graphics.newImage("interface/touchicon.png")
--screen options
screenoptionsicon= love.graphics.newImage("interface/screenoptionsicon.png")
helpicon= love.graphics.newImage("interface/helpicon.png")
paletteicon= love.graphics.newImage("interface/paletteicon.png")
crteffecticon= love.graphics.newImage("interface/crteffect.png")
shadericon= love.graphics.newImage("interface/shadericon.png")
threedicon= love.graphics.newImage("interface/3dicon.png")
dioramaicon= love.graphics.newImage("interface/dioramaicon.png")
screenresolutionicon= love.graphics.newImage("interface/screenresolutionicon.png")
closeicon= love.graphics.newImage("interface/closeicon.png")
-- show hide panels
showpanelright= love.graphics.newImage("interface/showpanelright.png")
hidepanelright= love.graphics.newImage("interface/hidepanelright.png")
panelup= love.graphics.newImage("interface/panelup.png")
paneldown= love.graphics.newImage("interface/paneldown.png")
-- sound icons
soundonicon= love.graphics.newImage("interface/soundon.png")
soundoff= love.graphics.newImage("interface/soundoff.png")
--music icons
musiconicon= love.graphics.newImage("interface/musicon.png")
musicoff= love.graphics.newImage("interface/musicoff.png")
--dialogs icons
opendialogs= love.graphics.newImage("interface/opendialogs.png")
closedialogs= love.graphics.newImage("interface/closedialogs.png")
readdialog= love.graphics.newImage("interface/readdialog.png")
--controller icons
xboxgamepad= love.graphics.newImage("interface/xboxgamepad.png")
end
function love.update(deltatime)
t = t + deltatime -- increase t by the deltatime
if t > updaterate then
local x, y = 0, 0
if love.keyboard.isDown('up') then y=y-(20*t) end
if love.keyboard.isDown('down') then y=y+(20*t) end
if love.keyboard.isDown('left') then x=x-(20*t) end
if love.keyboard.isDown('right') then x=x+(20*t) end
--[[
local dg = string.format("%s %s %f %f", entity, 'move', x, y)
udp:send(dg)
local dg = string.format("%s %s $", entity, 'update')
udp:send(dg)
t=t-updaterate
end
repeat
data, msg = udp:receive()
if data then
ent, cmd, parms = data:match("^(%S*) (%S*) (.*)")
if cmd == 'at' then
local x, y = parms:match("^(%-?[%d.e]*) (%-?[%d.e]*)$")
assert(x and y)
x, y = tonumber(x), tonumber(y)
world[ent] = {x=x, y=y}
else
print("unrecognised command:", cmd)
end
elseif msg ~= 'timeout' then
error("Network error: "..tostring(msg))
end
until not data
--]]
end
end
function love.draw(dt)
for k, v in pairs(world) do
love.graphics.print(k, v.x, v.y)
end
love.graphics.setColor(0.5,0.5,0.5,0.8)
love.graphics.rectangle('fill',150,100,800,700)
love.graphics.setColor(1,1,1,0.8)
love.graphics.rectangle('fill',50,800,380,180)
love.graphics.rectangle('fill',450,800,380,180)
love.graphics.draw(fishtouch1,50,800,0,1.6) -- Fish 1 selection
love.graphics.draw(fishtouch2,450,800,0,1.6)
tcx=1300
tcy=450
love.graphics.circle('fill',tcx+190,tcy+320,84)
love.graphics.circle('fill',tcx+440,tcy+320,84)
love.graphics.circle('fill',tcx+320,tcy+200,84)
love.graphics.circle('fill',tcx+320,tcy+450,84)
love.graphics.draw(touchcontrols1,tcx,tcy,0,1.6) -- arrows
love.graphics.setColor(0.5,0.5,0.5,0.8)
love.graphics.rectangle('fill',1140,30,100,600)
love.graphics.draw(confcontrol1,1150,50,0,0.1) -- Options menu
love.graphics.draw(levelcontrol1,1150,150,0,0.1) -- screen options
love.graphics.draw(screenoptionsicon,1150,250,0,0.15) -- screen options
love.graphics.draw(touchicon,1165,320,0,0.10) -- touch interface
--love.graphics.draw(hidepanelright,1165,400,0,0.10) -- hide panel right
--[[
love.graphics.setColor(1,1,1)
love.graphics.draw(crteffecticon,200,300,0,0.15) -- CRT effect
love.graphics.print("CRT effect",200,370,0,1)
love.graphics.draw(shadericon,400,300,0,0.10) -- Shader effect
love.graphics.print("Shader",400,370,0,1)
love.graphics.draw(paletteicon,600,300,0,0.10) -- paletteeffect
love.graphics.print("Change color scheme",600,370,0,1)
love.graphics.draw(threedicon,200,500,0,0.10) -- 3d icon
love.graphics.print("3d on / off",200,570,0,1)
love.graphics.draw(dioramaicon,400,470,0,0.15) -- Diorama
love.graphics.print("Diorama on/off",400,570,0,1)
love.graphics.draw(screenresolutionicon,600,500,0,0.10) -- Screen resolution
love.graphics.print("Screen resolution",600,570,0,1)
--love.graphics.draw(leditoricon,200,700,0,0.15) -- level editor
--love.graphics.print("Background editor",200,770,0,1)
love.graphics.draw(closeicon,400,700,0,0.10) -- Close
love.graphics.print("Close screen options",400,770,0,1)
--]]
--if talkies==true then
love.graphics.draw(closedialogs,900,800,0,0.30) -- Close dialogs
love.graphics.setColor(0,0,0)
love.graphics.print("Close dialogs",900,850,0,1)
love.graphics.setColor(1,1,1)
love.graphics.draw(readdialog,1100,800,0,0.30) -- keep reading
love.graphics.setColor(0,0,0)
love.graphics.print("read",1130,850,0,1)
love.graphics.setColor(1,1,1)
--end
--if soundon==true then
-- love.graphics.draw(soundonicon,500,900,0,0.10) -- turn sound off
-- elseif soundon==false then
love.graphics.draw(soundoff,1150,450,0,0.10) -- turn sound off
--end
if musicison==true then
love.graphics.draw(musiconicon,1150,550,0,0.10) -- turn music off
elseif musicison==false and talkies==false then
love.graphics.draw(musicoff,1150,550,0,0.10) -- turn music off
end
end
function drawMouse ()
local mx, my = love.mouse.getPosition()
local tileSize = self.gridSize
local x = math.floor(mx/tileSize)+1
local y = math.floor(my/tileSize)+1
--love.graphics.setColor (0, 1, 0)
--love.graphics.print (x..' '..y, (x-1)*tileSize, (y-1)*tileSize) -- beware of -1
--love.graphics.print (mx..' '..my, (x-1)*tileSize, (y-1)*tileSize)
-- control coordinates: Left: X: 1045 - 1145 right 1175 - 1270
--Y: 810 - 905
-- X_ 1113 - 1200
--Up Y: 750 - 840 down 875 - 965
--Player selection coor: Big fish: X:50 - 242
-- Y:900 - 995
--Small fish X:250 - 440
-- Configuration button:X: 1150 - 1226
--Y:48 - 122
if love.mouse.isDown(1) then
if mx>1045 and mx<1145 and my>810 and my<905 and touchinterfaceison==true then love.timer.sleep( 0.1 ) --left
dx = -1
dy = 0
pb:mainMoving (dx, dy)
elseif mx>1175 and mx<1270 and my>810 and my<905 and touchinterfaceison==true then love.timer.sleep( 0.1 ) --right
dx = 1
dy = 0
pb:mainMoving (dx, dy)
elseif mx>631 and mx<1200 and my>875 and my<965 and touchinterfaceison==true then love.timer.sleep( 0.1 ) --down
dx=0
dy = 1
pb:mainMoving (dx, dy)
elseif mx>1113 and mx<1200 and my>750 and my<840 and touchinterfaceison==true then love.timer.sleep( 0.1 ) --up
dx=0
dy = -1
pb:mainMoving (dx, dy)
elseif mx>250 and mx<448 and my>900 and my<995 and touchinterfaceison==true and ispaneldown==false then love.timer.sleep( 0.2 ) --Select small fish
self.agent = self.agents[1]
elseif mx>50 and mx<242 and my>900 and my<995 and touchinterfaceison==true and ispaneldown==false then love.timer.sleep( 0.2 ) --Select big fish
self.agent = self.agents[2]
elseif mx>1150 and mx<1226 and my>48 and my<122 and touchinterfaceison==true and panelright==true then --Options menu
shader2=false
gamestatus="options"
TEsound.play("externalassets/sounds/GUI_Sound_Effects/GUI_Sound_Effects_030.ogg","static")
elseif mx>1150 and mx<1226 and my>149 and my<224 and touchinterfaceison==true and panelright==true then --levelselection menu
shader2=false
gamestatus="levelselection"
TEsound.play("externalassets/sounds/GUI_Sound_Effects/GUI_Sound_Effects_030.ogg","static")
love.timer.sleep( 0.3 )
elseif mx>1170 and mx<1225 and my>315 and my<395 and touchinterfaceison==true then if panelright==true then touchinterfaceison=false gui21:play() love.timer.sleep( 0.3 ) elseif touchinterfaceison==false and panelright==true then touchinterfaceison=true love.timer.sleep( 0.3 ) end --Touch controls on / off
--panels
elseif mx>1170 and mx<1225 and my>400 and my<470 and touchinterfaceison==true then if panelright==true then gui21:play() love.timer.sleep( 0.3 ) panelright=false elseif panelright==false and touchinterfaceison==true then gui24:play() love.timer.sleep( 0.3 ) panelright=true end --panel right show / hide
elseif mx>500 and mx<600 and my>900 and my<1000 and touchinterfaceison==true then if ispaneldown==true then gui21:play() love.timer.sleep( 0.3 ) ispaneldown=false elseif ispaneldown==false and touchinterfaceison==true then gui24:play() love.timer.sleep( 0.3 ) ispaneldown=true end --panel down show / hide
--dialogs off
elseif mx>35 and mx<95 and my>730 and my<807 and talkies==true then gui21:play() talkies=false
--read dialogs
elseif mx>265 and mx and my>730 and my<807 and talkies==true then Talkies.onAction() love.timer.sleep( 0.2 )
--dialogs on
elseif mx>200 and mx<288 and my>830 and my<985 and touchinterfaceison==true and ispaneldown==true and talkies==false then
talkies=true createcanvas()
if nLevel==1 then Obey.lev1()
elseif nLevel==2 then Obey.lev2()
elseif nLevel==3 then Obey.lev3()
elseif nLevel==4 then Obey.lev4()
elseif nLevel==5 then Obey.lev5()
elseif nLevel==6 then Obey.lev6()
elseif nLevel==7 then Obey.lev7()
end
--sound
elseif mx>300 and mx<375 and my>900 and my<980 and touchinterfaceison==true and soundon==true and ispaneldown==true and talkies==false then soundon=false gui21:play() love.timer.sleep( 0.2 ) nLevel=nLevel-1 changelevel() --turn sounndon on
elseif mx>300 and mx<375 and my>900 and my<980 and touchinterfaceison==true and soundon==false and ispaneldown==true and talkies==false then soundon=true gui21:play() love.timer.sleep( 0.2 ) nLevel=nLevel-1 changelevel()--turn sounndon on
--music
elseif mx>400 and mx<473 and my>900 and my<970 and touchinterfaceison==true and ispaneldown==true and talkies==false and musicison==true then gui21:play() musicison=false --turn music off
--if player:hasEnded() then player:play(true) else player:stop() end
love.timer.sleep( 0.2 )
if assets==2 then
love.audio.stop()
end
elseif mx>400 and mx<473 and my>900 and my<970 and touchinterfaceison==true and ispaneldown==true and talkies==false and musicison==false then gui21:play() musicison=true --turn music on
--if player:hasEnded() then player:play(true) else player:stop() end
love.timer.sleep( 0.2 )
if assets==2 then
nLevel=nLevel-1
changelevel()
end
elseif mx>1150 and mx<1226 and my>249 and my<306 and touchinterfaceison==true then if screenoptions==false then gui21:play() screenoptions=true end --screen options menu
--crteffect
elseif mx>200 and mx<290 and my>300 and my<360 and touchinterfaceison==true and screenoptions==true then gui21:play() love.timer.sleep( 0.3 ) if shader1==true then shader1=false elseif shader1==false then shader1=true end
--shadertoy
elseif mx>400 and mx<490 and my>300 and my<360 and touchinterfaceison==true and screenoptions==true then gui21:play() love.timer.sleep( 0.3 ) if shader2==true then shader2=false elseif shader2==false then shader2=true end
--change color
elseif mx>600 and mx<690 and my>300 and my<360 and touchinterfaceison==true and screenoptions==true then shader2=false gui21:play() love.timer.sleep( 0.3 ) shader2=false palette=palette+1 createcanvas() if palette>7 then palette=0 end if palette==1 then shader2=true end
--3d on off
elseif mx>200 and mx<290 and my>500 and my<560 and touchinterfaceison==true and screenoptions==true then gui21:play() love.timer.sleep( 0.3 ) if threeD==true then threeD=false elseif threeD==false then threeD=true end
--diorama
elseif mx>400 and mx<490 and my>500 and my<560 and touchinterfaceison==true and screenoptions==true then gui21:play() love.timer.sleep( 0.3 ) if screensaver==false then screensaver=true shader2=true threeD=true elseif screensaver==true then screensaver=false end
-- screen resolution
elseif mx>600 and mx<690 and my>500 and my<560 and touchinterfaceison==true then --res=res+1 love.timer.sleep( 0.3 ) changeresolution()
love.graphics.setColor(1,1,1)
love.graphics.rectangle('fill',600,600,300,150)
love.graphics.setColor(0,0,0)
love.graphics.print("This option is still under development",600,620)
love.graphics.print("Use the key -R- to change resolution",600,650)
-- level editor
--[[elseif mx>200 and mx<290 and my>700 and my<760 and touchinterfaceison==true then
love.timer.sleep( 0.5 )
TEsound.play("externalassets/sounds/GUI_Sound_Effects/GUI_Sound_Effects_030.ogg","static")
essenceeditor = require ('leveleditor')
--touchinterfaceison=false
--leveleditor=true
--gamestatus="game"
--]]
-- Close screen options
elseif mx>400 and mx<470 and my>700 and my<760 and touchinterfaceison==true then gui24:play() screenoptions=false
end
end
end