Skip to content

Instantly share code, notes, and snippets.

@shakesoda
shakesoda / utf8.lua
Last active August 29, 2015 14:08 — forked from markandgo/utf8.lua
-- $Id: utf8.lua 179 2009-04-03 18:10:03Z pasta $
--
-- Provides UTF-8 aware string functions implemented in pure lua:
-- * string.utf8len(s)
-- * string.utf8sub(s, i, j)
-- * string.utf8reverse(s)
-- * string.utf8char(unicode)
-- * string.utf8unicode(s, i, j)
-- * string.utf8gensub(s, sub_len)
--
@shakesoda
shakesoda / save-the-world.diff
Last active August 29, 2015 14:08
add line drawing mode (really useful for debugging) and fix crash on non-OS X in love-experiments vertex buffer branch
diff -r 125cff058bd5 src/modules/graphics/opengl/Mesh.cpp
--- a/src/modules/graphics/opengl/Mesh.cpp Mon Jun 02 00:22:41 2014 -0300
+++ b/src/modules/graphics/opengl/Mesh.cpp Sat Oct 25 10:12:35 2014 -0700
@@ -581,6 +581,8 @@
{
case DRAW_MODE_FAN:
return GL_TRIANGLE_FAN;
+ case DRAW_MODE_LINES:
+ return GL_LINES;
case DRAW_MODE_STRIP:
@shakesoda
shakesoda / color-correct.glsl
Created October 26, 2014 23:57
color correction shader (gutted out of a larger post processing shader)
// For textureSize2D, etc.
#extension GL_EXT_gpu_shader4 : enable
uniform int u_color_correct = 0;
// Sort of a hack: LOVE doesn't expose 3D textures, so we have to sample them
// as 2D and interpolate the samples ourselves.
uniform sampler2D u_lut_primary;
uniform sampler2D u_lut_secondary;
uniform float u_factor = 0.0;
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <cstdio>
#ifdef _MSC_VER
// I really don't give a shit about your deprecation warnings, MSVC.
#pragma warning(disable: 4996)
#define usleep _sleep
#else
#include <unistd.h>
@shakesoda
shakesoda / textinput-polyfill.lua
Last active August 29, 2015 14:20
Love 0.10 setTextInput polyfill for 0.9.2
local ffi = require "ffi"
ffi.cdef [[
typedef struct SDL_Rect
{
int x, y;
int w, h;
} SDL_Rect;
void SDL_SetTextInputRect(SDL_Rect *rect);
]]

Creating a new Screen

Defining metrics

Screens need to be defined in a theme's metrics file to be available. At a minimum you must define a screen's name, class, next and previous screen. Different screen classes need different things to work, here is a basic ScreenAttract:

; Screen name
-- note: https://raw.githubusercontent.com/alexander-yakushev/awesompd/master/utf8.lua
print = function(...)
local str = ""
local num = select("#", ...)
for i = 1, num do
str = str .. tostring(select(i, ...))
if i < num then
local len = utf8.len(str) + 1
local tab = 8
@shakesoda
shakesoda / banner_wheel.md
Last active August 29, 2015 14:25
some early work in progress stepmania docs for the wiki

Creating a banner wheel

The wheel transform is up to you, buddy.

Files

  • Graphics/MusicWheelItem SectionCollapsed NormalPart
  • Graphics/MusicWheelItem SectionExpanded NormalPart
  • Graphics/MusicWheelItem Song NormalPart
  • Graphics/MusicWheelItem Portal NormalPart
  • Graphics/MusicWheelItem Random NormalPart
@shakesoda
shakesoda / en.lua
Last active August 29, 2015 14:27
Some translation utilities for LD33. Uses memoize module if available (I use this: https://github.com/airstruck/knife/blob/master/knife/memoize.lua)
return {
locale = "en",
base = "assets/audio/en",
quotes = { "\"", "\"" },
strings = {
welcome = { text = "Sup" }
hello = { text = "Hello!", audio = "hello.ogg" }
}
}
@shakesoda
shakesoda / anchor.lua
Created August 20, 2015 22:42
Anchor - utilities for screen positioning (with overscan support and centering adjustment)
-- Helper utilities for positioning things relative to screen anchor points and
-- dealing with overscan.
--
-- Use the default instance or make a new one with anchor.new(params) or using
-- anchor(params). You can control X and Y offset and padding for all 4 edges.
--
-- This library does not retain state for screen dimensions, so resizing should
-- be perfectly fine.
local anchor = {}