Skip to content

Instantly share code, notes, and snippets.

@Zerophase
Zerophase / gist:5836180
Last active December 18, 2015 19:49
Example code
private void setBooleanArg (char argChar, boolean value)
{
booleanArgs.get(argChar).setBoolean(value);
}
public boolean getBoolean(char arg)
{
return falseIfNull (booleanArgs.get(arg).getBoolean());
}
private void setBooleanArg(char argChar, bool value)
{
if (booleanArgs.ContainsKey(argChar))
booleanArgs.Remove(argChar);
booleanArgs.Add(argChar, Am.setBool(value));
}
public bool GetBoolean(char arg)
{
public abstract class GenericParserTests<T>
where T : IStringParser
{
protected abstract string GetInputHeaderSingleDigit();
// creates and returns intance of class inheriting from IStringParser
protected T GetParser(string input)
{
return (T)Activator.CreateInstance(typeof(T), input);
}
// Rotating with Quaternions.
Quaternion rotation = Quaternion.LookRotation(transform.position);
rotation *= Quaternion.Euler(0f, 90f, 0f);
transform.rotation =
Quaternion.Slerp(gameObject.transform.rotation, rotation, 1f); // place holder for testing final position.
// Rotating with vector 3
transform.eulerAngles += Vector3.Slerp(gameObject.transform.position,
gameObject.transform.position + new Vector3(0f, 90f, 0f), 1f); // place holder for testing final position
Quaternion target = Quaternion.Euler(0f, 90f, 0f);
transform.rotation = Quaternion.Slerp(transform.rotation, transform.rotation * target, 1f); // place holder value
@Zerophase
Zerophase / Ball
Created July 17, 2014 18:37
Interface Example for bounce
public class Ball : MonoBehaviour
{
private IBounce bounce;
public void Initialize(IBounce bounce)
{
this.bounce = bounce;
}
void Update ()
@Zerophase
Zerophase / Ball
Last active August 29, 2015 14:04
public class Ball : MonoBehaviour
{
private IBounce bounce;
public void Initialize(IBounce bounce)
{
this.bounce = bounce;
}
void Update ()
Public class DoSomething : IDoSomething
{
public void DoSomethingCool()
{
//Do Something Cool
}
}
@Zerophase
Zerophase / Board
Created October 15, 2014 10:11
Tower of Hanoi Peg to move from code
Peg *pegToMoveFrom = nullptr;
for (auto peg = pegs.begin(); peg != pegs.end(); peg++)
{
// hard coded values need to generalize for N
// makes sure to move till all of the pegs are filled.
// Then it moves the smallest peg from the goal peg to the auxillary peg
// Then it moves the smallest peg from the auxillary peg to the start peg
// then it moves the peg on the bottom of the auxillary peg to the goal peg
// then it moves the smallest peg to the goal peg.
public Vector3 Jump(bool pressed)
{
return jumpAnimations[jumpComparision(pressed)].Invoke();
}
private int jumpComparision(bool pressed)
{
if (pressed && !savedPress && !hasJumped)
returnValue = (int)JumpComparison.ON_Press;
else if (pressed && jumpVelocity.y > 0.0f)