Skip to content

Instantly share code, notes, and snippets.

View YellowAfterlife's full-sized avatar

Vadym Diachenko YellowAfterlife

View GitHub Profile
@YellowAfterlife
YellowAfterlife / love2d.txt
Created December 13, 2014 14:32
Love2d 0.8 (?) function list for use in Notepad++ style configurator
Data Object love.draw love.focus love.joystickpressed love.joystickreleased love.keypressed love.keyreleased love.load love.mousepressed love.mousereleased love.quit love.run love.update Source SourceType love.audio.getNumSources love.audio.getOrientation love.audio.getPosition love.audio.getVelocity love.audio.getVolume love.audio.newSource love.audio.pause love.audio.play love.audio.resume love.audio.rewind love.audio.setOrientation love.audio.setPosition love.audio.setVelocity love.audio.setVolume love.audio.stop Event love.event.clear love.event.poll love.event.pump love.event.push love.event.wait File FileData FileDecoder love.filesystem.enumerate love.filesystem.exists love.filesystem.getAppdataDirectory love.filesystem.getLastModified love.filesystem.getSaveDirectory love.filesystem.getUserDirectory love.filesystem.getWorkingDirectory love.filesystem.init love.filesystem.isDirectory love.filesystem.isFile love.filesystem.lines love.filesystem.load love.filesystem.mkdir love.filesystem.newFile love.file
for (i in 0 ... 5) {
switch (i) {
case 3: switch (i) {
case 3: break;
case 4:
}
}
}
var j:Int = 0;
while (++j < 5) switch (j) {
public static function run() {
for (i in 0 ... 5) {
switch (i) {
case 3: switch (i) {
case 3: break;
}
}
trace(i);
}
}
@YellowAfterlife
YellowAfterlife / SpelunkySD.txt
Created October 24, 2014 18:12
Spelunky SD readme snip (October 2014)
_____________________
/ Spelunky SD
A Spelunky Classic mod
by YellowAfterlife
This is a modification and expansion of "Spelunky Classic" by Derek Yu.
It changes and improves a number of things in the game, most notably adding
2-player cooperative online multi-player support.
Useful links:
package openfl.state;
import openfl.events.Event;
import openfl.events.KeyboardEvent;
import openfl.Lib;
/**
* Provides a simple interface to get keyboard state.
* @author YellowAfterlife
*/
class Keyboard {
// Experimenting with custom JSON serialization.
// Things that annoy me in existing implementation are:
// * Ordering: Since haxe.Json takes dynamic objects, field order cannot be warranted.
// If resulting JSON has to be viewed/edited manually, uncertain order is no help.
// * Readability: You have no control over how contents are written. Prettyprint gets bulky fast.
// * Typing: JSON nodes are, by definition, dynamic objects, which means that you'll most
// likely have to implement an extra I/O layer with "data from class N" typedefs.
// * Efficiency: Dynamic objects and arrays are read only to (most often) be thrown again later.
//
// So here I'm working on a library that solves a fair of these problems by providing
@YellowAfterlife
YellowAfterlife / ImplementsHaxe.java
Created September 23, 2014 20:24
This is what you have to do to interface from Java with a Haxe interface, as they all implement IHxObject for no particular reason.
import java.lang.Object;
import java.lang.String;
public class JavaClass implements HaxeInterface {
// ...
// Dummy IHxObject implementation:
public boolean __hx_deleteField(String f) { return false; }
public Object __hx_lookupField(String f, boolean e, boolean c) { return null; }
public double __hx_lookupField_f(String f, boolean e) { return 0.0; }
public Object __hx_lookupSetField(String f, Object v) { return null; }
/// Create:
globalvar mouse_x0, mouse_y0, mouse_x1, mouse_y1, mouse_dx, mouse_dy;
mouse_x1 = mouse_x
mouse_y1 = mouse_y
mouse_dx = 0
mouse_dy = 0
/// Step:
mouse_x0 = mouse_x1; mouse_x1 = mouse_x
mouse_y0 = mouse_y1; mouse_y1 = mouse_y
@YellowAfterlife
YellowAfterlife / assign-operator.lua
Created September 17, 2014 14:29
Comparisons for what is "var2 = (var1 = value)" in other languages.
function set_field(t, f, v)
t[f] = v
return v
end
local n = 10000000
local t = { }
local q
local p
-- Direct:
q = os.clock()
function printTry(e1:haxe.macro.TypedExpr, catches: Array<{ v : haxe.macro.TVar, expr : haxe.macro.TypedExpr }>)
{
// TODO catch other types of exceptions
// getting last (e:Dynamic) catch:
var _dynCatch = catches.pop(), _tabs;
// try-block:
var s = 'local try, catch = pcall(function ()';
_tabs = tabs; tabs += tabString;
var tryBlock = printExpr(e1);