Thursday, 7 May 2015

Intersecting Paths on a Hexagon Grid

In an earlier post, I discussed a co-ordinate system for a hexagon grid.

In this post, I will discuss a problem I worked on recently concerning such a system.

Essence of Glory is a game of formations and positioning. One way this manifests is in the system for close Assaults. These do not necessarily refer to hand to hand combat (although boarding parties are one possibility), but "close" engagements. Sort of how two airplanes coming within a mile of each other is a near miss.

The system we are using for Assault stipulates that an Assault occurs between two opposing wings of ships if they pass through each other during the Movement phase.

The question is, how do we determine when ships pass through each other?

There are two options, really. Either track ships as they move and report any collisions, or do some calculations based on their paths.

The first option isn't really useful, because we want Assaults to occur any time ships' paths cross.
We don't necessarily care if they are in the same space at the same time.

So we are better off looking at the movement paths as a whole. Remember the grid system?


A vector can describe either a position, or a change in position.
[2,0] may be the position to spaces to the right on the horizontal axis, or it may represent a movement of two units in that direction.

It would be possible to describe the movement of a unit with one vector, but it wouldn't be as useful. For example, a ship starting at [0,0] might move to [-2, 1], but did it pass through [-1, 0] or [-1,1]?
If we described that movement using only the vector [-2, 1], we would have no way of knowing.

Instead, we can store the movement of a ship with a series of unit vectors. Unit vectors are those with length one. Note that in hex co-ordinates, [-1, 1] is a unit vector, but [1,1] is not.

So, a ship starting at [0,0] and moving to [-2, 1] could have its movement described with the sequence of unit vectors {[-1,0], [-1, 1]} or with {[-1,1], [-1,0]}.

To find all the hexes through which a ship passed during the course of its movement, just add each of the unit vectors in its path to its starting position in turn.

Then, to find which ships will assault each other, find all hexes that all ships passed through during the movement phase, and then find those that are shared between opposing ships.

Monday, 27 April 2015

No Aliens Allowed: Why Only Humans in "Essence of Glory"

Yeah, what he said.
I think we really didn't want to include aliens because they simply wouldn't add anything. At the end of the day essence of glory is about politics and the people they affect particularly those on the front lines. In this case aliens can add some interesting things to a sci fi story, especially for characters. The point here is for aliens to present different perspectives to the human characters. Prominently in the Mass Effect series, alien races have vastly different goals and systems of morality to the protagonist and humanity. An effective narrative tool but in the end that's just it, a narrative tool to present the player with different perspectives on their actions.

Don't you want to see the version with Germans?
At the end of the day I'm aiming to achieve a similar goal but simply with other human nation states. In fact to me, using humans rather than alien analogues is much more effective because it's not as hard to sympathize or be horrified by their actions(Although there is some great sci fi about people trying to sympathize). In classic Sci fi, extraterrestrials were sometimes used as manifestations of real political fears and crises. For example The War of the Worlds by H.G Wells is an example of British "invasion literature" in which Britain fears invasion from some outside force. The Battle of Dorking by Sir George Tomkyns is a novel with a similar plot and structure with the difference being the martians in war of the worlds are replaced with Germans (minus the armoured war tripods and heat rays).

Tangent aside, my point is similar narrative goals can be acheived by both human and alien actors in a story. The question is really one of tone, aliens have a tendency to sterilize a plot point whereas with humans it feels that much more visceral.




Thursday, 19 March 2015

Ease of Unity

This is my first project at really using Unity, and in the game development community there is a saying that you don't need to know coding that well to make a game using it. It seems that is actually the case... to a certain extent.

It seems that although you COULD technically use only the built in libraries for Unity, and how it handles cameras, assets, and rendering; to make a game using 100% code, it is entirely possible to use just assets, and use the settings provided with each asset with a few scripts here and there to glue things together.

One plus side of Unity is that the community is really big, and if you need a certain asset, what you're looking for will probably be in the store. Even if you need a certain functionality with it, you could potentially find that also. Making changes in the game to be event driven is also taken care of nicely in the engine itself, and is able to be set through simple dropdown boxes when you add it to a certain scene. Even if you do need to write code for certain events, the libraries handle a large component of the groundwork already.

So for anyone with cool ideas for games, or is even an aspiring game developer. Unity is a great engine to experiment with, even if you're not from a coding background.

Wednesday, 18 March 2015

Unity 5 + Progress + Planning

Unity 5 was released recently, and so we decided to go ahead and move the project to that.
It seems to contain many updates to the high-end graphical and animation side of things, which this project may not touch, but there's not much reason to continue developing for an older version.

The conversion process was straightforward. All that was necessary was to open the project in the new editor, and the upgrade was automatic. It did take a surprisingly long time, and seemed to hang, but others have reported encountering this problem.

Anyways, I've been working on the rules side of the game. Essence of Glory is a table-top game for two players. It features dice, orders tokens, models, and a grid to play on. But there is also that portion of the game that exists only within the player's heads. They need to keep track of what turn it is, who has to play, and what they're doing at this juncture. And it is that non-physical side of the game that I have been tackling recently.

The game engine needs to know what turn it is, what phase it is, and what's happening, and it needs to present this information to the player in a convenient way. It also needs to account for the different ways of playing the game. Players may face off against the AI, or they may play with their friends over the internet, or around the table. I've been spending time thinking about how to handle all this, and started putting those ideas into action.

Since there aren't any illustrative screenshots to show off yet, maybe it might be fun to try to figure out my notes? Find them below the fold.

Tuesday, 17 March 2015

Dreaming Man Update 7

I've come up with a new flowchart and decided that I'll add as I write more. I've also come up with a bunch of key turning points where the player has options that affect the outcome of the story (standard VN dialogue options).

This is written pretty bare-bones for simplicity, as Matt and I will be the ones mainly using it. It's going to be added to as more is written and decided.

One of the options:

Protag Dialogue Choice
Asuka?
Good morning.
??? – Asuka… Who’s that? Were you dreaming about someone, or are you still asleep? You must mean your wife, Amelia. [put her name in bold]





How’s breakfast coming along?
....
Amelia – Almost done!
Amelia – Breakfast is almost done!

To do: Actually rite moar

Thursday, 12 March 2015

Dreaming Man Update 6

Not much to post about this week. I'm currently just in the process of writing dialogue.

I believe Matt is looking into the aforementioned functions from the last post.

Wednesday, 4 March 2015

Events in Unity

Events are a useful tool for communicating between game objects, especially when you don't know which objects will be communicating with each other.

Say we have a Button. When the user clicks on the button, we want another Thing to do task X. Maybe the code would look like this:

void OnClick(){
     Thing.doX();
}

All very well. But what if we decide that actually, there's going to be a whole bunch of different Things in this scene, and they should all do X? What if those Things need more information to do X? What if the set of Things that should perform the task X is constantly changing?

If any of that is true, that means we'll have to change our code for the Button in order to change what and how Things do X. And all the while the button hasn't changed. It's still there, doing its thing, getting clicked by the user. So why should we have to change the Button, if the responsibilities of other objects have changed?

The answer is that we don't, if we use Events.

Events are a really handy construct. They can be thought of as a one-to-many relationship, where one object publishes or broadcasts events and a set of others receive and act on them. Just like a radio broadcaster doesn't know how many people are tuned in at any given time, the Event broadcaster doesn't know what objects are subscribed or even if any of them are.

So our button code would be changed to look something like this:


//This defines a delegate which is a little like a function pointer.
//It defines the kind of function that is needed to handle the event.
//In this case, a void function that takes an object is needed
//to properly handle this event. 
public delegate void ClickEventHandler(Object sender);

//This goes inside the Button class, and defines a delegate member of the ClicEventHandler type for that button.
//This is the event that other classes will listen to.
public event ClickEventHandler clickEvent;

 void OnClick(){
     //Now, when the button is clicked, all of the delegates subscribed to the event will trigger
    clickEvent(this);
}

public class Thing{
    public void handleButtonClick(Object sender){
        doX();
    }
}


Now, we can change the behaviour of the Thing without changing the button at all.

In Essence of Glory, events are used to update parts of the game engine about changes in other parts of it. For example, when a ship is moved in the Model, an event is raised that is received by the View, which then updates where that ship is displayed on the screen. Events can also be used for special effects that trigger under certain conditions.

More information about Events in C# can be found here and in Unity here.