Abeyance Classes

Whisperer

Heavily Neuro focused. Has more MND. Wields a dagger and pistol.

Psychopath

Heavily Psycho focused. Has more DEL. Wields a short sword and pistol.

trigger finger

Gun specialist. Has more DEX. Wields a dagger and shotgun. Fires Neuro from barrel

Manic

Melee Specialist. Has more STR. Wields a long sword and pistol.

Tormentir

Defender. Has more VIT. Wields a hammer and a pistol.

Shadower

Masters of evasion. Has more AGI. Wields a special dagger and a pistol

Shadow Talker

Jack of all trades, master of Notts. Balanced Stats. Nott related attacks. Wields a short sword and pistol.

Dark Irrlicht

Currently there is an Open Source project going on to bring an Irrlicht wrapper to Dark Basic Pro, for this project I am working on some of the documentation and helping any Dark Basic Pro users get to grips with this plugin. My C++ skills aren’t good enough to contribute to the DLL itself, though I have given DLL programming a shot, I think there’s more I’d need to learn.

The project has a working prototype, but there’s still a lot of Irrlicht commands to bring into the mix. So whilst people are adding stuff, I am working on a demo in C# I can bring into Dark Basic Pro and explain how everything works. It seems like a sensible set of tutorials and documentation to do whilst I wait on the release of Dark GDK 2.0 to do the tutorial series I promised.

You might recognise this scene from a project:

image

This will be used as part of the demonstration so I don’t have to 3D model anything new. Smile I’ll probably use some of the stock media for the characters.

The Dark Irrlicht project is here over on the TGC forums.

Setting Up Irrlicht Lime in VIsual C# 2010

This is easy as pie, but I saw no tutorials so I thought I’d make one.

You can get Irrlicht Lime from here

Boot up Visual C# 2010

image

Make a Console Application project.

Go to references:

Add a new reference and browse for ‘IrrlichtLime.dll’. (Found in IrrlichtLime-1.0/bin/debug/).

image

Save your project. Hit F5/Start Debugging. This will add what you need to your bin/debug folder, except one component.

Head to the ‘bin/debug’ part of your project’s directory in explorer. And also go to the bin/debug’ folder in the Irrlicht Lime directory (where we got IrrlichtLime.dll). Take Irrlicht.dll, copy and paste it into your project debug folder.

image

In Main.cs copy and paste the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using IrrlichtLime;
using IrrlichtLime.Core;
using IrrlichtLime.Video;
using IrrlichtLime.Scene;
using IrrlichtLime.GUI;

namespace _01.HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {

            IrrlichtDevice device = IrrlichtDevice.CreateDevice(
            DriverType.Software, new Dimension2Di(800, 600), 16, false, false, false);

            device.SetWindowCaption(“Irrlicht Project!”);

            VideoDriver driver = device.VideoDriver;
            SceneManager smgr = device.SceneManager;
            GUIEnvironment gui = device.GUIEnvironment;

 

            while (device.Run())
            {
                driver.BeginScene(true, true, new Color(100, 101, 140));

                smgr.DrawAll();
                gui.DrawAll();

                driver.EndScene();
            }

            device.Drop();
        }
    }
}

Hit compile!

And voila!

image

Class System In Abeyance–Update

I’ve not posted much Abeyance stuff and to be fair, I was away in Germany last week and this week my brain has literally been fried. Some of the stuff I was working on in Dark Basic Pro was experimentation leading up to the code I’d be using in Abeyance to implement my classes and in the process I have made update to skills and items (due to discovering a more convenient method).

In theory, I could have as many classes as I’d like without changing any code in C#.

image

See, I can just define everything inside of the editor. Keats’ Class is also listed there, his current class will be set to whatever the string ‘Class’ says. The default is Whisperer. But in mid battle whilst testing I could change this and everything would adapt.

image

Current stats are set to ‘Whisperer’. But in editor all I have to do is type a different class.

image

And automatically the player data changes to that specific class. I am not going to implement a system where the player can change class, but this demonstrates a much more sensible way of handling classes. Also, lets say I wanted to add a new class?

image

No changes to code were necessary.In fact, all of these screenshots were all taken from the same test run and we made whilst debugging. See, this is what I love about Unity3D – I can write my code to make as much use of the editor as I need.

So what about the code? Essentially I am using a class in C#, previously I was using structs, but you can’t get a struct to show in the editor, but you can get a class to if you use this command:

[System.Serializable]

It goes before you create the class:

[System.Serializable]
  public class Classes
   {
      public string name;
       public string magic1;
       public string magic2;
       public string skill;
       public string weapon;
       public string armor;
       public float HP;
       public float MP;
       public float Speed;
       public float STR;
       public float VIT;
       public float MND;
       public float DEL;
       public float DEX;
      public float AGI;
   }

In DBP it’s like using UDTs.

With having the ability to level up in game, I can’t have set the HP, MP and so on from just within the class. Instead I use a base stat. You’ll notice above the Demoniser class had ‘24hp’ but Keats actually has ‘120hp’. It’s because I use that ‘24’ as part of a calculation to get the player’s final stat, which scales as the player levels up.

So how has this affected my inventory & abilities. With the ability to use a class inside of the editor it means I can throw my old system out of the window, the DBP version of that system can be found here Like with the classes I can just define all of these variables from within the editor and not compile anything.

image. image

So with this system, how would make class specific abilities? I haven’t implemented this system yet, but you’ll notice in each class/path, there’s Magic1 and Magic2, this would work nicely as a place holder for creating different types of spells. In Abeyance there’s only 2 types of ‘magic’ and that’s Neuro and Psycho and they’re hardwired into every class/path. However, each class has a set of exclusive ‘Neuro’ and ‘Psycho’, so I can still take advantage of ‘Magic1’ and ‘Magic2’ to give categories for exclusive spells, these would have to match with a spell’s particular school. Why have I done it as “Magic1’” and “Magic2”? It’d make the code re-useable for future projects without change. For now the school is just defaulted ‘neuro’ or ‘psycho’. But in actuality for ‘Shadower’ I might have magic1 as “shadow” and magic2 as “darkblade” and Mindjolt’s school could be ‘shadow’. So when Keats’ Neuro list appears as a Shadower it’ll show Mindjolt, but no other class could see it unless there’s another class with ‘shadow’ as magic1. The advantage here is that you could actually mix and match some classes – for example 2 classes might share the same Neuro attacks but have different Psycho attacks. And should I introduce a new class I could easily set up a new series of spells without coding or recompiling.

What about animation? I can just add 1 extra line of code in my class and have my animation code use that line to grab the animation from that line of code. Simple.Thank Satan for Object Orientated Programming.

Data in Dark Basic Pro

image

What’s going on in this image? There’s a lot actually going on. When coding a game it’s always worth thinking about using external data files to make up your game’s data, as for a start it saves on compile times and makes things more manageable. Here in Dark Basic Pro I’ve got a system where you acquire ‘spell’ and ‘class’ data from external .dat files. All that data above has been edited externally. I have 2 project files for this, the game engine (read data) and a project dedicated just to writing the above data(write data), kind of like scripting. You can find a code snippet here. 

So this means, I could make changes to things like classes without having to recompile the whole project.

You’ll also notice in that screenshot, a little menu. That menu was created from reading class data, in code it is reading ‘class number 1’, which happens to be Scholar. But lets change that to class 3 (Dark Knight).

image

The list changes as the player’s class is different. What about if I am using ‘null’? As you’ll see under ‘Blue Mage’ there is a null value.

image

The menu size changes and doesn’t read any data that is set to null.

To create that menu, you may wish to use this code (uses this code snippet):

d3d_starttext
        h = 1
    cNumber = 2
    if Player.class = class(cNumber).name

        Border_Text(1, x, y + gap*h , 0, “Attack”)
        inc h, 1
        Border_Text(1,x,y+gap*h, 0, “Ranged Attack”)
        inc h, 1
        if class(cNumber).magic1 <> “null”
            Border_Text(1,x,y+gap*h, 0, class(cNumber).magic1)
            inc h,1
        endif
        if class(cNumber).magic2 <> “null”
            Border_Text(1,x,y+gap*h, 0, class(cNumber).magic2)
            inc h,1
        endif
        if class(cNumber).skill <> “null”
            Border_Text(1,x,y+gap*h, 0, class(cNumber).skill)
            inc h, 1
        endif
       
        Border_Text(1,x,y+gap*h,0, “Defend”)
        inc h, 1
        Border_Text(1,x,y+gap*h, 0, “Items”)
           
       
    endif

    d3d_endtext

Better you copy and paste it as WordPress won’t keep the formatting.

Variables you’ll need to define yourself:

Player.class = class(3).name  (the variable ‘player.class’, acquired the name of class number 3)

X = 30 | Y = 30 | Gap = 15

 

C#–Text Adventure–Part 1

Wanting to learn C#? I figure this would make a great set of tutorials for beginners. What we’re going to be doing is using the Windows Forms feature to create a text adventure all using Visual C# 2010 straight out of the box. I will try to clearly explain everything.

First off, lets create a new project:

image

I’ve called mine “Pulse” after a text adventure I started in DBP. It’ll need to be a ‘Windows Form Application.

Creating Forms

You’ll end up with a form and it’ll look something like this:

image

So what we want to do first is just design our little ‘form’ or ‘window’ for our little game. Click on the form and if the ‘Properties’ window in the right panel, does not show, click this button:

image

Inside of the properties, we’ll want to change the text in the form’s title from ‘Form1’ to whatever you want to call it.

image

On the left pane, you’ll notice a button labelled, ‘tool box’, we’ll want to use this to get the components to build our interface. It’s pretty basic.

Create a TextBox. In the properties, make sure it’s multiline.

imageimage

Scale the box and in the properties make sure it anchors Top, left, right and bottom. The anchor will mean that when the user resizes the window, the box will adjust.

image

Rename the textbox to ‘Body’. And make ‘ReadOnly’ True. (All in the properties). This text box will contain all of the text for the game.

Add another textBox, we only need to anchor this left, right and bottom. Rename it ‘command’. No other properties need to be changed. This text box is where the user will type in a command.

image

Now add a button with the text ‘Confirm’ and anchor it bottom right. Also, rename it ‘confirm’.

image

That’s all the form design you need to do. Now double click on your new button. It’ll take you into ‘Form1.cs’. The reason I said to double click on the button instead of opening ‘Form1.cs’ from the explorer is because by double clicking on it, C# will generate some code which has conditions should the user click on the button. We won’t worry about that yet.

The next bit will look confusing. It’s the actual code of the program.

image

Introduction to Programming

Basics

Think of programming at talking to your computer and you’re telling it to do things for you. Computers are very literal and mathematically minded. This means you have to spell everything out for them and mostly in mathematical equations. C# actually cuts out a lot of the work for you, in that you don’t quite have to go into depth explaining everything to the computer. For example, those forms we’ve designed? We didn’t actually need to code any of that.

A programming language is just that, a language. If we want to give a computer some instructions to tell it what to do, it helps to be able to refer to certain objects. So, you might say, “Pick up that can of Dr Pepper”. For a computer to understand what a ‘can of Dr Pepper’ is, we need to be able to define that object. Now we have 2 choices here: use objects that as already define or create our own. You see at the top of the code there’s “using” followed by a label. What that is essentially doing is saying to the computer, “use these definitions”. These definitions all point to various system commands and objects. Whilst “PickUp” is not a command and “DrPepper” is not an object, there’s a lot we can do.

It’ll make more sense in demonstration. But we’re not going to have to worry as much about ‘System’ ourselves. Because the commands and objects we’re mainly using will be made by ourselves.

Namespaces and Classes

Think of these like containers. Going with the ‘object’ analogy. You might think of the namespace as the world’, or heck to simplify things, a room. Inside of that room are lots of objects like your hi-fi system, your TV, your cooker, your books, your sink and so on. These are classes. You could even think of classes as rooms inside of a house. For a visual representation:

image

So like a TV your TV class would have certain properties you can give it – your TV might be a certain colour, size or shape, it might be of a certain brand or of a certain model. These are all ‘variables’, like: tv.size or tv.colour or tv.make. TVs also have different functions. In C# we call these ‘methods’. So you might have tv.turnOn(), tv.turnOff(), tv.nextChannel(), tv.GotoChannel(ChannelNumber) and so on

In code, you’ll notice the curly braces { }, these just represent the boundaries of the container, so everything within ‘class TV’ will be inside of those curly braces. So our ‘namespace’ in the game itself, all of our objects are contained within the game. Then we have a class called ‘Form1’, which is our form object. All of the pieces your added to your form as also objects, though you don’t have to define them yourself, as C# has taken care of that for you.

So, to demonstrate what the hell I’m on about, I’ll allow you to code a line. Everything that’s happening will be inside of the ‘Form1’ partial class, but the good news is, we can communicate to all sorts of other classes. Inside of the class is a method also called ‘Form1’, this is where the computer will read our logic. Anything we want to tell the computer to do will be inside of here, even if we’re telling it to look at a different class and read a different method.

For now, just add this:

image

Remember the textbox we renamed ‘Body’? It is also a class. One of its properties (which you might have spotted in the editor) is its ‘Text’. We can change that property in our code. When you hit ‘Start Debugging’ (F5), you’ll find that the text box will say “Hello World”.

image

Part 2 will cover classes a bit more and will show off variables and maybe even methods.

Concept: Dark Irr

One of the great things about Dark Basic and Dark GDK is that it has such a simple way of dealings with code, rather than bogging you down with heavy details it keeps it nice and concise for the coder. After reading a thread on the TGC Forums I had an idea that might be interesting to explore, not necessarily start as project, but an idea none-the-less. It’s to bring Dark Basic like commands to another library. I picked Irrlicht Lime as it is Open GL and multiplatform and free. Irrlicht doesn’t work in the same way, so for a Dark Irr to work it’d need to be coded in such a way that it has the simplicity of Dark GDK but the functionality of Irrlicht.

image

image

That’s just a sample of the concept. You’ll notice a few differences to the Dark method. Instead of ‘object numbers’ you just have the objects. And Irrlicht uses a scene manager whilst Dark products don’t. Irrlicht uses a box to contain text and therefore requires x, y, width & height and not just x & y. Also, you can just load a texture direct to a 3D object rather than having to use ‘Load Image’ first.

image

DBP SERIES #1: THE MENU PART 2

What’s the next stage? We need some interaction!

This is where the variable ‘selection’ comes in. This variable will store a number that will be associated with a selection on the menu. The range of selections is 1 to 5, as we have 5 items.

So in our GUI function, we need to turn the previous bit of code into an ‘if-then’ statement. An if then statement is useful for our games logic. It’s basically, “If this happens, then this happens”. We want to include the text commands in this statement.

image

There some new stuff to learn here. This is all inside of the ‘for’ loop we made in the last tutorial. Now there’s 2 text commands. But what is going on here? It’s pretty simple. Because we’re using 1 to 5 as our selections, it’ll be able to match the 1 to 5 in our for loop. The two if then statements are asking whether or not the selection matches an item.

The first statement. Into plain English,”If the selection isn’t the same as ‘x’, then just show the menu name at coordinate 10 and 10+h”

The second statement. Into plain English. “If the selection IS the same as ‘x’, then sow the menu name with additional text that represents an arrow (<-) at 10, 10 + h”

Now we need some input. The input will be handled inside of Update(), they’re 2 very simple If then statements.

image

By using the arrow keys, you can alter the selection. As the number increased, the further down the list you go. The ‘wait 200’ is to stop the input being too sensitive. This would normally be a terrible way of avoiding sensitive controls in a normal situation, but this keeps it simple enough and it will not cause us any problems. You’ll also notice I used a colon. What a colon does is allows you to merge lines together. In an ‘if then’ statement, it means I can list its results on a single line.

If you compile. it’ll work, but you’ll notice 1 problem occurs, your selections disappear if you go too far up or too low. This is because we’ve not restricted how many selections we can have. We’ve only got conditions for 5 selections, yet the number we have available is infinite.

In your LateUpdate(), you’ll need to add a couple of lines to restrict it. Now you can see why I’m using a late update. I could stick any changes to my selection in update anywhere and it won’t cause any bugs on how ‘selection’ is clamped, because it will always be called after ‘Update()’.

image

If this were called BEFORE we had any input to change the selection, then the above would simply have no effect. Hence Update() then LateUpdate()

Translation into plain English: If the current selection is lower than ‘1’ then set it to ‘1’. If it is higher than the total number of menu items then set it to the total number of menu items. It’ll stop the number going less than 1 and more than 5.

Now run and you’ll find that you can cycle through your menu.

image

The next step is to give each selection a function. The simple, non-flexible method is: (for Quit)

If selection = 5 and returnkey() = 1 then end

But I’m not going to make it that easy, because you might remember when I talked about adding or removing items from the list. If I added 2 more items, heck, if I added 2 more items before Quit, then it would no longer be selection five. This maybe not be so applicable in a title menu, but in an inventory menu, it’s pretty important.

So, what I need the computer to do is parse through my variables and pick a Menu item called ‘Quit’. Think of it like looking for something specific on a database. Or typing something into Google, though of course, instead of thousands of results, there’s only one and it’s looking through a total of 5 items. With this method, you could change all of the names to ‘quit’ and when you hit enter on any of them it’ll close the program. Useful, eh?

image

Into plain English. When the user hits ‘return’, look through all menu items (x =  to menucount) then check if it’s called “Quit” then close the application. For every type of item you want you can just add another statement.

image

I’ve put ‘end’ as we haven’t got anything for ‘New Game’ or ‘Load Game’.

That’s it for part 2. Why not experiment and try this?

Instead of having your code check the name of the item, give it a ‘purpose’ and then have the code read that. You might set your purpose to “end”, “start” or “loadgame”. In your menu create 2 instances where the purpose is set to ‘end’, but have 2 completely different labels. With code you’ve learned in these 2 parts, it should be possible. Why would you want to do this? Lets say you have 2 types of healing potions in your inventory in a game, instead of listing the name of every single potion and created an effect for every single one, you could actually cut it down to a single condition if you use that method. So you could have as many types of health potions out there without altering this part of the code. Handy.

DBP Series #1: The Menu part 1

This is the first part in a tutorial series in Dark Basic Professional, aimed at beginners.

This tutorial will start with something easy to get you started. Everybody will have their own approaches to program and the way you will be learning things will be based on how I program. My methods are inspired by how Object Orientated Programming (OOP) works. You don’t need to worry about what that means, because Dark Basic can’t actually do OOP.

Programming looks kind of scary to begin with, because it’s just a wall of code and equations. The way I tend to think of it is you’re learning how to speak to a computer. Computers do not speak English and it’s very difficult for them to understand, so you’re speaking in terms you both are capable of understanding coherently. A computer’s language is very mathematical, though you don’t actually need to solve any mathematical equations, you just need to make up those equations. Just as well, because my maths is actually horrendous. I got a C at GCSE level, which isn’t very impressive. I could do a simple, “hello world” app, where you learn to display some text on the screen, but I’m going to go a step further than that. What you’ll be creating is an interactive game menu. It’ll look basic, but it’ll give you some core principles to get started.

I like to get started with some structure first. What I mean is provide a template to place my code, because it’s always a good idea to organise your code, when your program gets bigger and bigger it can be harder and harder to maintain. Doing things this way I find it makes things more manageable.

So, copy this structure and I will explain:

image

This might look a little confusing. I’ll break it down for you.

The green text, which starts with ‘//’ are comments. Whenever you type ‘//’ anything on that line will be ignore by the compiler. This means you can leave your self notes inside of your code. It might help you understand what you were doing with a bit of code when you revisit or help somebody else understand when they read your code

Do. Sync. Loop, everything that happens between the words ‘DO’ and ‘LOOP’ will be repeated every single frame. ‘SYNC’ is used for maintaining how fast your loops update. In this code, it will do nothing, its usage will be explained later. You’re saying to the computer, “keep doing this stuff and don’t stop”.

Functions these are little containers to store segments of code. If you think of your code as a room, your TV contains a set of functions and so does your computer, your bed has its functions. So you might have TV(), Bed(), Computer(). You have to make these functions and generally I make them at the end of the code. So you have to write ‘function FunctionName()’. you can call it anything you like, though it’s a good idea to make the name relevant. Anything between ‘function FunctionName()’ and ‘endfunction’ will be used whenever you type, “FunctionName()”.

TYPES. I will explain these when I use one. These are useful in managing data. Not every one uses them, but I love them. You’ll see why they’re useful in this tutorial.

PUBLIC DECLARATIONS. The name might be confusing because Dark Basic Pro doesn’t use the term ‘private’ or ‘public’ in making variables. First, what is a variable? It is like doing algebra. You know, equations like: a = 3, b = 5, a + b = ?. But variables in programming are more flexible than that, they will store a number or a line of text or a single character, depending on the type of variable used. To make these variables, you have to declare them. A public variable is just one that can be accessed anywhere in your code. A private one is one that’s only accessible in a segment of code. In Dark Basic, variables are private by default, if you wanted something ‘public’ then you need to use the ‘global’ command. It will be explained when I get to it.

CALLS. This is where I call all of the main functions in the program. It’s how I structure my code. Not everybody does it this way. This is closer to how you might do things if you were using OOP.

Now to talk about the structure itself. Everything above the loop will only be ‘called’ once, everything inside of the loop will be called repeatedly.

Load(). This is what will happen first. This will be used for loading any data you need in a program, You might load an image or a piece of music or a 3D model or several things to make up your game world. That all goes in here.

Awake(). This is what will happen second. This is will collect a set of priority commands that’ll need to happen before anything else.

Start(). This is what will happen third. It’s like Awake(). In theory you could combine the two, it would not matter. I like to have 2 separate functions. It’ll make more sense as we move on.

GUI(). This is what’ll happen first in your loop. This will handle anything inside of your graphical user interface. It’s good to keep this separate as to not mix it up with other code. So you might stick everything to do with your menu in here. Or you might stick in your player health bar and well, you get this idea.

Update(). This is basically where you’re going to stick your game logic. This could be your input (to control a character) or AI. This is where your game’s functionality will exist.

LateUpate(). This is anything that needs to be updated right at the end of your code. For example, you might have something like a Bloom Shader and you will need to produce its final result at the end of the code.

In theory, I don’t need any of these functions and could just code it all straight in, but as I’ve said, this method makes things more manageable. Of course, this is only on a primary level, you can actually use a function within a function, which means inside of Update() you could have UpdatePlayer(), ControlPlayer(), EnemyAI() and so on. This method just allows you to break things down. If you had an error that occurs whenever you move the player, you can go straight to ‘ControlPlayer()’ instead of flicking through lines and lines of code to find the specific line you need to alter.

So now that the structure is out of the way. What are we going to do? Lets start with the ‘TYPES’. The ‘TYPE’ commands allow you to create your own variable type. So I mentions you’ve got lines of texts and numbers, this command will allow you to have an organised system of using them. Kind of like forming your own database. You might have a person’s name, their phone number, their favourite food and so on.

For our menu, I am only going to create one ‘type’ and I’ll call it a ‘list’. I like my list type to be versatile and to be used in a whole number of situations. So it might be for our menu items or items in an inventory or abilities a character can use.

image

For this tutorial, the only criteria our menu needs are ‘name’ and ‘active’. ‘Purpose’, ‘modifier’ and ‘description’ would be great for an item in an inventory.

But what are strings, floats and booleans? I said there’s different types of variables you can use. A string will contain text. A float is a floating point variable, or in layman’s terms, it’s a number with a decimal point. A boolean is a statement that is true of false, to put into context, “This Item is Active, true of false?” If false, then no, it’s not active, if it’s true, then it is.

How are we to use this list. Like a variable, we have to declare it. So you might do: “Menu as List”. But you will notice a problem. That would only make 1 menu item. So if say, I wanted 3 items in my menu, would I have to do this:

MenuItem1 as List : MenuItem2 as List : MenuItem3 as List

No you wouldn’t, that’s a waste of space and your time. Programming languages have a solution for that, it’s called an ‘array’. You just give the program the number of arrays you want and it’ll make them for you. In DBP, this is done by the command ‘dim’. Where do we put this command. It’s a variable and as it’s an array, it will be public, so it’ll go under ‘PUBLIC DECLARATIONS’.

image

I’m going to have ‘5’ items in this menu. So if I want to point to item number 2, I’ll use ‘Menu(2)’, for number 4, ‘Menu(4)’.

Next, lets give these menus some properties. We’re only going to be worried about names at the moment. Where do I stick it, it’ll be one of the first things to happen in our code, so we’ll stick it inside of ‘Awake()’.

image

Now things should be started to look clearer. But before we give this any functionality, you’ll be wanted the program to display these onto the screen, just so you can hit ‘compile’ and get something to look at.

First, lets head back to the public declarations,under the array, type:

image

Gap – Will be used for determine the distance in pixels between each menu item

Selection – Will be used for later

MenuCount – This will record the number of ‘items’ in your array, which is ‘5’. We did write ‘5’ previously and in theory we could just say, “MenuCount=5”, but what if you decide to add another item? You’ll have to change this to 6 as well. Array Count will grab the number of items inside of ‘Menu()’.

 

Now head to ‘GUI()’ and type this:

image

Now this looks a little confusing. This is called a ‘for loop’. It’s like the ‘do loop’, but it will only do it a certain number of times (and will be completed before a single frame is rendered). You will use a variable called ‘x’ (it can be called anything) to cycle through each update. It can start at any number that’s convenient for you and can end on any number that’s convenient for you. The reason the numbers are so flexible is because you may wish to use ‘x’ in a calculation and the first number in that calculation might not be 1. For us, we want to do an update for every single item in our list, so that is item 1 to item 5. Hence, for x = 1 to MenuCount (which is 5).

To explain ‘h’. ‘h’ will start at ‘0’ and at the ‘gap’ variable on every update. This means, it’ll go up 15 every time. This is useful for determining where I place my text. This method will mean each line of text is 15 pixels below the last.

With the text command, the 2 number you use are for where you want your texts to be be placed. This is 10 Pixels on the X Axis and 10 + h on the Y Axis, which puts it at the top left corner of your screen. The text we are displaying is the name of each menu item. You can see where ‘x’ is useful because it saves us time.

What I’ve done here is something called ‘parsing’. It means it’ll read through a selection of data and look for pieces of information. This is better than doing this:

image

Both will have the exact same results. The latter is easy to read and easier to understand, but very limited. The form is a lot more flexible. Lets say you were to change the number of items on the list to ‘7’, you’d have to add two more lines to the latter and nothing to the form. And in that last image, if you wanted a dynamic inventory where you could add or take away items, it’d just be impossible.

Now hit compile.

image

That’s what you’ve got. Better than a crappy ‘hello world’, right? It seems like a lot to get there and given the amount of explanation needed, it might not seem so simple, but that’s because you’re learning and need to get used to these concepts.

Experiment. Add more items. Change the gap size, place the menu elsewhere on the text. If you’re feeling adventurous, maybe use variables to alter the position on your menu. Make it so you can control the menu position from the Update() method, yet keeping your text commands in ‘GUI()’. All the information you need to achieve that is in this tutorial.

Abeyance: Keats Remodel

I’ve got started on reworking the Keats model and I’ve gone more for the original Keats style, but in 3D.

So here’s old sprite Keats

And this is what he looks like (texturing not complete) in 3D:

And in Unity3D?

There will be some improvements on the level graphics as well, as they look a bit crap at the moment.