Skip to content

Instantly share code, notes, and snippets.

View EngineerSmith's full-sized avatar
🔧
🦆

Engineer Smith EngineerSmith

🔧
🦆
View GitHub Profile
local lily = require("Lib.Lily")
local global = require("Scripts.global")
local file = require("Scripts.Utilities.file")
local insert = table.insert
local lilyLoaders = {
png = "newImage",
jpg = "newImage",
jpeg = "newImage",
local lg = love.graphics
local canvas = lg.newCanvas(128,128) -- treat canvas as your sprite, but I was too lazy to draw a debug image, so I made one from a canvas
lg.setCanvas(canvas) -- French flag debug graphic
lg.clear(1,1,1)
lg.setColor(0.2,0.2,0.8)
lg.rectangle("fill", 0, 0, 43,128)
lg.setColor(0.8,0.2,0.2)
lg.rectangle("fill",88,0, 43,128)
lg.setColor(1,1,1)
lg.setCanvas()
love.graphics.setColorHex = function(r, g, b, a)
r,g,b,a = r or 255, g or 255, b or 255, a or 255
assert(r <=255 and r >= 0, "Given R value is not in the range of 0-255")
assert(g <=255 and g >= 0, "Given G value is not in the range of 0-255")
assert(b <=255 and b >= 0, "Given B value is not in the range of 0-255")
assert(a <=255 and a >= 0, "Given A value is not in the range of 0-255")
love.graphics.setColor(r/255,g/255,b/255,a/255)
end
local lg, lm = love.graphics, love.math
local infected = {0.8,0.2,0.2}
local normal = {0.4,0.4,0.7}
local radius, speed = 5, 75
local circles = {}
for i=1, 100 do
circles[i] = {
x = lm.random(radius, lg.getWidth()-radius),
y = lm.random(radius, lg.getHeight()-radius),
local PATH = ....."."
local dirPATH = PATH:gsub("%.","/")
local helium = require("Lib.helium")
local lg = love.graphics
local function resize(element, w, h)
if element.anchor then
local v = element.view
v.x, v.y, v.w, v.h = element.anchor:getRect(w, h)
local sceneManager = {
currentScene = nil,
nilFunc = function() end,
sceneHandlers = {
-- GAME LOOP
"load",
"unload", -- added for sceneManager
"update",
"updateNetwork", -- added with custom love.run for multiplayer
"draw",
local appleCake = require("AppleCake")(true) -- Controls if AppleCake is disabled on all threads
appleCake.beginSession()
local thread
function love.quit()
appleCake.mark("Quit", "p")
thread:wait()
appleCake.endSession() -- Only the thread that started the session can end it
-- If you end the session while the the thread is still trying to use appleCake, it will throw an error that no session is active
function state:start()
appleCake.mark("State X began", "t") -- marked as "t" means it won't stand out as much as a "p" in data, see docs or tracing tutorial
end
function love.keypressed(key, scancode, isrepeat)
appleCake.mark("Key pressed", nil, {key = key, code = scancode, isrepeat = isrepeat})
-- by default, nil is "p"
end
local profileUpdate -- Recommended to reuse tables for commonly hit profiles to avoid recreating tables often
function love.update(dt) -- Will be profiled as "update#gettingstarted2.lua#2"
profileUpdate = appleCake.profileFunc(nil, profileUpdate)
--...
profileUpdate:stop()
end
local profileDraw
function love.draw() -- Will be profiled as "draw#gettingstarted2.lua#9"
profileDraw = appleCake.profileFunc(nil, profileDraw)
local appleCake = require("AppleCake")(true)
appleCake.beginSession() -- writes to "profile.json" by default
function love.quit()
appleCake.endSession()
end