Skip to content

Instantly share code, notes, and snippets.

@iamgreaser
iamgreaser / gist:1116213
Created July 31, 2011 00:57
raycastery
note:
dx/y/z = distance to grid boundary in coordinate direction
cx/y/z = current cell
vx/y/z = ray velocities (absolute value of each coordinate)
gx/y/z = direction each ray is going
tx/y/z = time it takes to hit a boundary, or something like that
tc = time covered when firing a ray (initialised to 0)
cell_size = size of a cell
##### # ######### ### # ##### # # ####### ##### ##
# # # # # # # # # #
##### ### ### ### # ### # ### # ### # # ### #####
# # # # # # # # # # # # # #
# # ### # ### # ######### # # ##### # # ##########
# # # # # # # # # # # #
# ### ######### # # ### ### # # ####### # # # ###
# # # # # # # # # # # # # #
######### # ######### ##### # ### # # ##### # # ##
@iamgreaser
iamgreaser / gist:1160500
Created August 21, 2011 11:41
quick template for java gfx
import java.awt.*;
import javax.swing.*;
public class GameCanvas extends JComponent
{
public static final int WIDTH = 640;
public static final int HEIGHT = 480;
public GameCanvas()
{
@iamgreaser
iamgreaser / gist:1182495
Created August 31, 2011 00:17
periods.sna source code (minus the actual sample data)
.memorymap
defaultslot 0
slotsize $8000
slot 0 $8000
slotsize $4000
slot 1 $4000
.endme
.rombankmap
@iamgreaser
iamgreaser / gist:1182606
Created August 31, 2011 01:33
ittech periods as doubles
double pitchTable[120] = {
0.03125, 0.033111572265625, 0.0350799560546875, 0.0371551513671875, 0.03936767578125, 0.041717529296875, 0.044189453125, 0.0468292236328125, 0.0496063232421875, 0.05255126953125, 0.0556793212890625, 0.058990478515625, 0.0625, 0.06622314453125, 0.070159912109375, 0.0743255615234375, 0.0787506103515625, 0.08343505859375, 0.0883941650390625, 0.0936431884765625, 0.099212646484375, 0.105117797851562, 0.111358642578125, 0.11798095703125, 0.125, 0.132431030273438, 0.140304565429688, 0.148651123046875, 0.157485961914062, 0.166854858398438, 0.176773071289062, 0.187286376953125, 0.19842529296875, 0.210220336914062, 0.22271728515625, 0.2359619140625, 0.25, 0.264862060546875, 0.280609130859375, 0.29730224609375, 0.314987182617188, 0.333709716796875, 0.353546142578125, 0.37457275390625, 0.3968505859375, 0.420440673828125, 0.445449829101562, 0.471939086914062, 0.5, 0.52972412109375, 0.561233520507812, 0.5946044921875, 0.629959106445312, 0.66741943359375, 0.707107543945312, 0.749160766601562, 0.79
@iamgreaser
iamgreaser / gist:1182688
Created August 31, 2011 02:34
this f***ing pumpkin
if(curFreq < targetFreq)
{
curFreq *= slideUpTable[effectParam];
if(curFreq >= targetFreq)
{
curFreq = targetFreq;
baseNote = targetNote;
}
} else if(curFreq > targetFreq) {
curFreq *= slideDownTable[effectParam];
@iamgreaser
iamgreaser / gist:1199267
Created September 6, 2011 23:12
How not to make a mixer (.it player component I've since polished up)
void do_channel(struct fatmodule *mod, int idx, SLONG *buf)
{
SWORD v = 0;
int pan;
int mch = (mod->chn[idx].master == -1 ? idx : mod->chn[idx].master);
if(!mod->chn[idx].tperiod)
mod->chn[idx].tperiod = mod->chn[idx].period;
@iamgreaser
iamgreaser / gist:1248984
Created September 28, 2011 19:32
pyspades build log w/ warnings
ben@95lx:~/Desktop/pyspades$ ./build.sh
Compiling ./pyspades/compression.pyx because it changed.
Compiling ./pyspades/load.pyx because it changed.
Compiling ./pyspades/bytes.pyx because it changed.
Compiling ./pyspades/packet.pyx because it changed.
Compiling ./pyspades/loaders.pyx because it changed.
Compiling ./pyspades/contained.pyx because it changed.
Compiling ./pyspades/world.pyx because it changed.
running build_ext
building 'pyspades.compression' extension
@iamgreaser
iamgreaser / gist:1292179
Created October 17, 2011 08:06
patch for /ratio for pyspades
diff -r 359d9d545a79 feature_server/commands.py
--- a/feature_server/commands.py Sun Oct 16 00:45:02 2011 +0200
+++ b/feature_server/commands.py Mon Oct 17 21:01:40 2011 +1300
@@ -239,6 +239,19 @@
raise KeyError()
return ('Your current kill streak is %s. Best is %s kills.' %
(connection.streak, connection.best_streak))
+
+def ratio(connection):
+ if connection not in connection.protocol.players:
@iamgreaser
iamgreaser / ratio.py
Created October 17, 2011 08:34
pyspades /ratio, as a script
# KDR script because Enari said so --GM
import commands
def ratio(connection, user=None):
if user != None:
connection = commands.get_player(connection.protocol, user)
if connection not in connection.protocol.players:
raise KeyError()
ratio = connection.ratio_kills/float(max(1,connection.ratio_deaths))