Pre-school Lion Official Launch!

It’s been a crazy week launching our latest game for pre-school kids on Google Play. We’ve been contacting review websites and getting feedback from the launch. It’s a pretty exciting time, and I’m so glad to have reached this milestone in the project! I almost forgot to post the news on the blog. How crazy is that.

GetItOnGooglePlay.png

Preschool Lion is a collection of educational mini-games for pre-school kids aged 2 to 5.

Many of the games focus on topics they will need for thier first year of school like shapes, colors, numbers, the alphabet, top, bottom, left, right, bigger, smaller, counting and upside-down.

There is also a game that will teach your kids about letters and how how they are used in words and a cool toy box mode that uses real physics as a reward for completing the educational games.



Features:
– Beautiful hand drawn flash cards throughout the games
– Animated lion to help with the puzzles
– Voice overs for all of the in game text
– A simple easy to use interface designed with kids in mind.
– Endless game-play

The flashcards cover every letter of the alphabet including the following words:
Apple, Balloons, Cake, Dog, Egg, Flower, Glass, Hot Dog, Ice Cream, Juice, King, Lion, Moon, Nuts, Orange, Pig, Queen, Rainbow, Star, Teapot, Umbrella, Vegetables, Watermelon, Xylophone, Yo Yo, Zip.

Counting from 1 to 20.
Shapes include Circle, Diamond, Heart, Rectangle, Square, Star and Triangle.

GetItOnGooglePlay.png

My Story

I recently wrote an answer to a question on Quora.. Can one developer make a successful indie game? and I thought I would republish it here.

Okay, here’s my story. It’s probably not what many would call “successful” but it’s an honest account of what I have achieved as an indie thus far.

Firstly, a bit of background. I’ve been programming since the age of 12. I’m 33 now and I’ve become very good at developing software. Making games has always been a hobby outside my day job but it’s only been in the last year or so that I’ve really been trying to figure out how to make money from it.

I’ve also got a family to support, a mortgage to pay and 2 children under the age of 4. So one of my biggest challenges is finding the time to make games and run a business. For that reason, I’ve had to greatly improve my time management skills and figure out clever ways to make the most of every spare minute.

Managing scope is also an issue. For a couple of years I burned a lot of time trying to build a project that was too big for one person. You’d be surprised how often this happens, and once you’ve already sunk hundreds of hours into a project it’s hard to give it up, even after you realize you’ll probably never finish it. Saying no, stripping features or doing whatever you have to do to get a game finished is really important. It’s probably also why the stats say so many projects fail.

Once I finally came to grips with my scope issues I made a decision. I was going to make a really, really small game and get it to market as quickly as possible. I spent another week thinking about what kind of game I could do in less than a month and finally realized it was staring my right in the face the whole time. I made a game called Toddler Word Puzzles for Android because it was something my 3 year old (at the time) could play and it was easy to create. The whole game took about 2 weeks from start to finish and I learned a lot about getting a game on the Google Play and developing for mobile devices in the process.

In the first couple of days of having the game on Google Play I made my first sale. $1.70 to be exact. I was excited and confused at the same time, I actually believed it might be a mistake. Obviously it wasn’t much money, but it was proof that someone appreciated what I had done and that was pretty cool. After the first month I had made about $5 total. The second month I made like $10 and in the third month I made about $20 and so on.. the numbers grew slowly and organically with no marketing at all. Today I make about $70 per month from that first app. There’s no reason to believe it will stop making money, but I’m also not sure how to grow the sales from here.

In terms of success, the game hasn’t done much to replace my day job. But it has made me believe I can do it again, a little better each time and grow a business doing what I love.

My current plan is to keep making games and building reusable tech by increasing the scope a little each time. Focusing on quality and learning everything I can about building an app business, marketing, etc.

I hope this helps, and you have to passion and drive to try doing what you love. I’d love you hear your story and others like this.

Introducing Craftwork Engine

draft craftwork engine logo

A couple of days ago I started merging the open source MonoGame CraftworkGUI project into my private Craftwork Engine project. Now the whole engine project is open source on github. Craftwork Engine is a 2D game engine based on MonoGame targeting mobile plaforms like Android, iOS and Windows Phone.

The engine is intended to follow the SOLID design principles but it isn’t quite there yet. So I’m also going to be refactoring the code along the way and blogging about why I think it fits better into the SOLID design principles, hopefully stimulating some interesting discussion to improve the design along the way.

Over the next couple of weeks I’ll be talking about how the engine works via a series of simple tutorials and examples while I’m refactoring and adding new features.

The get the ball rolling I think a good place to start is sprites. If you’ve worked on any kind of 2D game before, chances are you’ve used sprites in one way or another. However, if you’re using XNA or MonoGame you’ll quickly find out that there is no Sprite class provided for you. So the first thing I created in Craftwork Engine is a simple Sprite class that fits nicely into the SpriteBatch Draw methods.

    public class Sprite
    {
        public Sprite(TextureRegion textureRegion)
        {
            TextureRegion = textureRegion;
            Scale = Vector2.One;
            Colour = Color.White;
            Origin = Vector2.Zero;
            Rotation = 0;
            Depth = 0;
            Effect = SpriteEffects.None;
        }

        public Sprite(Texture2D texture)
            : this(new TextureRegion(texture))
        {
        }

        public Sprite(Texture2D texture, Rectangle sourceRectangle)
            : this(new TextureRegion(texture, sourceRectangle))
        {
        }

        public TextureRegion TextureRegion { get; set; }
        public Color Colour { get; set; }
        public Vector2 Origin { get; set; }
        public SpriteEffects Effect { get; set; }
        public float Depth { get; set; }
        public Vector2 Position { get; set; }
        public Vector2 Scale { get; set; }
        public float Rotation { get; set; }

        public Sprite Clone()
        {
            var sprite = new Sprite(TextureRegion)
            {
                Colour = Colour,
                Origin = Origin,
                Effect = Effect,
                Depth = Depth,
                Position = Position,
                Scale = Scale,
                Rotation = Rotation
            };

            return sprite;
        }

        public Texture2D Texture
        {
            get
            {
                return TextureRegion.Texture;
            }
        }

        public Rectangle SourceRectangle
        {
            get
            {
                return TextureRegion.Rectangle;
            }
        }

        public Point OriginPoint
        {
            get
            {
                return new Point((int)(Origin.X * SourceRectangle.Width), 
                    (int)(Origin.Y * SourceRectangle.Height));
            }
        }

        public Rectangle DestinationRectangle
        {
            get
            {
                var originPoint = OriginPoint;
                int x = (int)(Position.X - originPoint.X);
                int y = (int)(Position.Y - originPoint.Y);
                int width = (int)SourceRectangle.Width;
                int height = (int)SourceRectangle.Height;
                return new Rectangle(x, y, width, height);
            }
        }

        public override string ToString()
        {
            return string.Format("{0}", TextureRegion);
        }

You’ll also notice that the Sprite can take a TextureRegion in it’s constructor. This is so a sprite can be used with a texture atlas. I’ll talk more about that later, but for completeness I’ll include the TextureRegion class here.

    public class TextureRegion
    {
        public TextureRegion(Texture2D texture, int x, int y, int width, int height)
            : this(texture, new Rectangle(x, y, width, height))
        {
        }

        public TextureRegion(Texture2D texture)
            : this(texture, new Rectangle(0, 0, texture.Width, texture.Height))
        {
        }

        public TextureRegion(Texture2D texture, Rectangle rectangle)
        {
            Texture = texture;
            Rectangle = rectangle;
        }

        public Texture2D Texture { get; private set; }
        public Rectangle Rectangle { get; private set; }

        public int X
        {
            get
            {
                return Rectangle.X;
            }
        }

        public int Y
        {
            get
            {
                return Rectangle.Y;
            }
        }

        public int Width
        {
            get
            {
                return Rectangle.Width;
            }
        }

        public int Height
        {
            get
            {
                return Rectangle.Height;
            }
        }
    }

The final handy thing to know is how to render the Sprite with a SpriteBatch Draw call. For that I’ve created a handy extension method on the SpriteBatch class like this:

public static void Draw(this SpriteBatch spriteBatch, Sprite sprite)
{            
        spriteBatch.Draw(sprite.Texture, sprite.Position, sprite.SourceRectangle, 
             sprite.Color, sprite.Rotation, sprite.OriginPoint.ToVector2(), 
             sprite.Scale, sprite.Effect, sprite.Depth);
}

public static Vector2 ToVector2(this Point point)
{
        return new Vector2(point.X, point.Y);
}

Using the sprite class is simple. First create a sprite in the LoadContent method.

var texture = Content.Load<Texture2D>("splat");
_sprite = new Sprite(texture)
{
        Origin = new Vector2(0.5f, 0.5f),
        Position = new Vector2(100, 100)
};

Then render the sprite with the SpriteBatch extension method.

_spriteBatch.Begin();
_spriteBatch.Draw(sprite);
_spriteBatch.End();

Gadget Craft

I’m pretty passionate about this game idea! It’s been a while since I’ve had a game idea that I feel so strongly about. Scratch that, I’ve *never* had an idea that excites me like this one. I am going to finish this game. I *have* to finish this game. It’s the game I’ve always wanted to play, it produces feelings at my core that just can’t be ignored. But I need your help.

I’ve been making games since I was a teenager. Many of them never reached completion, some of them where far too big for one man, some just didn’t keep me interested for long enough. In recent times, I have got a lot better at finishing games and a couple have made it to Google Play. They prove that I can do it, but they aren’t very spectacular. I know I can do better, and from this moment forward I’m going to use everything I’ve learned to make games I’m proud of.

I recently read the Gunpoint Development Breakdown by Tom Francis and I found it very inspiring. Particularly the way he created regular releases of the game for community testing and the open submission process to find artists. He’s also far better than I at blogging and promotional stuff so I hope I can learn a few things by following his lead this year. Thanks Tom, Gunpoint is awesome btw! :)

the prototype

My game is about crafting gadgets. Actually it’s more of a toy than a game at the moment, but I really like the game mechanics. The player has lots of little parts that can be connected together in various combinations to craft a gadget. After each gadget is crafted new parts are unlocked allowing for more interesting gadgets to be crafted.

So far I’ve got the inventory and crafting board implemented. A couple of parts are working including a battery, wire and a light bulb. Next on the list are some buttons and switches followed by timers.

As a programmer I’m going to enjoy implementing all of the parts. I’ve got lots of ideas for what kinds of parts to add to the game, and I think there’s loads of potential for many more. The programmer in me is also the reason the game appeals to me as a player, it’s about creating things in a similar way to programming software. Although, far less complicated and hopefully more fun for non-programmers.

I need your help turning this toy into a game though. While sandbox mode can be a lot of fun, it would be nice to have some goals. It could be about crafting a particular type of gadget on each level, and/or selling them on a virtual market. Maybe they lead up to a bigger goal or are somehow part of a bigger game. I’m really not sure about this part yet. Any ideas are welcome.

MouseUp, MouseDown and MouseMove events with MonoGame

Sometimes when developing code with MonoGame or XNA it’s easier to deal with mouse or touch input using MouseUp, MouseDown and MouseMove events rather than dealing directly with the MouseState in each update loop. Although this code is relatively easy to implement by comparing the previous mouse state with the current one, the code can often get messy and prone to bugs. It’s nice to be able to encapsulate this code into a reusable class (and as an added bonus, make it unit testable).

First up, we are going to define the inputs and outputs of the class. In this case, we want to read the mouse state as input and fire MouseUp, MouseDown and MouseMove events as output.

    public interface IGetMouseState
    {
        MouseState MouseState { get; }
    }

    public delegate void MouseStateEventHandler(MouseState mouseState);

If you’re wondering why we supply the class with an interface to read the mouse state instead of reading it directly from the Mouse.GetState() method there are 2 reasons. First, this class is not going to be the only one to require the current mouse state so it’s more optimised to hand this responsibility off to something else and only call Mouse.GetState() once per update. Second, by passing an interface into the constructor we have made the class unit testable.

Next we can implement our MouseListener class like so:

    public class MouseListener
    {
        public MouseListener(IGetMouseState mouse)
        {
            _mouse = mouse;
        }

        public event MouseStateEventHandler MouseUp;
        public event MouseStateEventHandler MouseDown;
        public event MouseStateEventHandler MouseMove;

        private IGetMouseState _mouse;
        private bool _isMouseDown = false;
        private MouseState _previousMouseState;

        private void RaiseEvent(MouseStateEventHandler eventHandler, 
            MouseState mouseState)
        {
            if (eventHandler != null)
                eventHandler(mouseState);
        }

        public void Update()
        {
            var mouseState = _mouse.MouseState;

            if (mouseState.LeftButton == ButtonState.Pressed 
                || mouseState.RightButton == ButtonState.Pressed)
            {
                if (!_isMouseDown)
                {
                    _isMouseDown = true;
                    RaiseEvent(MouseDown, mouseState);
                }
            }
            else
            {
                if (_isMouseDown)
                {
                    _isMouseDown = false;
                    RaiseEvent(MouseUp, mouseState);
                }
            }

            if (_previousMouseState.X != mouseState.X 
                && _previousMouseState.Y != mouseState.Y)
            {
                RaiseEvent(MouseMove, mouseState);
            }

            _previousMouseState = mouseState;
        }
    }

The important thing to note here is that the class has 3 public events similar to what you’ve probably used in WinForms or WPF code, and a public Update method. To use the class, you’ll want to create an instance of the class during initialization, have some other class implement the IGetMouseState interface, subscribe to the desired event handlers and call the Update method somewhere inside the game’s Update loop.

There are lots of different ways you could use this class deep inside your code, but the simplest example is to use it directly from the main Game class. Here’s a cut down version of the relevant bits.

        // first, have your Game class implement the IGetMouseState interface
        public MouseState MouseState
        {
            get
            {
                return Mouse.GetState();
            }
        }

        private MouseListener _mouseListener;

        protected override void Initialize()
        {
            base.Initialize();

            // then create an instance of the mouse listener and subscribe to events
            _mouseListener = new MouseListener(this);
            _mouseListener.MouseDown += MouseListener_MouseDown;
        }

        private void MouseListener_MouseDown(MouseState mouseState)
        {
            // do stuff
        }

        protected override void Update(GameTime gameTime)
        {
           // ...
           // last, call the update method
            _mouseListener.Update();
            base.Update(gameTime);
        }

And that’s it.

Let me know in the comments if you like this kind of tutorial because I will do more if there is enough interest. For the next tutorial, I’ll do a similar reusable class for Drag and Drop operations.