Chains is delicious, also pretty soon done

Chains is really close to being done by now. All I need by now is some audio. I've got a dude on the job but it's not going very fast, he told me that I'd get a sample. But that was supposed to have happened two weeks ago. Still haven't heard from him... so yeah..

But anyways! Here are some pictures from the latest version of chains.

The Main menu. The button has a opening animation, opposite of what the orbs normally do.

Image of an active game.

How it looks when you've died at this version, see next picture.

Explanation of where the death-window is supposed to be. It will show score and such. Perhaps lives if we implement that.

Just started Uni

Hey guys, I just started attending university where i'll be studying Com Sci. So even though content is low already, I'll try to make a little bit more. I hope to post a few more blog posts about chains, which has seen an a complete revamp of the movement system along other thins. This happened due to Copy not saving my progress before I formatted my computer. But it runs faster and better than before, so in the end it was all worth it even with the extended develop time.

New death window getting there


This is the draft of the new window. There still needs to be made a few adjustments to the border and a little to the font sizing/potitioning.

But it's 02:21 in the morning and I'm going to sleep. See you next post mate.

Moving

Hi guys. Currently JUST moved into my new apartment, so there isn't a ton of time to write new content. But I promise I'll get back to the Three Shot Hero guide soon. Just need to get settled in and unpacked.

HTML5

Times have been quite slow lately. I'm waiting for my partner to finish up some things so that we can finally release chains.


Meanwhile that has been going on I stumbled on Lost Decade Games's blog which featured an article on HTML 5 canvas games. After reading it I got curious and thought it'd be fun to tinker with. So am now creating a HTML5 game, you'll be seeing it soon!

How to make a game tutorial - Part 1 - Starting out

Today I'll be starting a new guide on how to make a game from scratch (with unity though). I will be making a game called Three Shot Hero, but you should feel free to make any changes to the project that you feel like. If you're all new, it may be a good idea to follow my instructions pretty precisely. But if you know/feel that you can make changes, please do. I originally wanted to use Daikon Forge (A GUI Library) for the project, but to let everyone join in I'll have to refrain from it.

Start

First of all, start out a new project and find a location for it. I always save my projects in Dropbox or Copy, so that I can access them anywhere.


First off we'll make a new screen size default to see what the game will look like. Call it landscape and make it 800x480px. Even though most phones have different screen resolutions, it should give us an idea how how the game will react.´

Project Settings

Now go to Edit ->Project Settings ->Player. Here you can name your game if you want, and even set a company name. You'll want to go to the Desktop settings (the Arrow down) and check run in Background. Also shown below. After that go to Android(/iOS if you can do that)and set it's mode to landscape.


Importing Sprites

Now we'll add a title to the game and a start button. I recommend making your own, or get a friend to do it. If not, you can use this one:

When you have made/downloaded a title header and a play button, go ahead and drag it into the assets section of unity so you can use it in your game. Once imported set the settings to the following (Pixels to units may wary). After that select sprite editor. When that has opened press the little 'Slice' button in the top left corner and select slice. Lastly press apply, top-right corner, and close the Sprite Editor down. Now you should have a header sprite and a play button sprite.


Navigate to where your title sprite is and click the little arrow-button as shown below.

Now drag the title header out into the Scene window. Do the same for the play button and your scene/game should look something like this
Scene:
Game:

Go ahead and save the scene (Ctrl + S) somewhere in your assets folder within the project.
That is the final thing for the first part of this tutorial. I'll write part two immediately afterwards, so please check it out afterwards, you'll make a great game, I'm sure :)

Fading Scenes in unity (C#)

Today I'm going to show you how to fade out a scene, change to another scene and then fade back in. This can be a useful effect in many games and apps.

First off go ahead and add a new script to your Main Camera. Call it Fading. Then go ahead and setup the start variables as shown below. The fadeTexture is just a small image of the texture we want to show when fading scenes, I use/recommend a tiny black image like this one. The import settings for that image should look like this:



public Texture2D fadeTexture;
 public float fadeSpeed = 0.8f;

 private int drawDepth = -1000;
 private float alpha = 1.0f;
 private int fadeDirection = -1;

Most of these variables are quite self explanatory, so lets rush on to the next part.

void OnGUI()
 {
  alpha += fadeDirection * fadeSpeed * Time.deltaTime;
  alpha = Mathf.Clamp01(alpha);

  GUI.color = new Color (GUI.color.r,GUI.color.g,GUI.color.b,alpha);
  GUI.depth = drawDepth;
  GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),fadeTexture);
 }

This simply fades the black texture's opacity. If the fadeDirection is negative one, it gets less and less visible, and if it's one the black texture gets increasingly visible. The drawDepth part makes sure that the black texture is being shown above everything else. Now lets move on to the last bit of code in the Fading script.

public float StartFade(int direction)
 {
  fadeDirection = direction;
  return fadeSpeed;
 }

 void OnLevelWasLoaded()
 {
  StartFade(-1);
 }

The first function StartFade is what we need to call with a positive direction value to actually fade out. The second one is a function that will run automatically when the scene is loaded, it removes the black texture.

Now for the final part, which makes it all work.
You will need to put this part in the place where you load up another scene. E.g a button, a timer of an object a player collects.

IEnumerator FadeScene()
 {
  float fadeTime = Camera.main.GetComponent().StartFade(1);
  yield return new WaitForSeconds(fadeTime);
  Application.LoadLevel( (Application.loadedLevel+1));
 }

Whenever you want to fade a scene out you just call that function by typing this:

StartCoroutine(FadeScene());

Happy fading!


For reference, here is my whole Fading.cs file:
using UnityEngine;
using System.Collections;

public class Fading : MonoBehaviour {

 public Texture2D fadeTexture;
 public float fadeSpeed = 0.8f;

 private int drawDepth = -1000;
 private float alpha = 1.0f;
 private int fadeDirection = -1;

 void OnGUI()
 {
  alpha += fadeDirection * fadeSpeed * Time.deltaTime;
  alpha = Mathf.Clamp01(alpha);

  GUI.color = new Color (GUI.color.r,GUI.color.g,GUI.color.b,alpha);
  GUI.depth = drawDepth;
  GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),fadeTexture);
 }

 public float StartFade(int direction)
 {
  fadeDirection = direction;
  return fadeSpeed;
 }

 void OnLevelWasLoaded()
 {
  StartFade(-1);
 }
}


and my button, that loads up the next level:
StartGame.cs
using UnityEngine;
using System.Collections;

public class StartGame : MonoBehaviour {

 void OnMouseDown()
 {
  StartCoroutine(FadeScene());
 }

 IEnumerator FadeScene()
 {
  float fadeTime = Camera.main.GetComponent().StartFade(1);
  yield return new WaitForSeconds(fadeTime);
  Application.LoadLevel( (Application.loadedLevel+1));
 }
}


Basic Infinite Vertical Sprite Spawning

Today I'll show you something that I use for my own game, Chains!

I'll show you how to infinitely (and semi-randomly) spawn sprites vertically! First off we'll declare some of the things we need. I use orbs in my game, but you should feel free to change anything at all

private GameObject lastOrb;
private Vector2 pos;

//Define the rage in which each object is allowed to spawn
public float fromY;
public float toY;
public float fromX;
public float toX;

public GameObject orbPrefab;
 
//If you want more than one gameObject to spawn declare them aswell and set them in the editor.
public GameObject pinkOrbPrefab;
public GameObject redOrbPrefab;
public GameObject blueOrbPrefab;

Now we need to set the first sample point for the script to work.

void SampleGenerate()
{
 if(lastOrb == null)
 {
 // Here i have a single orb preplaced as a starting point for the script.
 // The name of the object is what you put in GameObject.Find(), it should be unique.
 lastOrb = GameObject.Find("OrbFirst");
 }
}

With a first point of reference we're going to start out

void SampleGenerate()
 {
  if(lastOrb == null)
  {
   lastOrb = GameObject.Find("OrbFirst");
  }
  pos = lastOrb.transform.position;
  pos.y += Random.Range(fromY,toY);
  pos.x += Random.Range(fromX,toX);
  
  InstOrb();
 }

//Here you just select a random range of numbers depending on how many items you have.
//I want my standard orbPrefab to be spawned much more often then my other orbs so it has a 7 in 10 chance.
void InstOrb()
 {
  int Select = Random.Range(0,10);

  switch(Select)
  {
  case 0:
   
   lastOrb = Instantiate(orbPrefab,pos,Quaternion.identity) as GameObject;
   break;

  case 1:
   lastOrb = Instantiate(pinkOrbPrefab,pos,Quaternion.identity) as GameObject;
   break;

  case 2:
   lastOrb = Instantiate(blueOrbPrefab,pos,Quaternion.identity) as GameObject;
   break;

  case 3:
   lastOrb = Instantiate(redOrbPrefab,pos,Quaternion.identity) as GameObject;
   break;

  default:
   lastOrb = Instantiate(orbPrefab,pos,Quaternion.identity) as GameObject;
   break;

  }
 }

Now all we have left to do is utilize the script in our Update function. I don't recommend just keeping it in the Update function as it will slow your game down dramatically. I recommend setting a cycle for it to run once.

Cycle:
void Start()
{
 //Amount of objects to spawn/cycles to run
 int cycles = 10;
 for(int i = 0; i < cycles; i++)
 {
  SampleGenerate();
 }
}
OR [!SLOW WARNING!] Infinite:
void Update()
{
  SampleGenerate();
}

Comming Along nicely!

I recently posted a mini-teaser for my game chains. Glad to say that it's really getting closer. I've fixed up the range system (the white circle that you see in the picture). Which was easier than I thought.. Even better, I've managed to create the beginning of random level spawning system. Look below for a code snippet, and if you do, please consider that it's just the beginning of it. It'll get more advanced as I figure out exactly how I want it to work



Chains

The game, Chains, that I've been working on for a while is nearing completion! I need to do two or three major things and fix all the details, but then it should be ready for release. It's coming to the Google Play store, so Android. Here's a little teaser image.

Very small and very blurred, but I'm not supposed to release anything, so shhhh!