Skip to content

Instantly share code, notes, and snippets.

View flamendless's full-sized avatar
🎯
Focusing on Game Development and University

flamendless flamendless

🎯
Focusing on Game Development and University
View GitHub Profile
@flamendless
flamendless / mana.lua
Created March 2, 2018 08:15
Progress Bar
local classic = require("modules.classic.classic")
local guiMana = classic:extend()
function guiMana:new()
self.max = 100
self.current = 100
self.percent = 1
self.x = game.gWidth/2 + 8
self.y = game.gHeight - 3
@flamendless
flamendless / Love2D-wiki-trimmer.lua
Created March 10, 2018 14:19
Love2D api/wiki trimmer (removes non-english .html files). Also useful for other batch deletion using lua and lfs.
--LOVE2D api/wiki trimmer
--Also useful for other batch deletion using lua and lfs
--Created by Brandon Blanker Lim-it @flamendless
local lfs = require("lfs")
local toRemove = {
"_deutsch",
"_portugu",
"_fran",
@flamendless
flamendless / String-to-secret-code.lua
Created March 13, 2018 00:52
Convert string into secret code!
--Secret Code Parser - change strings into secret codes defined!
--Created by Brandon Blanker Lim-it @flamendless
local str_sample = arg[1] or "Hi, my name is Brandon"
--this is the JEJEMON trend code
local secret_code = {
a = {"4","ha","ah"},
i = "1",
e = "3",
o = "0",
local Colors = {
RESET = {1,1,1,1},
WHITE = {1,1,1},
BLACK = {0,0,0},
RED = {1,0,0},
GREEN = {0,1,0},
BLUE = {0,0,1},
}
local setup_args = function(args, tween)
local Pswap = {}
local orig_pal
local new_pal
local image
local image2
local lookup = {}
function Pswap:load()
local orig_pal_data = love.image.newImageData("orig.png")
-- Create 256 shuffled numbers
local perm = {}
for i = 1, 256 do
table.insert(perm, math.random(#perm + 1), i)
end
-- Repeat the list
for i = 1, 256 do
perm[i+256] = perm[i]
end
@flamendless
flamendless / noise-to-image.lua
Created July 10, 2018 04:27
Save a noise to a texture! thanks Positive07
local data = love.image.newImageData(w, h)
data:mapPixel(function(x,y,r,g,b,a)
local a = love.math.noise(x, y)
return a, a, a, 1
end)
if isSaveIt then
data:encode("png", filename or "noise.png")
local image = love.graphics.newImage(data)
return image
else
@flamendless
flamendless / CircleTransformation.lua
Last active September 28, 2018 04:39
Interpolate a circle to another circle (number of points/2)
local processPoints = function(shape1, shape2)
local d = #shape1/#shape2 * 2
local all = {}
for i = 1, #shape1, 2 do
all[i] = false
if i % d == 1 then
all[i] = true
end
end
return all
@flamendless
flamendless / convert-to-grayscale.lua
Created October 16, 2018 13:01
Convert a palette .png (num of colours x 1 pixel) to appropriate grayscaled palette (for colour swap shader)
function love.load()
for k, file in pairs(love.filesystem.getDirectoryItems("source")) do
convert(file)
end
end
function convert(file)
local data = love.image.newImageData("source/" .. file)
local width = data:getWidth()
local div = 255/width
@flamendless
flamendless / MakefileLoveAndroid
Last active November 8, 2018 13:51
Makefile for easier love development for android using apktool
--usage: make build-android
--usage: make apk-release VERSION=0.1.3
--note: You must still edit the versionCode in AndroidManifest.xml
SHELL := /bin/zsh
ANDROID = PATH:/opt/android-sdk/build-tools/28.0.2
LOVE_NAME = game.love
BUILD_DIR = build
OUTPUT_DIR = ${BUILD_DIR}/output
RELEASE_DIR = ${BUILD_DIR}/release
NAME = purrr