Skip to content

Instantly share code, notes, and snippets.

View homelinen's full-sized avatar

Calum Gilchrist homelinen

View GitHub Profile
@homelinen
homelinen / gist:4311474
Created December 16, 2012 19:07
My Island Code that does not work.
require_relative "island_tiles"
require "chingu"
include Chingu
# An area impassable to ships
# Other things can be built onto it
class Island < GameObjectMap
def initialize(options = {})
super(options)
@homelinen
homelinen / gist:4302225
Created December 16, 2012 01:52
My animated objects in Chingu. Bullet doesn't animate, for some reason.
class Bullet < Chingu::GameObject
traits :velocity, :bounding_circle
trait :animation, :delay => 200, :size => [16,16], :width => 16
def initialize(options = {})
super(options.merge(:image => Image["cannon-ball.png"]))
end
def update
@image = self.animation.next if self.animation
@homelinen
homelinen / AStar.java
Created November 21, 2012 20:07
My A* Algorithm for AI
package uk.calumgilchrist.ai.pathfinder;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import org.json.simple.JSONArray;
@homelinen
homelinen / GeneticAlgorithm.java
Created November 21, 2012 20:05
My Genetic Algorithm for AI Coursework
package uk.calumgilchrist.ai.pathfinder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Random;
[
{
"city1": "Aberdeen",
"city2": "Ayr",
"weight": 179
},
{
"city1": "Aberdeen",
"city2": "Edinburgh",
"weight": 129
@homelinen
homelinen / jsonparser.java
Created November 15, 2012 16:11
Very Simple JSON Parser
import java.io.*;
import java.util.Map;
import static java.nio.file.Files.newBufferedReader;
import static java.nio.file.Paths.get;
import static java.nio.charset.Charset.defaultCharset;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
@homelinen
homelinen / Rakefile
Created November 11, 2012 01:00
My 3D Model Rake File
#!/usr/bin/env rake
# Basic rake file
task :default => [:compile]
libraries = "-lGL -lGLU -lglut -lm"
appName = "initials"
includes = "3DCurve.cpp 3DCube.cpp drawHelpers.cpp letters.c display.c mouse.c keyboardHandler.c legs.cpp LegDefinition.cpp scene.c camera.c spider.c thorax.cpp head.cpp abdomen.cpp"
desc "Compile sources"
@homelinen
homelinen / lambda-snippet.tex
Created November 4, 2012 16:17
Lambda Calculus in LaTeX
\begin{eqnarray*}
&& (\lambda xyz.xyz)(\lambda x.xx)(\lambda x.x)x \\
& \to_\beta & (\lambda yz.xyz)[x := \lambda x.xx](\lambda x.x)x \\
& \equiv & (\lambda yz.(\lambda x.xx)yz)(\lambda x.x)x \\
& \to_\beta & (\lambda yz.(xx)[ x := y]z)(\lambda x.x)x \\
& \equiv & (\lambda yz.yyz)(\lambda x.x)x \\
& \to_\beta & (\lambda z.yy)[ y := \lambda x.x ]x \\
& \equiv & (\lambda z.(\lambda x.x)(\lambda x.x)z)x \\
& \to_\beta & (\lambda z.x[x := \lambda x.x]z)x \\
& \equiv & (\lambda z.(\lambda x.x)z)x \\
@homelinen
homelinen / old-lightbox.js
Created June 23, 2012 16:42
Lightbox I'm currently using on my website.
/*
* Title: Lightboxer
*
* AUTHOR:
* Calum Gilchrist - http://CalumGilchrist.com
*
* Description: Creates a simple, light Lightbox for viewing and looking through images, built for Gallerium Image Viewer.
*
* TODO:
* - Make the actual lightboix easier to read, in the code
public Vector3f findStartPoint(Vector3f position, float objHeight) {
Vector3f newPos = position.clone();
int center = Math.round(heightMap.getSize() / 2);
Vector3f trans = new Vector3f(center, 0, center);
position.addLocal(trans);
float yHeight = heightMap.getInterpolatedHeight(position.x, position.z) + objHeight;