Skip to content

Instantly share code, notes, and snippets.

for(Map.Entry<Integer, String> entry : map.entrySet()){
System.out.printf(entry.getKey() + " || " + entry.getValue());
}
@poemdexter
poemdexter / CreateWorldMesh.cs
Created September 8, 2014 18:48
Creates a mesh where every triangle has a unique set of verts.
using System;
using UnityEngine;
using System.Collections;
using UnityEditor;
public class CreateWorldMesh : MonoBehaviour
{
public int dimension;
public bool isTerrain;
public float terrainPower;
@poemdexter
poemdexter / CreateWorldMesh.cs
Created August 28, 2014 14:24
Make a sweet mesh dawg. Triangles don't share verts.
using System;
using UnityEngine;
using System.Collections;
public class CreateWorldMesh : MonoBehaviour
{
public int dimension;
public void Start()
{
if (inputEnabled && Input.GetButtonDown("Button1"))
{
inputEnabled = false;
// Launch game exe
}
using UnityEngine;
using System.Collections;
public class KillParticleEffect : MonoBehaviour
{
void Update()
{
if (!particleSystem.IsAlive())
Destroy(this.gameObject);
}
using UnityEngine;
using System.Collections;
/**
* A camera to help with Orthagonal mode when you need it to lock to pixels. Desiged to be used on android and retina devices.
*/
public class PixelPerfectCam : MonoBehaviour
{
/**
@poemdexter
poemdexter / raycast.cs
Created July 5, 2014 04:12
2D raycast for Unity3D
RaycastHit2D hit = Physics2D.Raycast((Vector2)transform.position, direction, length, layerMask);
// check hit in direction
if (hit.collider != null) {
// we hit something check what it is
if (hit.collider.gameObject.CompareTag("wall")) {
// we hit a wall so don't translate in this direction
}
}
@poemdexter
poemdexter / TileManager.cs
Last active December 23, 2019 16:27
Representing a 2D array as a 1D array with wrapping sides (up at top of 1st column will place you bottom of 1st column)
using UnityEngine;
using System.Collections;
public class TileManager : MonoBehaviour
{
public GameObject walkableTile;
public GameObject blockingTile;
private GameObject[] tiles = new GameObject[25];
public int offset = 0; // current position on grid array
@poemdexter
poemdexter / TiltController.cs
Last active August 29, 2015 14:00
phone tilt left/right to move thing left/right
using UnityEngine;
using System.Collections;
public class TiltController : MonoBehaviour
{
public float speed;
void Update()
{
Vector3 dir = Vector3.right * Input.acceleration.x;
@poemdexter
poemdexter / wut.java
Created April 8, 2014 20:35
a good method
@Override
public doThing(String param)
{
super.doThing(param);
}