Skip to content

Instantly share code, notes, and snippets.

View qpfiffer's full-sized avatar
🔚

Quinlan Pfiffer qpfiffer

🔚
View GitHub Profile
@qpfiffer
qpfiffer / gist:674796
Created November 12, 2010 22:16
hashing function
// I think this works correctly...
int stringSize = strlen(s);
int i(0), j(0);
int runTotal(0);
for(;i<stringSize;i++) {
int temp = (int)s[i];
for(j=0;j<(stringSize-(i+1));j++) {
temp *= 31;
}
runTotal += temp;
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
const int N = 16;
struct Names
@qpfiffer
qpfiffer / TerribleDetection.cpp
Created June 30, 2011 07:22
Shitty collision detection
if (floorPads1.floorPadsPlaces[localPlayerPos[2]][localPlayerPos[0]] == 1) {
return 1;
}
else // Redundant but FUCK YOU
return 0;
//glEnable(GL_LIGHTING); //GO TO HELL
newRoomOrigin[i] = newRoomOrigin[i] + newRoomDim[i]; // Just look at it you dumbass
@qpfiffer
qpfiffer / snippets.cpp
Created July 15, 2011 16:37
Ode to .NET:
/* This: */
if (((System::Collections::IList ^)filterData->OpenSubKey("day_filter")->GetSubKeyNames())->Contains("days") == true) {
...
}
/* Or this: */
using System::Collections;
...
for (int i=0;i<nHands;i++) {
ArrayList<pCard.Card> player = new ArrayList<pCard.Card>();
int playerScore = 0;
for (int j=0;j<cardsPerHand;j++) {
try {
player.add(deck.get(i+(j*nHands)));
} catch (IndexOutOfBoundsException e) {
System.out.println("Not enough cards for that player/hands combination.");
System.exit(1);
}
@qpfiffer
qpfiffer / awesome.xml
Created July 21, 2011 02:39
BEAUTIFUL XML FOR CAT
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<!-- TODO: replace this Asset with your own XML asset data. -->
<Asset Type="DataTypes.LevelData[]">
<Item>
<WorldSize>15 15</WorldSize>
<TileSize>5 5</TileSize>
<WormNum>1</WormNum>
<LineNum>0</LineNum>
<MazeRooms>4</MazeRooms>
@qpfiffer
qpfiffer / awesome.cpp
Created July 21, 2011 16:53
More .NET beauty, inorite?
for each (Generic::KeyValuePair<String ^, List<String ^> ^> ^item in temp->NameToDataMap) {
if (mergeInto->NameToDataMap->ContainsKey(item->Key)) {
for each (String ^subString in temp->NameToDataMap[item->Key]) {
mergeInto->NameToDataMap[item->Key]->Add(subString);
}
} else {
mergeInto->NameToDataMap->Add(item->Key, item->Value);
}
}
@qpfiffer
qpfiffer / streakyConcrete.cs
Created July 27, 2011 05:18
Streaky Concrete
public static void modConcrete(ref Texture2D modify, GraphicsDevice gDevice, Random tRandom)
{
if (modify == null)
throw new Exception("Null texture.");
//float colorFloat = (float)(tRandom.Next(25, 75)) / 255.0f;
//Color bgColor = new Color(colorFloat, colorFloat, colorFloat, 1.0f);
Color setColor;
simplexCarmody simC = new simplexCarmody(tRandom);
double noise = 0f;
@qpfiffer
qpfiffer / concGen.cs
Created July 27, 2011 16:07
Concrete TextureGen
public static void modConcrete(ref Texture2D modify, GraphicsDevice gDevice, Random tRandom)
{
if (modify == null)
throw new Exception("Null texture.");
//float colorFloat = (float)(tRandom.Next(25, 75)) / 255.0f;
//Color bgColor = new Color(colorFloat, colorFloat, colorFloat, 1.0f);
Color setColor;
simplexCarmody simC = new simplexCarmody(tRandom);
double noise = 0;
@qpfiffer
qpfiffer / simplexC.cs
Created July 27, 2011 16:13
Carmody's implementation of Simplex noise in C#
public class simplexCarmody
{
int[] T;
private static int i, j, k;
private static int[] A = new int[3]{0, 0, 0};
private static float u, v, w, s;
private static float onethird = 0.333333333f;
private static float onesixth = 0.166666667f;
public simplexCarmody(Random randObj)