Thursday, December 29, 2016

How to implement movement undo

It turns out that Skye still has a partner in crime on this project. I tend to keep to my hermitage, but from time to time, I feel it necessary to let people know I'm still here. Lately I've been focusing on building the code instead of the artwork, which is why there hasn't been much to show. However, I thought it might be interesting to talk about some of the design.

One of the most constructive bits of feedback we received from the Salt Lake gaming convention was that our movement system was not immediately intuitive. Because of that we decided to overhaul it and move to a point-and-click waypoint system similar to other tactical games. There are a few working parts to this, including the path finding algorithm, the grid system, the waypoints, and the actual movement. However, I'd like to focus more on the design of the waypoint system.

For those familiar with the fundamentals of programming, there is the concept of a stack. For those that know a bit more, there's another concept called the state pattern. A stack is essentially what it sounds like. You add things to the top and when you need something, you take it off the top, making it a "last in, first out" structure. The state pattern is a way to design the flow of a program. Essentially, there is one object that everything references and it delegates to state objects that behave differently. In order to implement a path (with waypoints) that can be undone, I employed a combination of these two concepts.

Here come the technical details, so if that makes you uneasy, feel free to stop here or skip to the last paragraph. Anyway, to start, I added an interface for what I refer to as an “action”. This action is essentially one of the state objects and any state in the state machine will need to have the same interface to its actions as the others in order for it to be reused. As I am using C#, the code looks something like this:


1
2
3
4
5
6
public interface IAction {
 void Act(Vector2 move);
 void Act(bool confirmation);
 ....
 ActionType GetActionType();
}


The Act() function accepts a number of different types of arguments. Each one will be implemented differently based on the state.
An example of one of the states might be something like this:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public class MovementSelection : IAction {
 private Vector2 location;
 public MovementSelection() {
  // Initiation stuff for this state
 }
 public void Act(Vector2 move) {
  // Check for stuff that might need to validated before the move actually happens
  // Now we have a move, so we need to store it and move to the next state
  location = move;
  ActionHandler.Instance.SetState(new MovementWaypoint(move));
 }
 ....
 public ActionType GetActionType() {
  return ActionType.MovementSelection;
 }
}


As you can see, the state is in charge of initializing stuff for itself, storing any relative data, and then moving to the next state if appropriate. It also can return the type of state it is for bookkeeping if necessary. Then the next state (MovementWaypoint) handles itself in a like manner. And of course different states will keep track of different stuff and behave differently.
Now you may be wondering where all of this is initiated from and where the main handler object comes in. One of the keys to the state pattern is that the states are essentially hidden from the rest of the application. The state handler and other states are the only ones that should know anything about states. Ultimately, the state handler becomes the interface to the rest of the application for this.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class ActionHandler : IAction {
 // The following makes this object a singleton
 private static ActionHandler instance;
 public static ActionHandler Instance { 
  get {
   if (instance == null)
    instance = new ActionHandler();
   return instance;
  } 
 }
 private ActionHandler() { /* any necessary initialization here */ }
  
 private Stack<IAction> stateStack;
 public void SetState(IAction newState) {
  // sets the current state or, for us, adds it to the stack of states that are used to keep track of state history
 }
 public void RevertState() {
  // Pop off the stack to have the previous state be the current
 }
 public ActionType GetActionType() {
  // get the type of the current state 
 }
 public void Act(Vector2 move) {
  // calls Act on the current state
 }
 public void Act(bool confirmation) {
  // calls Act on the current state
 }
 ....
} 


There’s kind of a lot going on here, so explain it a bit. The first part makes this into a singleton, which ultimately means that only one instance of this object will ever exist. I won’t go into too much detail on this concept, but this is important because we only want one occurrence of the state machine. The next part is the stack that I mentioned previously. This is used to keep track of a history of states, or in our case, moves. The MovementSelection state handles the initial selection and the MovementWaypoint state handles subsequent selections and can also close out the path. Since all of these states are kept track of in the handler, it can handle all of it and delegate calls to the states themselves. Then if we need to undo, we can just revert the state and have the previous state as our current.

The benefit of using a stack is relatively obvious as it provides a history of actions, however, the state pattern is another powerful tool. Instead of having to edit a lot of code that could potentially be in a giant if statement, we can just add a state and update who goes to that state and what that state’s behavior is. Additionally, the state pattern can be expanded to more than just the movement (hint: I used this for the entire battle flow). Anyway, I hope this has given some useful information to those curious about the process.

Tuesday, December 27, 2016

Dev Take Tuesday - A Small Tribute to Carrie Fisher

Like many others today, I’m saddened by the death of actress Carrie Fisher. As a huge fan of the Star Wars universe—including the movies, books, and video games—I first appreciated Carrie Fisher for her role as the iconic Princess Leia. But later in life I started to also appreciate her honesty and candor in interviews as she discussed her problems with mental health and addiction. I think it’s important for me to remember that she wasn’t just about unconventional hairstyles, creative insults, metal bikinis, or even her skill with a blaster. Carrie Fisher was royalty off the screen as well.

Image found on this Huffington Post article


While writing and developing the characters of Alkanaur, I’ve always known that mental illness would play some role in shaping their personalities and backstories. I’ve personally dealt with depression and anxiety, and people close to me have had even more acute experiences with mental health. At this point, I haven’t written any specific dialogue, so I’m not sure how much of our characters’ problems with mental health will show. However, I do promise that all our characters’ struggles and experiences will be treated with respect, openness, and sincerity. Hopefully—in some small, small way—that will be a fitting tribute to Carrie’s legacy.

Saturday, December 17, 2016

Showcase Saturday - Steam Greenlight and Skelattack

When I mention that I’m making a video game to friends and family, many people are curious how we’ll take our game to market. I’m going to use this showcase Saturday post to give a quick explanation of how we plan to get our game to consumers: Steam Greenlight.

Image found on Steam's website


Steam is essentially a digital storefront for nearly all computer games on the market. With few exceptions it’s safe to say that if you’re into PC gaming, you know Steam and use Steam. Steam used to curate all available games on its own, accepting titles from known publishers and then reviewing games from smaller companies to see if they belonged on Steam. With more and more independent (indie) publishers trying to get their games on Steam, the company decided to use a new crowdsourced approach called Greenlight.

So once our game is a little farther along—we’ll need to include screenshots and a nice trailer that show polished gameplay—we will enter Alkanaur into the Greenlight process. Once there, people can vote whether or not they’d be interested in buying the game. If we get enough attention, our game gets “greenlit” and we reserve a spot on Steam’s digital shelves, so to speak. From that point on we’ll continue to develop our game until it’s ready for release. Another nice feature of this process is that we’ll be able to build a community on Steam and keep receiving feedback to improve.

With so many games trying to be greenlit, the first few days of being on the front of the Greenlight page are vital. After you slip further back in line, you rely on other avenues to get visibility on your personal Greenlight page. So we’re hoping for a big first day, but if we don’t get greenlit right away, we’ll just keep spreading the word. Both Robby and I are confident that we’re making a well-designed, polished, and meaningful game that belongs on Steam, but it might take some extra work to make sure we get the necessary visibility. When the time comes, we’ll be reaching out to everyone for a bit of help. We’ll let you know!


In the meantime, I’d like to showcase a fun game called Skelattack. I’ve been following its progress on Twitter, and I think it has a unique character design and some fun gameplay. Skelattack is currently in the Greenlight process, so if you have a Steam account head on over to this link and check out the game. There’s even a demo version for Mac and PC users.

Tuesday, December 13, 2016

Characterization Takes Time

I recently finished the television series Supergirl. In the first few episodes, I had some reservations. I sensed way too many tropes and flat characters. Add that to the fact that I’ve never exactly been enamored with Superman as a concept, and I was about ready to drop the series altogether.

Fortunately a good friend convinced me to give it a bit more time. As the season went on, Supergirl’s supporting cast became much more vibrant. In fact, two of my least favorite characters—Cat Grant and Hank Henshaw—became my two favorite characters by season’s end.

High-power CEO Cat Grant from the show Supergirl (image found here)

Characterization takes time. If you want characters in your TV show, movie, or video game to develop, you need to give your audience sufficient time with them. If the characters change too fast, the development won’t seem realistic. And if you don’t change at all, you end up with flat characters that will never really capture your audience in a profound way.

In Alkanaur, we wanted to provide our audience with fun, insightful, and sincere characters. On the other hand, we also know that many tactical gamers want to focus on the gameplay with minimal distractions. Our compromise was too split most of the character building from the tactics battle system. While actions in the battle will influence character relationships and conversations, those conversations will take place in separate, optional events that we’re calling “tavern moments.”

These tavern moments will have characters sitting next to each other and discussing the most recent battle, and as relationships deepen their conversations will become more profound and open as well. As a writer and storyteller, I—of course—hope that players will participate in these tavern moments. With sufficient time, I think that they’ll fall in love with our characters just as I fell in love with Supergirl’s characters. However, I’m also glad that people who want to get right back to the core gameplay will have the option to do so.

Tuesday, December 6, 2016

Balancing Innovation, Pragmatism, and Patience

Lately, I’ve been playing a lot of Terraria, the action-adventure sandbox game from Re-Logic games. With over 200 hours played at this point, it’s obviously held my attention for quite a while. I was discussing the game with my wife tonight, and I initially said that the game was perfect. Or at least perfect for the game it was trying to be. But, to her credit, my wife pushed me to keep thinking about what I would change. And I did eventually find some (small) issues with the game.

My number one issue is inventory management. Terraria’s dev team does an amazing job delivering free, content-rich updates, and those updates have added some helpful features for managing all your stone blocks, countless potions, and leftover furniture. The system of storing items in various chests is still unwieldy, however, and I find myself irked when I spend an entire play session reorganizing my chests simply because I needed to expand my home.

The much, much harder question is: what would I change? I’m not sure there’s a great answer here. You could get rid of all chests and just have a global inventory, but that would take some of the survival and resource management mechanics out of the game. One big “home chest” that you can’t move but holds everything? That would lead to a massive mess of an inventory and creates a huge problem if you do have to move the chest for some reason. All of the “fixes” I came up with in my own quick brainstorm had serious drawbacks as well.


Not every conundrum in game design has a clean answer. For example, in Alkanaur we’re always looking at ways to speed up combat for the player, but no matter what there’s going to be some pauses in the game. When we chose to make a turn-based strategy game, we simultaneously chose not to have the responsiveness of a real-time action game. Of course, such thinking can stifle creativity. If designers always left things the way they were, we’d miss out on a lot of great innovations. I think the key is accepting that every design has a drawback, while at the same time pushing ourselves, constantly asking: what could we change? 

Saturday, December 3, 2016

Showcase Saturday 12/3

Hope everyone's having a great weekend!

On our Showcase Saturday this week, I want to show off a pixel art concept Robby and I have worked out for a character we're calling Sentinel for now.


Sentinel focuses on defensive abilities using her humongous tower shield. Her parents were too wrapped up in their own busy lives to take care of their several children, so as the oldest daughter she learned to take care of those around her. Now she takes her protective personality to the battlefield as a member of the mercenary team.

For these pixel art character concepts, Robby and I work together through various iterations until we find an art concept that fits the gameplay and narrative niche for that character. It takes a little longer to get it right, but we want each character to feel unique and look fantastic.