Tuesday, 18 July 2017

KEEP IN MIND - to be successful as game developer

Previous: Update our pseudo code


Just a reminder:
  1. You need to know your goal. Always remind yourself what your goal is a game developer. Whether it is to make money, entertain, train or for fun then don't deviate from that goal.  Most of us give up as result of undefined goal.
  2. Review your skills. Get to understand what you need to develop your game. The skill needed to develop a game can be acquired from a training college, online, self taught or trial and error. Always expand your skills through self training and appreciate any little progress you make.
  3. Review your tools of work. Keep yourself up-to-date with new developments in regard to the technology you adapt to develop your game. Unity keeps on changing every day. You need to acquire new skills as they are released.
  4. Do not limit yourself to one field. Always explore to learn more.
  5. It is never too late to start. Even with saturated market, your game stands a chance. Proper marketing coupled with constant updates makes your game visible to the world.
So how do you make your game stand among other developers:
  1. Marketing. You can develop a marketing plan. Either free or paid.
  2. Social media. Create online accounts on various social media and keep constant updates to keep you audience engaged.
  3.  In-game marketing. When developing game, give link to your games or marketing images for your games.
  4. Create support channels for your games. e.g create a YouTube channel for cartoon, music etc and use it to market your games.
  5. Website. Create website for your game.  Update it frequently.
Since our assumption is we don't have enough funds to do marketing, then use the available free resources like WordPress or blogger to create your website. create a free YouTube channel, google plus, twitter and Facebook accounts. You can also add other social media channels


Next: Updating our C# code

Monday, 21 November 2016

Update our pseudo code

Previous: Advancing our Game further

To make the game more interactive, we introduce the player element. We need to move the player to collect the boxes.
We first check if the total boxes collected are less than boxes to collect. If condition holds we drop a box and collect.

initialize boxcollected to zero
initialize totalboxes to zero
initialize boxtocollect to 40

While totalboxes < boxtocollect
drop box
Move playerbox
if collected
  increase boxcollected by one
print boxcollected
end if
increase totalboxes by one
print totalboxes
end while


Our pseudo-code is taking shape now.

Next: Reminder of our goal

Monday, 14 November 2016

Advancing our Game further

Previous: Complete C# code
We learn the basics of working with unity. The game developed so far is a skeleton game. Only one box dropped and collected.

What we know:
Story line:
The game involves some boxes that drop from above and the player is required to collect the boxes. At the end of the game. the player should be able to tell how many boxes we generate and how many s/he managed to collect.

What we have done so far:
Dropped a box and collect it and, display the number of box collected . To further our game, we need to drop more boxes and collect them. This will enable us display the total boxes generated.  We need to advance our story line:

Updated Story line:
The game involves some boxes that drop from above and the player is required to collect the boxes.The boxes drop from any point above the catch up box. We move the catch up box to collect the boxes on left or right. No box should fall down. At the end of the game. the player should be able to tell how many boxes we generate and how many s/he managed to collect.

The new story line provides:
  1. We generate the boxes randomly.
  2. Move catch up box right or left. This now defines the player. 
  3. Display the boxes lost.
  4. Display total boxes dropped
To break the game, we advance our code to move the catch up box, then generate more boxes before displaying our score. We then need to redefine our pseudo code to reflect the new changes

Next: Update our pseudo code

Friday, 11 November 2016

Complete C# code



Previous: Turning Pseudo code into C# code



using UnityEngine;
using System.Collections;

public class CatchBox : MonoBehaviour {
    int boxescollected =0;
    int totalboxes =0;
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }
}

  
Lets add new method to check collision:

void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.tag == "box") {
            boxescollected += 1;
            Destroy (other.gameObject);
        }

    }


Since the code is attached to "catch up", it detects collision between it and other game objects. We check if the object has tag "box" and add
boxescollected. We then destroy the box.

We need to display our boxes. We use OnGUI method 

void OnGUI()
    {
        GUI.Label (new Rect (10,10, 300, 50), "Boxes collected: " + boxescollected);
    } 


Save the code. 

Below is the complete code for our game: 

using UnityEngine;
using System.Collections;

public class CatchBox : MonoBehaviour {
    int boxescollected =0;
    int totalboxes =0;
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.tag == "box") {
            boxescollected += 1;
            Destroy (other.gameObject);
        }

    }
    void OnGUI()
    {
        GUI.Label (new Rect (10,10, 300, 50), "Boxes collected: " + boxescollected);
    }



Run the game


 




This is the most basic games.

Next: Advancing further 

Thursday, 10 November 2016

Turning Pseudo code into C# code

Previous: Score display in pseudocode

It is now time to turn our pseudocode into C# code and display our score

Pseudocode
initialize boxcollected to zero
initialize totalboxes to zero

drop box
if collected 
  increase boxcollected by one
print boxcollected
end if
increase totalboxes by one
print totalboxes

In unity editor, inside assets folder, create a folder (from project menu, create -> folder) and name it Scripts. inside this folder, add C# script from project menu, create ->C# Script and name it CatchBox. 


Double click our new script to open. It opens with the default code.

We begin by declaring variable to store boxes collected
int boxescollected =0;

Then declare variable to store total boxes:
 int totalboxes =0; 

Every time a box is added to game, we add totalboxes: This will be added inside update method

totalboxes +=1;
 
We will use colliders added to the boxes to determine when the boxes collide. This denotes the box was collected. Every time the two boxes collide, we add boxescollected. We add a new method to detect collision and add

boxescollected +=1; 

To know which box collided, we need to add tag to differentiate our boxes. Lets add tags "catch" and "box" and assign to our boxes.

Select box and in the inspector under tag, click add tags. In the tags, click + sign  and add "catch" in tag 0. click + again and add "box" in tag 1.
 














Select our box again and set tag to "box". Select catch and set tag to "catch". 


Save project. 

Select "catch up" in the heirachy and drag C# script from script folder and drop in the inspector panel.


 Save project

Next: Complete our C# code