Skip to content

Instantly share code, notes, and snippets.

@poemdexter
poemdexter / proof.cs
Created June 19, 2013 01:42
music in unity proof of concept
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class SoundPOC : MonoBehaviour
{
FContainer container;
CBox greenbox;
bool started = false;
boolean isValid = true;
if (isValid && expensiveCheck1()) { ... }
if (isValid && expensiveCheck2()) { ... }
// expensiveCheck1() and expensiveCheck2() should set isValid = false if needed to short circuit rest of validations
@poemdexter
poemdexter / .gitignore
Created May 27, 2016 15:29
.gitignore for unity
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
# Autogenerated VS/MD solution and project files
/*.csproj
/*.unityproj
/*.sln
/*.suo
@poemdexter
poemdexter / 1_DungeonGenerator.cs
Last active May 12, 2016 13:43
C# implementation of dungeon generation based off https://github.com/adonaac/blog/issues/1
using System;
using System.Collections.Generic;
// from https://github.com/adonaac/blog/issues/1
public class DungeonGenerator
{
/** GRID OF CELLS **/
private Cell[,] grid;
private int gridWidth, gridHeight; // of grid
@poemdexter
poemdexter / dungeon.cs
Created October 16, 2015 05:29
yet another dungeon generator
using System;
using System.Collections.Generic;
// from https://github.com/adonaac/blog/issues/1
public class DungeonGenerator
{
/** GRID OF CELLS **/
private Cell[,] grid;
private int gridWidth, gridHeight; // of grid
@poemdexter
poemdexter / ian.cs
Last active March 7, 2016 16:07
flipping pixels something something for ian
/*
a 2D array can easily be represented by a standard array. given an array that has a size equal to a square number,
reverse the order of the "rows" into a new array without changing the order of the elementes in each row.
example:
oldArray newArray
row 1 [0,1,2 row 3 [6,7,8
row 2 3,4,5 --> row 2 3,4,5
row 3 6,7,8] row 1 0,1,2]
*/
Vector2 pixelToTile (Vector2 mouseInput) {
//Tiles are what size?
if (tileSize == 0) {
tileSize = tileGrid[0][0].toUse.getWidth();
}
int x = Math.floor(mouseInput.x / tileSize);
int y = Math.floor(mouseInput.y / tileSize);
@poemdexter
poemdexter / child.cs
Created January 26, 2014 07:08
get the children
foreach (Transform child in transform) {
child.parent = null;
child.collider2D.isTrigger = false;
child.rigidbody2D.isKinematic = false;
child.rigidbody2D.AddTorque(Random.Range(-torquePower, torquePower));
child.rigidbody2D.AddForce(new Vector2(Random.Range(-.5f, .5f), 1.0f) * forcePower);
}
@poemdexter
poemdexter / query.sql
Created December 18, 2013 23:13
game over yahhhhhh
select
*
from
people
where last_name in
(
select
distinct (last_name)
from
people
@poemdexter
poemdexter / Lissajou.cs
Created December 9, 2013 05:20
Pistol sway based on Lissajou curve.
using UnityEngine;
using System.Collections;
// gun sway based on lissajou curve
// formula found in example 3 of http://www.intmath.com/trigonometric-graphs/7-lissajous-figures.php
public class Lissajou : MonoBehaviour
{
float local_X;
float local_Y;
float t = 0;