Skip to content

Instantly share code, notes, and snippets.

import UnityEngine
class Health(MonoBehaviour):
public health as single
def Damage(amount as single):
health -= amount
NotifyDeath() if health < 0f
def NotifyDeath():
@LoganBarnett
LoganBarnett / TankMovement.boo
Created March 15, 2011 03:41
Tank movement Boo example
import UnityEngine
import Finput
#import Input
class TankMovement(MonoBehaviour):
public wheels as GameObject
public speed = 100.0f
public breaking = 50.0f
wheelColliders as List of WheelCollider
@LoganBarnett
LoganBarnett / TankMovement.cs
Created March 15, 2011 03:49
TankMovement example in C#
using UnityEngine;
using Finput;
// using Input;
public class TankMovement : MonoBehaviour
{
public GameObject wheels;
public float speed = 100.0f;
public float breaking = 50.0f;
float List<WheelCollider> wheelColliders;
~/Projects/Jetpack$ MONO_PATH=/Applications/Unity/Unity.app/Contents/Frameworks/Managed nunit-console2 Library/ScriptAssemblies/*.dll
NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Unix 10.6.0.0
CLR Version: 2.0.50727.1433 ( 2.10.1 (tarball Fri Feb 25 15:56:49 MST 2011) )
@LoganBarnett
LoganBarnett / Once.boo
Created March 27, 2011 14:51
Attribute based memoizing
"""
doing expensive processing
1234
1234
"""
import Useful.Attributes from "Boo.Lang.Useful"
class OnceTest:
@LoganBarnett
LoganBarnett / FindTheError1.cs
Created April 8, 2011 17:47
Find the compiler error
void SomeMethod() {
try {
var foo = DoSomethingThatMightBreak();
} catch {
// handle
}
var foo = "asdf";
}
@LoganBarnett
LoganBarnett / GetSideOffset.boo
Created April 30, 2011 18:24
Gimmie the side as a vector 3, plus an offset for anti z-fighting
def GetSideOffset(normalized as Vector3, additionalOffset as single):
absX = Mathf.Abs(normalized.x)
absY = Mathf.Abs(normalized.y)
absZ = Mathf.Abs(normalized.z)
if absX > absY and absX > absZ:
if normalized.x > 0:
return Vector3.right * additionalOffset
else:
return Vector3.left * additionalOffset
elif absY > absZ and absY > absZ:
@LoganBarnett
LoganBarnett / CallbacksInEvents.cs
Created June 21, 2011 17:09
Demonstrates callbacks inside events using Action<T> or Func<T>
public delegate void CreateThingHandler(Func<Thing, Thing> preCreate, Thing thing);
public class Thing
{
public static event CreateThingHandler OnMadeThing;
public bool Valid { get; set;}
List<Thing> things = new List<thing>();
public static Thing MakeThing(Func<Thing, Thing> func)
{
@LoganBarnett
LoganBarnett / .gitconfig
Created August 24, 2011 15:48
git w/ diffmerge
[user]
name = Logan Barnett
email = [email protected]
[color]
status = auto
branch = auto
diff = auto
[mergetool "diffmerge"]
cmd = /Applications/DiffMerge.app/Contents/MacOS/DiffMerge \
--nosplash \
@LoganBarnett
LoganBarnett / ssh-copy-id
Created September 3, 2011 00:26
ssh copy for mac
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/id_rsa.pub"
if [ "-i" = "$1" ]; then