Using Midjourney for creating 2d game assets
Tags: gamedev, ai, midjourney
Published: 2023-09-09 11:26:46

I started game development almost 20 years ago and have published few titles on itch.io, with many more in the bank. The main reason for that is that I lost interest in many of them due to the lack of visual aesthetics. It really motivates me when I see an idea come to life. However, I couldn't draw anything pleasing even if my life depended on it. With the uprising of generative AI in general and Midjourney in particular, I wanted to try it out for myself and see if I could use this as my designer/art director for my future game development projects.

{% spoiler tl;dr %} Midjourney produces amazing results but struggles with some basic asset types (i.e. buttons). Prompt engineering is key. Will use it again in future games. If you want to see the results for yourself, checkout: [itch.io](https://dasheck.itch.io/fantasy-matching-card-game) {% endspoiler %}

## Setup
I wanted to create a simple game so I wouldn't risk dropping it because of complexity or the fact that it takes weeks to complete. This is about asset creation, not game development in general. Also, I used phaserJS for this because it handles a lot of the complexity in creating games (e.g. rendering, animations, ...).

So I decided to use a simple card matching game, often called Memory. You see a set of cards, all face down. Your task is to choose two cards. If they match, you get a point and the cards are removed from the game. If they don't match, the cards are turned face down again and it's your opponent's turn. The opponent is a simple agent who follows some rules that are not relevant to the experiment.

The goal of this experiment was to create 

- a visually appealing background
- a cool looking set of cards (including back cover)
- a button image

I wanted a fantasy-style game, similar to Bastion or Rayman Legends.

## Process
Before I started the midjourney part, I created a few simple assets to work with so I had the game ready before I started creating the actual production assets. This is something I never considered doing before, but found very helpful and will continue to do in the future. Here are the assets I came up with:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9005rjrv5avkqfvyo8z.png)

So the game would basically look like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mq2i9et7g98ykzb77b69.png)

Normally, that would have been it, except for trying to find some free assets from the internet that usually wouldn't work. Now for the midjourney part.

## Midjourney
Midjourney is a generative AI that can generate images. You provide a prompt of what you want to see, and 30 seconds later Midjourney shows you 4 results to choose from. From there you can upscale, regenerate or enhance them to your liking.

### Back cover
First, I wanted to get an idea of how this game could look like. So I started with a simple prompt like

```
2d matching card game, concept art, mobile game, bastion style
```

which produced amongst others the following image, that I eventually went with:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztsevvxmzallzcalayly.png)

I used the style for the rest of the generation and even took one of the card designs as a back cover. Post-processing the images consisted of either removing the background with another AI tool or rearranging the images with Figma. In this particular case, I traced the inner part of the back cover to get a shape that I could use as a mask for the actual memory tiles. Here is an example (from left to right: back cover, mask, example tile):

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gcctkv9fdzz55kzgw4b.png)

This worked pretty well and was done pretty quickly. So I had a template and just needed actual images to mask and rearrange so I could export the resulting layers as a single image.

### Memory tiles
This was not as easy as I had hoped. Since I wanted a fantasy setting, all my prompts went something like this: `fantasy [object], bastion style`. Naturally, I experimented with different "objects" like heroes, monsters, buildings, castles, and so on. This was quite good, but eventually led to a problem: I could no longer win. In this game, it's extremely hard to remember complex shapes and similar images, at least for me. I developed an agent that memorised the revealed tiles and their position. The tiles were identified by their id. The actual picture did not matter to the agent. So it was much easier for him to find matching pairs than for me. And this was ultimately related to the way I used Midjourney. Here is an example of a prompt and the final cards I created from the 4 images generated:

```
fantasy action scene, bastion style
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qk5ac8hlfqs6ybbegls.png)

When you reveal a card, you get to see it for 1 second before it is concealed again. That's not nearly enough time to memorise these complex shapes, especially when they're so similar. To minimise this, I had to use different themes, subjects, and settings when creating the images. Here are some of the examples I ended up using for the game. Note that sometimes I had to regenerate them to make them more distinct to the ones I already had:

```
fantasy magician, bastion style 
fantasy battle horse, bastion style
fantasy rpg hero group fighting monsters, bastion style
fantasy well, bastion style
fantasy crystal, bastion style
fantasy waterfall, bastion style --no building people house castle
fantasy ogre, bastion style
```

There were many more requests to Midjourney to count against my quota. So I tried to reuse as much as possible of the 4 images I generated. Especially more complex scenes like "fantasy rpg hero group fighting monsters" produced a lot of cards because they had several different distinct scenes within one image. Here are all the tiles that made it into the game:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ed2mzw6f1shqpvthuksu.png)

### Remaining assets and the final game
The remaining assets were the background and a button graphic. The background was quite simple

```
unobstrusive fantasy game background, only nature, bastion style -- no building people monster hero
```

which was then blurred. It was important to include the `--no` directive to the prompt, as I didn`t want to draw too much attention away from the actual memory tiles.

For the button graphic, I simply created a few mockups and then removed the background using another AI tool. This was harder than I thought it would be, and I wasn't as happy with it as I would have liked. So the buttons could still be a little tricky. Here's what the finished game looks like:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x6ez25u2y6cpxzamk6w6.png)

If you want, you can play it on [itch.io] (https://dasheck.itch.io/fantasy-matching-card-game). Keep in mind that this is just an experiment to see if Midjourney is suitable as a tool for creating game assets. So don't expect too much fun while playing.

## Conclusion
I had really high expectations before running this experiment, and most of them were met. I went for an art style that is hard for many to pull off, let alone me. I'm happy with the results (except for the button graphic). Not only that, I was able to do it all in one sitting and used 6.87% of my monthly quota (while still experimenting). All in all, I consider this a success and I will most definitely use it in future games.

Counterintuitively it is harder for Midjourney to create basic shapes like buttons (or even text). As I've didn't go into that direction it is hard for me to tell, whether Midjourney is able to help here. This could be part of another experiment.

Also keep in mind that I'm not an expert at creating prompts for Midjourney. So it would be easier if I knew how to word this properly. If you have feedback on this, please let me know.

## Feedback
I would love to hear your experience with Midjourney. Have you used it in the past. And if so, would you like to share your results (e.g. images, assets, prompts, insights). If not, do you plan to use it?