Tags » Blog Pages

Pathfinding Algorithm Code

This is a post to show off the code for the pathfinding algorithm for the enemy, I will explain at the bottom one section of the code which can be adapted to cover the rest of the possibilities of movement. 1,187 more words

Blog Pages

Player Movement Explained

This post is an explanation of how the player movement works as seen, in full, in the following script.

	void Update(){

		float horzMove = Input.GetAxisRaw ("Horizontal");
		float vertMove = Input.GetAxisRaw ("Vertical");
		Vector2 moveVect;
		var localVelocity = transform.InverseTransformDirection(rb.velocity);
		if (Input.GetKey ("a")) {
			if (localVelocity.x > 0) {
				moveVect = new Vector2 (horzMove, 0);
				transform.position = new Vector2 ((int)transform.position.x + .5f, (int)transform.position.y + .5f);
			} else {
				moveVect = new Vector2 (horzMove, 0);
				if (ValidDirections (moveVect)) {
					transform.position = new Vector2 ((int)transform.position.x + .5f, (int)transform.position.y + .5f);
					rb.velocity = moveVect * speed;
				}
			}
		} else if (Input.GetKey ("d")) {
			if (localVelocity.x < 0) { 				moveVect = new Vector2 (horzMove, 0); 				transform.position = new Vector2 ((int)transform.position.x + .5f, (int)transform.position.y + .5f); 				rb.velocity = moveVect * speed; 			} else { 				moveVect = new Vector2 (horzMove, 0); 				if (ValidDirections (moveVect)) { 					transform.position = new Vector2 ((int)transform.position.x + .5f, (int)transform.position.y + .5f); 					rb.velocity = moveVect * speed; 				} 			} 		} else if (Input.GetKey ("w")){ 			if (localVelocity.y > 0) {
				moveVect = new Vector2 (0, vertMove);
				transform.position = new Vector2 ((int)transform.position.x + .5f, (int)transform.position.y + .5f);
				rb.velocity = moveVect * speed;
			} else {
				moveVect = new Vector2 (0, vertMove);
				if (ValidDirections (moveVect)) {
					transform.position = new Vector2 ((int)transform.position.x + .5f, (int)transform.position.y + .5f);
					rb.velocity = moveVect * speed;
				}
			}
		} else if (Input.GetKey("s")){

			if (localVelocity.y < 0) {
				moveVect = new Vector2 (0, vertMove);
				transform.position = new Vector2 ((int)transform.position.x + .5f, (int)transform.position.y + .5f);
				rb.velocity = moveVect * speed;
			} else {
				moveVect = new Vector2 (0, vertMove);
				if (ValidDirections (moveVect)) {
					transform.position = new Vector2 ((int)transform.position.x + .5f, (int)transform.position.y + .5f);
					rb.velocity = moveVect * speed;
				}
			}
		}
	}
	bool ValidDirections(Vector2 dir){
		Vector2 pos = transform.position;
		Transform point = GameObject.Find ("GB").GetComponent ().gBPoints [(int)pos.x, (int)pos.y];
		if (point != null) {
			GameObject pointGO = point.gameObject;
			Vector2[] vectToNextPoint = pointGO.GetComponent ().vectToNextPoint;
			foreach (Vector2 vect in vectToNextPoint) {
				if (vect == dir) {
					return true;
				} 
			}
		} 
		return false;
	}
… 393 more words
Blog Pages

2017: Phil's Year in Review

I know that it’s a bit early to review this year, but I feel the need to get off my chest just how the year 2017 was to me. 808 more words

Blog Pages

Philiz Cumpleanos: Another Year in the Life of Phil

August 18th, 1990. 12:12PM. My family’s lives changed forever, and my life was just about to begin. Isn’t that beautiful? The thought of being born with a clean slate, entering the world without a clue as to what lies ahead. 1,043 more words

Blog Pages

The Score

Our first act is a fast growing american indie pop duo known as The Score.

The band is formed around Eddie Anthony on guitar and vocals, with the help of Edan Dover on Synths, Piano, and as the act’s producer in the studio. 898 more words

Act

Friends: How Many of Us Have Them?

               Ever since we were able to communicate with people other than our family, we’ve been constantly talking and spending time with others that we felt shared similar interests, had similar traits, and some that we just wouldn’t give the time of day.   984 more words

Blog Pages

Los Angeles - A Melbournian's View

I have now been in LA for 10 action packed days. I have been to theme parks, travelled on the Metro, walked for miles (they don’t say kilometres over here). 391 more words

Blog Pages