Skip to content

Instantly share code, notes, and snippets.

View Darthfett's full-sized avatar

Casey Kuball Darthfett

View GitHub Profile
@Darthfett
Darthfett / gist:1342503
Created November 6, 2011 05:05
Lever Metadata
// Methods of Dealing with Metadata (such as whether a lever is turned on or off (powered or unpowered)
// 1:
mf.Metadata.Levers = {
"SideEastOff": 1,
"SideWestOff": 2,
"SideSouthOff": 3,
"SideNorthOff": 4,
"TopNorthOff": 5,
GLfloat LightPos[] = { 10.0f, 0.0f, 0.0f, 1.0f};
void setupProjectionMatrix() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,WindowWidth,WindowHeight);
gluPerspective(FieldOfView, AspectRatio, NearPlane, FarPlane);
glMatrixMode(GL_MODELVIEW);
}
@Darthfett
Darthfett / gist:1362315
Created November 13, 2011 16:49
print token
void printType(string type) {
if (typeOf[type].length()) {
return;
}
vector<string> matches;
for (int i = 0; i < symbols.size(); i++) {
string base = getBaseType(symbols[i]);
if (base.compare(type) == 0 && symbols[i].compare(type)) { // symbols[i]'s base is type, but isn't actually type
Camera camera = m_Scene.m_Camera;
Vector cameraPosition = camera.GetPosition();
// Camera Coordinates directions
Vector negZ = (camera.GetTarget() - cameraPosition).Normalize();
Vector posY = camera.GetUp().Normalize();
Vector posX = negZ.Cross(posY).Normalize();
float FOV = camera.GetFOV();
float nearZ = camera.GetNearClip();
// - DiffuseColor - Returns the Diffuse color for the specified material and light
Vector DiffuseColor(Vector materialDiffuse, SceneLight light, Vector normal, Vector lightv)
{
float distance = lightv.Magnitude();
float distanceTerm = 1.0f / (light.attenuationConstant + light.attenuationLinear * distance + light.attenuationQuadratic * distance * distance);
return materialDiffuse * light.color * (normal.Dot(lightv)) * distanceTerm;
}
@Darthfett
Darthfett / grade_analyzer.py
Created March 7, 2012 15:25
1. Copy and paste ASU class pages into "classes_and_grades.txt" file in same directory. Delete any empty lines and save. 2. Run script in python 3.x.
import os, sys
with open("classes_and_grades.txt") as classes_and_grades:
for line in classes_and_grades:
data = line.split("\t")
fixed = []
for item in data:
stripped = item.strip()
if stripped:
fixed.append(stripped)
@Darthfett
Darthfett / gist:3006008
Created June 27, 2012 18:56
Search directory for file
find [Path] | grep -i <file name>
# Path defaults to the current directory.
# Using -i for case-insensitive searching.
# Using -E will do regex parsing.
@Darthfett
Darthfett / gist:3166718
Created July 23, 2012 22:42
Create a tag
git tag -a Tag_Name 0123456 -m 'MessageHere'
@Darthfett
Darthfett / readme.md
Last active December 11, 2015 02:09 — forked from andrewrk/readme.md

Proposed Digging API, first pass

event "diggingCompleted"

Fires when the block you were digging has broken.

block.isDiggable

Whether the block is diggable. This returns false for air, water, lava, etc.

@Darthfett
Darthfett / gist:4602297
Created January 23, 2013 05:26
Small hack to convert normal coordinates to pygame coordinates (where y is 0 at bottom left and positive is up, instead of top left corner and positive is down).
def flip_y(y):
"""Small hack to convert normal coordinates to pygame coordinates"""
return -y+GAME_WINDOW_HEIGHT