Skip to content

Instantly share code, notes, and snippets.

View Problematic's full-sized avatar

Derek Stobbe Problematic

View GitHub Profile
@Problematic
Problematic / AimingCircle.cs
Created March 7, 2014 23:46
Get the position on a circle for the direction you're aiming in Unity
Vector2 mousePos = _camera.ScreenToWorldPoint(Input.mousePosition);
Vector2 aimDirection = mousePos - (Vector2)_transform.position;
float aimAngle = Vector2.Angle(_transform.up, aimDirection);
if (Vector3.Cross(_transform.up, aimDirection).z > 0)
{
aimAngle = 360 - aimAngle;
}
Vector3 newPos = new Vector3(_transform.position.x + bulletSpawnRadius * Mathf.Sin(aimAngle * Mathf.Deg2Rad),
_transform.position.y + bulletSpawnRadius * Mathf.Cos(aimAngle * Mathf.Deg2Rad),
describe('$resource', function () {
var $httpBackend,
$rootScope,
Tasks;
beforeEach(module('ngResource'));
beforeEach(inject(function (_$httpBackend_, _$rootScope_) {
$httpBackend = _$httpBackend_;
$rootScope = _$rootScope_;
@Problematic
Problematic / Vagrantfile
Created April 14, 2014 00:56
Vagrantfile to set up postgres, redis, ruby, and rails (uses docker)
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.provision "docker" do |d|
@Problematic
Problematic / dialogBox.js
Last active August 29, 2015 14:02
Quick and easy Angular dialog box
angular.module('dialogBox', [])
.factory('DialogBox', function ($q) {
var instances = {};
function DialogBox (name) {
if (!instances[name]) {
instances[name] = $q.defer();
}
instances[name].resolve(this);
using UnityEngine;
using System.Collections;
public class EventConsumer : MonoBehaviour
{
EventProvider ep;
void Awake ()
{
ep = GetComponent<EventProvider>();
@Problematic
Problematic / MouseFollow.cs
Created August 11, 2014 02:52
Unity3D mousefollow script
using UnityEngine;
public class MouseFollow : MonoBehaviour
{
new public Camera camera;
public float zValue = 0;
public enum CoordinateSystem
{
World,
@Problematic
Problematic / FooScript.cs
Created August 16, 2014 19:44
Default new Unity script
using UnityEngine;
using System.Collections;
public class FooScript : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
using UnityEngine;
using System.Collections;
public class CoupledComponent : MonoBehaviour
{
void Update ()
{
if (Input.GetKeyDown(KeyCode.E))
{
PerformAction();
(VBoxManage list runningvms | grep "Ora_XE" && echo "Oracle VM is already running... skipping start step.") || VBoxManage startvm Ora_XE_11.2
// The only thing HSHG expects a collidable object to have is a getAABB() method that
// returns an object with two properties, min and max, that should both have a single
// array with two numbers as coordinates. For example, an object at 10, 10 and
// height/width of 100 would return { min: [10, 10], max: [110, 110] }
function Vertex(args /*x, y, radius*/){
var argProp;
for(argProp in args){
if(args.hasOwnProperty(argProp)){