Skip to content

Instantly share code, notes, and snippets.

@poemdexter
poemdexter / JONTERP.cs
Last active August 29, 2015 13:55
ping pong dongs
// POWvalue is current value of potential score
// POWProgress.value is current position of POW bar
void Increment()
{
we initiate a new float every Increment() that will hold new value of the POWProgress.value as it pingpongs
POWProgress.value = Mathf.PingPong(Time.deltaTime, 1);
}
int Calculate()
using UnityEngine;
using System.Collections;
public class PlayerSwingSword : MonoBehaviour
{
public bool isSwinging = false;
Quaternion startRotation;
Animator animator;
void Start()
@poemdexter
poemdexter / screenlock.cs
Last active August 29, 2015 13:57
Lock mouse cursor on screen
void Start()
{
Screen.lockCursor = true; // lock mouse cursor on screen at start
}
void Update()
{
if (Input.GetMouseButtonDown(0)) // keep mouse cursor locked when we come back (left click)
Screen.lockCursor = true;
}
@poemdexter
poemdexter / ScrollingBackground.cs
Created March 20, 2014 17:33
Scrolling Background for Unity3D. Set tile prefab, amount of tiles, tileWidth, and speed in inspector.
using UnityEngine;
using System.Collections;
public class ScrollingBackground : MonoBehaviour
{
public GameObject backgroundTile;
public int tileAmount;
public float tileWidth;
public float backgroundSpeed;
@poemdexter
poemdexter / CameraFollowPlayer.cs
Created March 22, 2014 05:40
Camera follows player and lerps appropriately.
using UnityEngine;
using System.Collections;
public class CameraFollowPlayer : MonoBehaviour
{
public float smooth = 1.5f; // The relative speed at which the camera will catch up.
private Transform player; // Reference to the player's PlayerMovement script.
private Vector3 relCameraPos; // The relative position of the camera from the player.
private float relCameraPosMag; // The distance of the camera from the player.
private Vector3 newPos; // The position the camera is trying to reach.
@poemdexter
poemdexter / ScreenShake.cs
Last active August 29, 2015 13:57
BE LIKE VLAMBEER TODAY!!!
using UnityEngine;
using System.Collections;
public class Screenshake : MonoBehaviour
{
public float shakeAmount = 0.7f;
public float decreaseFactor = 1.0f;
private float shake;
private bool shakeEnded = true;
@poemdexter
poemdexter / issue.cs
Created March 26, 2014 16:54
Prime[31] Windows Phone Admob issue
public void ShowBanner()
{
// DOES NOT SHOW IMPRESSIONS
WinPhoneAdMob.createBanner("ca-app-pub-xxxxxx", AdFormat.SmartBanner, AdHorizontalAlignment.Center, AdVerticalAlignment.Bottom, false);
// SHOWS IMPRESSIONS
WinPhoneAdMob.createBanner("ca-app-pub-xxxxxx", AdFormat.Banner, AdHorizontalAlignment.Center, AdVerticalAlignment.Bottom, true);
}
@poemdexter
poemdexter / gamejam.md
Created March 30, 2014 05:21
game jam talk description

The Art of Game Jam

Game jams give game developers an opportunity to flex game design skills but with a short deadline. Whether 48 hours or a whole month, game jams can be stressful when trying to get your game 'done'. Daniel Fairley will share tips and tricks on how to get the most out of a game jam before, during, and even after an event.

@poemdexter
poemdexter / wut.java
Created April 8, 2014 20:35
a good method
@Override
public doThing(String param)
{
super.doThing(param);
}
@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;