Tuesday, November 15, 2016

#asylumjam2016 So can we go on the bus now?

So I tried my hand at the #asylumjam2016 game jam over the weekend, I say tried because I didn’t finish with a playable game.

The theme was escape the room, which made me think of a short story my wife publish a couple of years ago. It tells the story of Gary, stuck in his primary class room with people from the class that have died.  It becomes evident that he too has died. The idea is that the Non playing characters (NPC) help Gary understand the truth of why he is there.
The game “So Can We Go On The Bus Now?” is a point and click Adventure game, doing all the Graphics, music and coding in a weekend proved too much though. I did go to the Pub Saturday night and also slept 8 hours per night, so about 20hours lost there, so if the challenge was to create a game using 48hour, I maybe could of finished. 

Anyway now for the blah blah on why it failed and what I should have done differently.

To create the game I created two scenes, one is the car crash that kills Gary and the other is the Classroom. The crash scene is non intractable and used as a flashback. It is also an unreliable narrator scene, not what actually happened.
In Inkscape I quickly knocked up the layout of the classroom, I decided on a 2.5d approach, this made creating the graphics that bit trickier.

I created an ItemBase class as a ScriptableObject.

public abstract class ItemBase : ScriptableObject
    public Sprite[] sprites;
    public AudioClip click;
    public AudioClip music;

    public string Title;
    public string Description;
    public float ZoomSize = 0f;
    public float ZoomY = 0f;
    public SpriteRenderer spriteRender;
    public GameObject go;

    public abstract void Examine();

Then inherited it for Inventory item, NPC or non-moveable that way coding will be easier by avoiding nested if statements. 
Each class has code that it only needs to know about.
Then I created .asset files for each of the objects so I could edit them easily in the IDE.

Still to do:
Conversation system
Giving items to NPC

I am going to continue this and get it finished. Making it my 6th game but totally different from previous games, I probably wouldn’t have chosen this type of game but the game jam makes you work outside your comfort zone.

I put it up on the GameJolt site anyway,  but I don't expect any votes as it isn't playable.
It was really good fun creating it though :)

Tuesday, October 4, 2016

Wool is the fuel available on GooglePlay

My latest game is a bit retro, it's like the classic old Defender game. 

It uses my system for Parallax scrolling the backgrounds, you get a HUD to see what alien is going for your sheep.

It has been written in Unity 3D,
I've written all the music myself in Ableton Live 9 lite.
For the sound effects I've used SONiVOX's Twist & Wobble.
The animations were made in Spriter by BrashMonkey the backgrounds and explosions were from their art packs.

Here is the video

Thursday, September 29, 2016

Saving 2 sheep with AZ

I was playing my game wool is the fuel and wanted to record a video of the game play. So I downloaded AZ screen recorder.

After a few seconds I had recorded this snippet.

I liked it because it also records the audio all be it from the speakers though. My previous phone had great speakers but after my cat Clicquot decided to bite through the screen, I had to get a new one (phone that is not cat).
 Clicquot catching munchies

Sunday, September 11, 2016

Wool is the fuel mecanim

I've just uploaded a video showing some of the game play and animations in my Wool is the fuel defender style game.

When developing I used single frame animations to test the mecanim to see that all the states worked. For the Landers, I used different colours to represent each of the states. Then when I was sure it all hung together nicely I created the animations.

Lander mecanim

Drag an image onto the Hierarchy then click Window->Animation

Click add property then click the plus on the right

I use Spriter by Brashmonkey to do the animations, I know I can create the animations directly in Unity and it has advantages with regard the colliders, but for simple animations I still use Spriter.
Also I love all of the effects they have already created for us, look at the video to check them out.

Thursday, August 25, 2016

Unity's Event trigger component

So I was adding my buttons to the game using UI event sytem in Unity.
The Fire and Flip where easy but when it came to the Thrust button I hit a snag. The button click is not enough I need it to respond when the button stays pressed.
To do this I needed to add Event Trigger component to the button.
Then in the component click add new event type for Pointer Down and Pointer Up. 

Here is the code for the 2 functions:

    public void ThrustDown()
        IsThrust = true;

    public void ThrustUp()
        IsThrust = false;

Then in the FixedUpdate() check if IsThrust then increase the speed, also I’ve added the code to slow down the player over time with the Speed * .99f:
        if (IsThrust)
            Speed += thrustAmount;

            if (Speed > MaxSpeed)
                Speed = MaxSpeed;

        Speed = Speed * .99f;

Sunday, August 21, 2016

Mutant aliens

When an alien takes a sheep up to the top of the screen it shears the sheep and becomes a fast moving alien mutant. 
What I want is for the mutants to go after the player. To do that we subtract the 2 positions vectors, giving us the difference between the 2 points. I wanted to use that to then set the direction of the mutant. I discovered there is a function normalized that does just that, so here is the code from the FixedUpdate() to do that. By placing it in the FixedUpdate it will continually change course towards the player.

if (IsMutant)
    var delta = player.transform.position - transform.position;
    direction = delta.normalized;


Aliens take sheep to top then change into Mutants

Saturday, August 20, 2016

Attack Waves

In defender all of the baddies don’t all arrive at once there are a number of waves per level. So to do that when instatiating the baddies I'll have a delay between them.

In a previous blog on the development of Rhino roll I used Editor scripting to help create the levels. So I’ll do the same here again. 

Here is my code to create an array of objects in the editor script.

    static void ObjectsToArray(string objType)
        var Code = "private Vector2[] " + objType + " = new Vector2[] {";
        var objs = Selection.gameObjects.OrderBy(go => go.transform.position.x);
        bool IsFirst = true;

        foreach (var item in objs)
            if (!IsFirst)
                Code += ", ";
                IsFirst = false;

            Code += string.Format("new Vector2({0:0.000f}, {1:0.000f})", item.transform.position.x, item.transform.position.y);
        Code += "};";


Here is the code to add the Menu Items to the IDE of Unity and call the function 

    static void SheepToArray()

    static void LandersToArray()

The idea is to move the landers aboout, duplicate new ones et.c. then select them all and call the LandersToArray function, like below.

Here is the code automatically generated by the function call. Saves so much time when designing levels, in my opinion.

    void Level1Wave1()
        Vector2[] Landers = new Vector2[] { new Vector2(-48.800f, -0.140f), new Vector2(-42.200f, 1.560f), new Vector2(-11.880f, -1.120f), new Vector2(-5.680f, -0.440f), new Vector2(-0.080f, 2.320f), new Vector2(0.020f, -1.850f), new Vector2(3.500f, 1.560f), new Vector2(24.200f, 0.960f) };
        Vector2[] LanderDirections = new Vector2[] { new Vector2(-0.240f, -0.074f), new Vector2(-0.933f, -0.997f), new Vector2(0.489f, -0.842f), new Vector2(0.702f, -0.403f), new Vector2(0.700f, 0.146f), new Vector2(-0.497f, -0.331f), new Vector2(-0.186f, 0.392f), new Vector2(-0.868f, 0.386f) };

        DoLanders(Landers, LanderDirections, .02f);

Then in the fixed update add the code to invoke these functions after a given time.

        if (CurrentWave < Waves.Length)
            if (Waves[CurrentWave] == 0)
                var wave = string.Format("Level{0}Wave{1}", CurrentLevel, CurrentWave);
                Invoke(wave, 0f);

As before here is a video to demonstrate. It has 2 attack waves from the aliens. I haven't done any fancy animations for the materialisation yet.