This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local jprof = appleCake.jprof | |
| jprof.push("frame") | |
| jprof.push("update") | |
| jprof.popAll() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local jprof = appleCake.jprof | |
| jprof.pop("Foo") | |
| jprof.pop("Bar") | |
| jprof.pop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local appleCake = require("lib.AppleCake")(true) | |
| local jprof = appleCake.jprof | |
| appleCake.beginSession() -- or jprof.START(), if you want to only use the jprof table | |
| function love.run() | |
| love.load(love.arg.parseGameArguments(arg), arg) | |
| love.timer.step() | |
| local dt = 0 | |
| return function() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local jprof = appleCake.jprof | |
| jprof.push("Foo") | |
| jprof.push("Foo", "Bar") | |
| jprof.push("Foo", love.graphics.getStats()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local counter -- Recommedned to reuse tables for commonly used counters | |
| function state:update(dt) | |
| counter = appleCake.counter("State", {"value"=self.value, "valueZ"=self.valueZ}, counter) -- You can create overlapping bar graphs | |
| end | |
| -- record memory each update | |
| local memory | |
| function love.update(dt) | |
| memory = appleCake.counter("Memory", {"kb"=collectgarbage("count")}, memory) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local timer = 0 | |
| local sinCounter | |
| function love.update(dt) | |
| timer = timer + dt | |
| sinCounter = appleCake.counter("sin", {sin=math.sin(timer)}, sinCounter) | |
| if timer > 0.1 then | |
| appleCake.counter("memory", {memory=collectgarbage("count")}) | |
| timer = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local buffer = require("string.buffer") | |
| local serialize = { | |
| encode = function(...) | |
| local data = {} | |
| for i=1, select('#', ...) do | |
| local var = select(i, ...) | |
| if type(var) == "userdata" then | |
| var = var:getString() | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if love._version_major == "11" and jit then | |
| local ffi = require("ffi") | |
| ffi.cdef[[ | |
| typedef void SDL_Window; | |
| SDL_Window* SDL_GL_GetCurrentWindow(void); | |
| void SDL_HideWindow(SDL_Window * window); | |
| ]] | |
| local SDL2 = ffi.load("SDL2") | |
| local window = SDL2.SDL_GL_GetCurrentWindow() | |
| SDL2.SDL_HideWindow(window) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local ffi = require("ffi") | |
| ffi.cdef[[ | |
| typedef struct { | |
| union { | |
| uint64_t rgba; | |
| struct { | |
| uint8_t a; | |
| uint8_t b; | |
| uint8_t g; | |
| uint8_t r; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local scene = {} | |
| -- all functions are the same as love.* (except scene.unload) but put them in a scene table and return it at the end | |
| scene.load = function() | |
| scene.img = love.graphics.newImage("logo.png") | |
| end | |
| scene.unload = function() -- only custom function added, called before switching scenes | |
| scene.img = nil -- unload image when leaving the scene as we will never return back to this splash screen | |
| -- if you're switching between the game and another scene back and forth you won't need to keep loading the images | |
| -- therefore check if they're already loaded in `scene.load` otherwise you will be |