This file contains 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 poof = {} | |
--Version 0.2a | |
--By The0x539 | |
--To poof a layer, use poof.startPoof(layer, frames, freeze) in your LunaLua file after loading the API. | |
--layer specifies which layer gets poof'd | |
--frames specifies the number of frames (give or take one or two, somebody teach The0x539 some computer science) between poofing each thing. | |
--freeze specifies whether time should be frozen starting when the camera moves, and ending when it's back at the player. | |
--If freeze == true, time is frozen. If freeze == false, player input is locked instead. |
This file contains 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 viewport = {} | |
viewport.width, viewport.height = 640,480 | |
local cam = Camera.get()[1] | |
local buffer = Graphics.CaptureBuffer(cam.width,cam.height) | |
function viewport.onInitAPI() | |
registerEvent(viewport,"onCameraUpdate") | |
end |
This file contains 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 _X = {} | |
local names = {} | |
--Resolves a file. Can be expanded to include directories like graphics or resources or what have you. | |
function _X.loadFile(name) | |
return Misc.resolveFile(name) | |
end | |
--Loads an API into _X, such that it can be accessed as a global from any code using _x |
This file contains 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
// Copyright 2015 Light Code Labs, LLC | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains 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
--Run an OS command, returning its output rather than its exit status. | |
local function run(cmd,mode) | |
local prog = io.popen(cmd) | |
local output | |
if mode == 1 then --String of full output | |
output = prog:read("*all"):sub(1,-2) | |
prog:close() | |
elseif mode == 2 then --Table of each line | |
output = {} | |
for line in prog:lines() do |
This file contains 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 player.speedX ~= 0 then | |
local direction = (player.speedX > 0 and 1 or -1) | |
local amt = 0 | |
local fwd, back = player.rightKeyPressing, player.leftKeyPressing | |
if direction < 0 then | |
fwd, back = back, fwd | |
end | |
local run = player.runKeyPressing | |
local gnd = player:isGroundTouching() |
This file contains 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 memo_mt = {__mode = "k"} | |
-- Memoize a function with one argument. | |
local function memoize(func) | |
local t = {} | |
setmetatable(t, memo_mt) | |
return function(x) | |
if t[x] then | |
return table.unpack(t[x]) | |
else |
This file contains 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 blocks = {} | |
local function tris(x, y, w, h) | |
return { | |
x, y, | |
x+w, y, | |
x+w, y+h, | |
x, y, | |
x, y+h, | |
x+w, y+h |
This file contains 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
#include <stdlib.h> | |
#include <string.h> | |
typedef unsigned int uint; | |
static void split_array(int array[], uint len, int **left, uint *llen, int **right, uint *rlen) { | |
*llen = *rlen = len / 2; | |
if (*llen + *rlen < len) { | |
*llen = *llen + 1; | |
} | |
size_t lsize = *llen * sizeof (int); |
This file contains 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
#include <stdlib.h> | |
#include <string.h> | |
typedef unsigned int uint; | |
static void split_array(void *array[], uint len, void ***left, uint *llen, void ***right, uint *rlen) { | |
*llen = *rlen = len / 2; | |
if (*llen + *rlen < len) { | |
*llen = *llen + 1; | |
} | |
size_t lsize = *llen * sizeof (void *); |
OlderNewer