Skip to content

Instantly share code, notes, and snippets.

View EngineerSmith's full-sized avatar
🔧
🦆

Engineer Smith EngineerSmith

🔧
🦆
View GitHub Profile
[{"cat":"mark","name":"Begin","ph":"i","pid":0,"tid":1074326280,"s":"p","ts":38635820939.5},{"cat":"function","dur":2.3000030517578,"name":"[email protected]#6","ph":"X","pid":0,"tid":1074326280,"ts":38635828316.2,"args":{"radian":0}},{"cat":"function","dur":108.59999847412,"name":"Draw","ph":"X","pid":0,"tid":1074326280,"ts":38635857022,"args":{"canvases":0,"images":0,"drawcalls":1,"drawcallsbatched":0,"fonts":0,"canvasswitches":0,"shaderswitches":7,"texturememory":0}},{"cat":"function","dur":2.0999908447266,"name":"[email protected]#6","ph":"X","pid":0,"tid":1074326280,"ts":38635941464.7,"args":{"radian":0.0036259999978938}},{"cat":"function","dur":26.5,"name":"Draw","ph":"X","pid":0,"tid":1074326280,"ts":38635944332.1,"args":{"canvases":0,"images":0,"drawcalls":1,"drawcallsbatched":0,"fonts":0,"canvasswitches":0,"shaderswitches":0,"texturememory":0}},{"cat":"function","dur":2.2999954223633,"name":"[email protected]#6","ph":"X","pid":0,"tid":1074326280,"ts":38635952094.9,"args":{"radian":0.060212149997824}},{"cat
local appleCake = require("AppleCake")(true) -- False will disable AppleCake for your project
appleCake.setBuffer(true) -- Buffer data, and only send it to be saved when appleCake.flush is called
appleCake.beginSession()
appleCake.mark("Begin") -- Add markers for timeless events
local r = 0
function love.update(dt)
local profileUpdate = appleCake.profileFunc({radian=r}) -- Auto-generates a name for the function, "[email protected]#7", and records the arguments
r = r + 0.5 * dt
profileUpdate:stop()
@EngineerSmith
EngineerSmith / main.lua
Last active January 30, 2020 21:32
Love2d, drawing an animated line
local lg = love.graphics
local floor = math.floor
local insert = table.insert
local image = lg.newImage("Line.png") --I used a 64x64 image to test
image:setWrap("repeat","repeat")
local iw, ih = image:getDimensions()
--Options
local frames = 20 -- Frames per line section
@EngineerSmith
EngineerSmith / train.lua
Last active January 2, 2020 21:54
Simple scrolling "mountain range" for Löve2d
local train = {}
train.__index = train
local lg, lm = love.graphics, love.math
local MAXY = 1000
-- We use the previous value so that it doesn't get too crazy looking
-- Will need better generation which min and max so it doesn't go up or down forever
local function generateValue(previous) return (lm.random(20)-10)*2+previous*0.25 end
@EngineerSmith
EngineerSmith / anchor.lua
Last active April 12, 2020 19:31
Script used to reposition GUI elements when window resizes
local floor = math.floor
local point = {
Center = 0,
North = 1,
NorthWest = 2,
West = 3,
SouthWest = 4,
South = 5,
SouthEast = 6,