Showing posts with label game design. Show all posts
Showing posts with label game design. Show all posts

Tuesday, March 29, 2016

PixelMaker - a pixel art and sprite drawing program


I've been thinking about making a sprite editor for a while now. Drawing sprites is a big part of what we do when making our games. We have been using GIMP as our primary drawing tool, and while it works pretty well, it doesn't mesh perfectly with our workflow.

So, a few months ago I finally pulled the trigger and started working on PixelMaker. In order to justify making a polished program (instead of a rough-and-ready developer tool), we plan to release it on various platforms - initially on Wii U (the GamePad and stylus are great for drawing) and then later on mobile/PC.

I'm pretty happy with how it is turning out. It loads instantly, unlike programs like Gimp and Photoshop, and is fast and lean - with the features you need for drawing pixel-y stuff, uncluttered by features you don't need (at least *we* think so - we'll see once we have more customers...)

Our initial feature set for release targets drawing individual pixel art pieces, but future planning includes frame-based animation.

On a more dev-centric note, I recently bolted on a project structure interface for us to manage the art assets for a game - designed to integrate with the custom sprite scaling/shadowing/sheet-packing pipeline we currently use:



We plan to get back to working on our already-well-in-progress next game soon, now switching over to using PixelMaker as our core art creation and management tool.

What next game is that? Well, stay tuned for more on that soon!

Monday, April 11, 2011

Randomization In Games - Managing Player Expectations

Block Village

Generating random numbers for use in games is easy. In C#, it is as simple as creating an instance of the Random class and calling Next() on it. Want to decide if an event should occur given a particular probability? Easy, just call Random.Next() and check if the result is less that your probability (expressed as a value from 0 to 1).

The results of this simple approach, however, do not always do a good job of creating behavior that corresponds to a player's expectations. This is because the results are truly random (ok, psuedorandom - but that's generally random enough) and events are independent. By independent, I mean that the result of a probability check does not depend in any interesting way on previous checks. Like flipping a coin, it doesn't matter if you have gotten 9 heads in a row - the probability of getting heads on the next flip is still exactly 50%.

People, however, have a tendency to assume that past result *do* influence future ones. In the case of flipping a coin, this assumption is irrational. In other cases, though, it isn't so much. A key example of this is selecting items randomly from a collection. If you replace items between choosing, then each selection is random and independent of the others. If, however, you do not replace items that you have chosen, this is no longer the case.

The notion of selecting items from a collection without replacement is a very useful one in games, and can result in random behavior that is much more in line with player expectations than independent probability checks.

In working on Kung Fu FIGHT!, I ran into this problem a lot. For example, when an enemy throws a shuriken, I have to decide if they should throw high or low. I started with a simple 50% probability check, but this sometimes resulted in a long string of high or low throws in a row. Perfectly reasonable from a probability perspective, but not what I wanted. On the other hand, simply alternating between high and low seemed too regular.

What to do?

I created a simple helper class to allow me to select random values from a finite "bucket". Here is how it works for my shuriken throwing behavior. To initialize the bucket:

Random random = new Random();

RandomBucket<bool> throwBucket = new RandomBucket<bool>(random).Add(true, 2).Add(false, 2);

What this does is initialize a bucket and fill it with two 'trues' and two 'falses'.

Then, to decide to throw high or low, simply do:

if (throwBucket.Choose())
{
  // throw high
}
else
{
  // throw low
}

Each time we call Choose(), a random value is selected from the bucket and take out of the list of available values. When we run out of values, the bucket is refilled with its original contents.

The result of this is random behavior with local dependencies. Each time I select a value, the probability that I get that value again next time goes down. You can't get more than four trues or falses in a row - and even that is fairly unlikely. If we only put 1 true and one false in the bucket instead of two of each, the behavior becomes even more locally dependent. Adding more values in makes things more random.

In addition to having nice properties for game randomness, the RandomBucket class also make for simple, clean code. For example, when I shoot out spark particles for bombs, I use a color bucket to choose what color a spark is:

RandomBucket<Color> colors =
  new RandomBucket<Color>(random).Add(Color.Yellow, 1).Add(Color.Orange, 1).Add(Color.Red, 1);

Color sparkColor = colors.Choose();

Here I am spitting out the colors in equal volumes, but I could easily change the ratios by altering the numbers when seeding the bucket.

Here is the RandomBucket class. As you can see, it is pretty simple. It doesn't generate garbage (an important quality for Xbox development) and it is quite efficient for reasonably small numbers of values, which should be the case since if you use a large number of values you might as well just use true randomness.

using System;
using System.Collections.Generic;

namespace MyCoolNamespace
{
    public class RandomBucket<T>
    {
        List<T> chooseList = new List<T>();
        List<T> discardList = new List<T>();
        Random random;

        public RandomBucket(Random random)
        {
            this.random = random;
        }

        public RandomBucket<T> Add(T value, int number)
        {
            for (int i = 0; i < number; i++)
            {
                chooseList.Add(value);
            }

            return this;
        }

        public T Choose()
        {
            if (chooseList.Count == 0)
            {
                List<T> tmp = chooseList;
                chooseList = discardList;
                discardList = tmp;
            }

            int pos = random.Next(chooseList.Count);

            T obj = chooseList[pos];

            chooseList.RemoveAt(pos);

            discardList.Add(obj);

            return obj;
        }

        public void Clear()
        {
            chooseList.Clear();
            discardList.Clear();
        }
    }
}

Wednesday, March 16, 2011

Don't Forget the Instructions

Block Village

When you are working on a game, it is easy to lose track of the knowledge you have about how your game works - knowledge that may not be obvious to other people.

When playtesting and reviewing XBLIG games, it is amazing how often I find myself in a situation where I am confused about what to do, or miss an important aspect of gameplay. I've also certainly been guilty of putting others in the same situation with my games, but I'm trying to be better about that.

Here are a few thoughts on the subject of game instructions:
  • You need instructions! It doesn't matter how simple you think your game is, you need to explicitly tell people how to play otherwise you will lose some of them. A confused player probably won't buy your game.
  • Don't assume people will read them. Just because you have instructions squirreled away in your options menu doesn't mean that people will read them. Instructions are boring - people will skip them. Providing gameplay information in the context of the actual gameplay itself is the best way to ensure the player will actually see it. In Kung Fu FIGHT!, I display in-game control hints in the early stages and I also display gameplay tips when the player dies.
  • Keep it simple. The best way to get people to read your instructions is to keep things concise and straightforward. Ten pages chock full of instructions will put people off. If your game really is that complicated, try to introduce concepts gradually and explain them when they become relevant.
  • Playtest makes perfect. As the person who knows everything there is to know about your game, you are the absolute worst person to judge which aspects of gameplay are obvious and which are not - you need to have other people play it. Kung Fu FIGHT! has been a clear example of this for me. People testing the game got frustrated because they didn't understand that certain actions were possible. The game difficulty level is plenty hard enough without confusion adding to it. Playtest feedback has allowed me to identify confusing situations and ensure that the player gets the information they need.
You really need to give your game instructions the attention they deserve. While it isn't the most sexy or fun aspect of game design, it is too much important to overlook.