Wednesday, 6 July 2016

Getting it rolling - what a load of BFS!

I'm back.  This time I want to post up a little about my exploration into building a prototype 'proof of concept' for my game I'm simply dubbing 'myCade' (Working title) for now.

More about the game concept

The game centers around an arcade (hence the working title).  Unlike my inspiration, this time the goal is not to stock up the machines with coins and collect them back, but instead let incoming characters play the games and stock the machines up with their hard-earned pocket money.  As the player, you then collect the cash and store it in your safe.  The goal here is to collect coins and move on to the next level (well, at a basic level) once you reach a certain amount

Obviously there are other game play features involved, but that's the general gist of it.  I have a fairly hefty document and design plan I sketched out that covers things in more detail that I may post up at a later date (once I see if there are any details I've left out, and test that things are actually working in terms of game play).

Getting the ball rolling...

I figured I'd make a start on some coding...  In the past, the best thing for motivation when writing code for a game is to at least see something happening...  Even if its a bit at a time.  This initial start was to purely get some characters running around an arcade to empty machines - or in this case, target points.


Of course, I also needed some generic graphics.  As this is purely a proof of concept and not a final project, I don't need anything complex for testing...  But also not too crappy looking either.  I decided on 64x64 sprites so at least it looked decent on a high resolution screen.  Four arcade machine graphics (representing machines that face left, right, up and down) and a single character.  The character was actually drawn by my brother back in the 80's on a ZX Spectrum - he is also a pretty creative guy, so there were always cool ideas for other games from his artistic designs.  I may drag him in at some stage and see what we can put together in the future for other games.

When I resized the characters, they did look a little less appealing in that the pixels didn't retain their clean shape, but I figured it does what it needs to at this early stage of testing.  I can make prettier graphics later of course! :)

Quick-n-dirty test sprites

The game play field.

As you'd expect with games like this, the design centers around a tile-based map.  The map contains clear areas for walking, and machines (which come in 4 orientations) that each character will stop at and play.  The characters in the arcade enter and then travel to a target (one of the free machines).  This initial test code uses random locations just to test the travel algorithms and make sure all the game characters would move as expected.  After this is all working, the game code will make sure that a character will choose a free machine as its target.

I first tried to code the movement of the characters to use an approach I'd tested in a simple Pacman-style game I wrote for fun a while back to help me learn how to use Pygame,  My version of Pacman featured purely random motion of ghosts rather then the usual target-based system that the original used, but it worked and it was fun to play.


I used the same concept initially for my character movement in this game, using a constant linear direction movement and checking for exits in the arcade 'maze' that were opposite to the initial motion (if vertical, see if we could move horizontally and change if we needed to reach the goal).

This proved problematic.  I found that I ran into some situations where characters would get locked into corners, or even walk out of the arcade and game window.  I ran through my code, and while I could have eventually found where things failed I decided I was spending too much time with it.  Plus there were issues that affected the feel of the game play, making the motion of the characters look a little 'misguided' and unintelligent...

Fyi - if you want to download the pacman game code, its included with some other retro code (old 1k ZX81 games recreated in Python).  Click here for a direct link to the source code on my google drive, or click that previous link to watch me fumble my way through a presentation I gave on the retro gaming project I'd been doing.

What a load of BFS!

I instead opted for a path search system.  The character would be given a target location to reach, and then would calculate its path as a sequence of directional movements.  While the game loop ran, each tile the character entered would then check for the next direction to move and set the characters motion as expected.

The search algorithm I ended up using was a Breadth-first seach (or BFS for short).  This is a fairly well documented algorithm, finds the shortest route (and gives our characters less of a random appearance when moving) and benefited from not requiring any use of recursion, making my code less of a mental strain on my brain cells (and at my age, I need to retain as many as possible - lol!)

Bonus is that bfs only takes 7 lines of Python code to implement - short, sweet and clean!

It may not be the fastest (I'll look at other options at a later date, such as A*, etc) but for this proof of concept, and the fact I'm working in a small map (once I converted the tiles to a graph structure, the amount of data became even smaller) it worked great with literally no visible impact on game speed.

Arcade time!

Because the path is pre-calculated, the nice thing here is that I know a character reached the goal when the end of the path is met.  I found I could take advantage of this path to easily control whether the character traveled onto a target, or could finish at the correct location one tile away (ie. say I wanted to make a character reach the arcade machine rather then land on top of it (ie. prevent it walking onto the machine graphic)).

The pacman-approach used a 'target tile reached' test, and calculating the direction the character was moving, the tile location and testing for the machine being in direct line takes more code and was not as clean a solution as simply ending at a path's second-to-last position.

So, at this stage I've got things moving in the arcade.  This is perhaps the main thing needed in the game - getting the game characters moving and reaching their goal.  With only a few simple tests and some data management needed to get the game up and running, I feel that this project may come together a lot quicker then expected (well, I hope so - but famous last words and don't count your chickens until they hatch as the sayings go!)

Until next update...
Share:

Wednesday, 13 April 2016

The first post!

Well, I had to start somewhere!

Welcome to my Arcadia blog.  At the time of this post, the theme I installed is still untouched, so if you've ended up here and wondered what all those crazy default menus are about...  Sorry, I'll get on to those asap!  (Mind you, by the time you read this its likely I will have updated a few things)

Arcadia is a space where I want to share some of my own personal tips, thoughts and historical memories about a little of everything related to (mostly retro) gaming development.  That may be snippets of old-school programming mentality, or it may be a look back at a classic game from my past, or links to interesting articles.

As well as that, its also a space for documenting the process and production as I work my way through the development of my own personal gaming projects. Right now, I'm developing (proof-of-concepting at least) a game - a sort of arcade arcade game (double-arcade...  now that sounds like double the fun! lol!).

For now I'll refer it as 'myCade' (not a final title, but I have to give it something, right?)

"myCade" - Ancient Influences

My main inspiration for this game (once I start blogging about it) was an old Apple ][ game called Spare Change, released by Broderbund Software back in 1983.

Nothing says more retro then classic green screen!

In the game, you filled up machines with tokens, and then would collect them back out of the machines...  There were two characters (Zerks) in the arcade who would run around and steal the tokens and place them into a piggy bank.

Your goal was to collect the tokens to get to the next level.  Of course, as you collected tokens, the machines would run out and you'd have to refill them.  If the other characters managed to fill their piggy bank, the game was over.  You could distract them for a short while by placing a token into a phone (one of them would pick up the phone and have a conversation), jukebox (they'd go and dance about) and later a popcorn machine.

You would eventually collect all the tokens from machines, and need to go to the till to collect more to load up the machines.  Problem is, the till only has a finite amount of tokens in the till, and you would occasionally need to go to the safe to fill up the till again.

There was only so many tokens that the machines would take before they were out of service.  When that happens, you'd lose the tokens you placed in and its one less machine that is active.

When you think about it, it does seem a somewhat odd game idea, but the cartoon antics of the Zerks (you'd get to see a variety of different Zerk Show's - short animated sequences - as you completed levels), plus the challenge of collecting as many tokens as you could before they bet you was quite addictive.  You know its a good game if the memories of it stick with you for 35+ years.

No - I'm not out to create a modern version of the game, just one inspired by its arcade theme.

myCade as I've mentioned is just a working title for now.  I'll post up more about the actual game in a later post once I get something completed and ready to talk about. For now, I'll just keep it under wraps (ahem, well, until I actually have something to show ;-) )

The Nerd factor...

My goal at this stage is to prototype using Python and pygame.  I'm a pretty old-school programmer - my roots set in the 80's where you invented and wrote your own games - before the booming industry it is today.  It was a different world back then, and I like the feeling of just coding the whole thing from scratch rather then use a game development tool that takes away the nerdy fun.

Well, that and to be honest I just love toying in Python for my 3D work as well as punching out the odd retro game just for kicks...  Though I will eventually take that prototype across to a more mobile platform. No escaping the modern world forever...

As mentioned, Arcadia is also a space where I will post up some snippets and tips - there's definitely a few things as I code that I'm sure may be of interest to others...

Anyway, enough waffle for now.  My day job as a 3D animation and VFX tutor has picked up again (a whole new class for the year) so life will be busier which may make this a slow blog, but lets see where the year takes us.  Until the next post...
Share:
Powered by Blogger.

Recent Posts