This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var xSpeed : int; | |
public var ySpeed : int; | |
public var randomX : boolean = false; | |
public var minXSpeed : int = 100; | |
public var maxXSpeed : int = 200; | |
public var randomY : boolean = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--============================================================== | |
-- pass in a lily pad number and get back a | |
-- table containing all the neighbors for | |
-- that lily pad. | |
local numCols = 11 | |
local numRows = 7 | |
local function getNeighbors(padNum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var rocket : GameObject; // object to push | |
public var xSpeed : float = 0; // horizontal speed | |
public var ySpeed : float = 400; // vertical speed | |
private var rb2D : Rigidbody2D; | |
function Start () | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.UI; | |
using DG.Tweening; | |
public class DriftingText : MonoBehaviour { | |
public GameObject canvas; | |
public GameObject textPrefab; | |
public float driftTime = 1f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class DragWithMouse : MonoBehaviour { | |
private Vector3 offset; | |
void OnMouseDown () { | |
Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0); | |
offset = transform.position - Camera.main.ScreenToWorldPoint(mousePos); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class SpawnAnimal : MonoBehaviour { | |
public GameObject animalPrefab; | |
public Sprite[] animalSprites; | |
public void MakeRandomAnimal() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Animal : MonoBehaviour { | |
private Vector2 origPos; | |
public string animalName; | |
public bool returnToOrigin = false; | |
void Start () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- most commonly used screen coordinates | |
local centerX = display.contentCenterX | |
local centerY = display.contentCenterY | |
local screenLeft = display.screenOriginX | |
local screenWidth = display.viewableContentWidth - screenLeft * 2 | |
local screenRight = screenLeft + screenWidth | |
local screenTop = display.screenOriginY | |
local screenHeight = display.viewableContentHeight - screenTop * 2 | |
local screenBottom = screenTop + screenHeight | |
local screenTopSB = screenTop + display.topStatusBarContentHeight -- when status bar is showing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- works like PHP explode() function | |
function explode(div,str) -- credit: http://richard.warburton.it | |
if (div=='') then return false end | |
local pos,arr = 0,{} | |
-- for each divider found | |
for st,sp in function() return string.find(str,div,pos,true) end do | |
table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider | |
pos = sp + 1 -- Jump past current divider | |
end | |
table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider |