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 FlyCamera : MonoBehaviour { | |
/* | |
Writen by Windexglow 11-13-10. Use it, edit it, steal it I don't care. | |
Converted to C# 27-02-13 - no credit wanted. | |
Simple flycam I made, since I couldn't find any others made public. | |
Made simple to use (drag and drop, done) for regular keyboard layout |
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
Sid Meier's 10 Rules of Game Design | |
1. Choose a topic you have a passion for. Game Design is about creativity. | |
2. Do research after the game is done. Tap into the player’s brain. | |
3. Define your axioms, refine your axioms. Prototype, prototype, prototype; sit in all the chairs. | |
4. Double it or cut it in half. You are more wrong than you think. |
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
// actually calculate the a-star path! | |
// this returns an array of coordinates | |
// that is empty if no path is possible | |
return calculatePath(); | |
} // end of findPath() function |
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
// Path function, executes AStar algorithm operations | |
function calculatePath() | |
{ | |
// create Nodes from the Start and End x,y coordinates | |
var mypathStart = Node(null, {x:pathStart[0], y:pathStart[1]}); | |
var mypathEnd = Node(null, {x:pathEnd[0], y:pathEnd[1]}); | |
// create an array that will contain all world cells | |
var AStar = new Array(worldSize); | |
// list of currently open Nodes | |
var Open = [mypathStart]; |
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
// Neighbours functions, used by findNeighbours function | |
// to locate adjacent available cells that aren't blocked | |
// Returns every available North, South, East or West | |
// cell that is empty. No diagonals, | |
// unless distanceFunction function is not Manhattan | |
function Neighbours(x, y) | |
{ | |
var N = y - 1, | |
S = y + 1, |
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
// distanceFunction functions | |
// these return how far away a point is to another | |
function ManhattanDistance(Point, Goal) | |
{ // linear movement - no diagonals - just cardinal directions (NSEW) | |
return abs(Point.x - Goal.x) + abs(Point.y - Goal.y); | |
} | |
function DiagonalDistance(Point, Goal) | |
{ // diagonal movement - assumes diag dist is 1, same as cardinals |
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
// Node function, returns a new object with Node properties | |
// Used in the calculatePath function to store route costs, etc. | |
function Node(Parent, Point) | |
{ | |
var newNode = { | |
// pointer to another Node object | |
Parent:Parent, | |
// array index of this Node in the world linear array | |
value:Point.x + (Point.y * worldWidth), | |
// the location coordinates of this Node |
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
// returns boolean value (world cell is available and open) | |
function canWalkHere(x, y) | |
{ | |
return ((world[x] != null) && | |
(world[x][y] != null) && | |
(world[x][y] <= maxWalkableTileNum)); | |
}; |
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
// world is a 2d array of integers (eg world[10][15] = 0) | |
// pathStart and pathEnd are arrays like [5,10] | |
function findPath(world, pathStart, pathEnd) | |
{ | |
// shortcuts for speed | |
var abs = Math.abs; | |
var max = Math.max; | |
var pow = Math.pow; | |
var sqrt = Math.sqrt; |
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
// world is a 2d array of integers (eg world[10][15] = 0) | |
// pathStart and pathEnd are arrays like [5,10] | |
function findPath(world, pathStart, pathEnd) | |
{ | |
// shortcuts for speed | |
var21abs = Math.abs; | |
var max = Math.max; | |
var pow = Math.pow; | |
var sqrt = Math.sqrt; | |
NewerOlder