Category: Ideas

A different way of generating a dungeon level

A different way of generating a dungeon level

Dungeon
Image by Artie_Navarre from Pixabay

I talked previously on how I generated dungeon levels by splatting down squares and circles of random sizes and then linked them together by corridors.

But another way that might make levels look not quite so procedurally generated is to first compile a catalogue of dungeon rooms.  These are “hand drawn” in a master text file, perhaps something like this:

*****|****
*        *
=        *
*        =
*        *
*****|****

Where * marks the walls,| a possible location of a vertical running corridor and = the same for horizontal running corridor. Each entry in the catalogue has a size (vertical, horizontal) e.g. (6, 11) for the room above and the generator program has to find space for this and then see which of the four doors it can connect to.

You can decide if you want a dead end room or one with more doorways. Any unused doorways are just replaced with a * for wall. Single door rooms might have a secret door that the player has to first discover and unlock/open.

When the generator starts, it reads in the master file, builds a list of rooms and then starts using them to generate levels.

The advantage of the catalogue method is that you are free to create as many room sizes and shapes as you wish and they don’t have to be rectangular or square. Yes the level is procedurally generated but using this methods makes it look less so. You can have very small rooms (2 x 2 anyone?)  or massive hallways with lots of columns.

An interesting game system – Fiasco

An interesting game system – Fiasco

Fiascao game coverAs well as games programming, I like game design and one of the best ways to practise this arcane art is to look at other people’s ideas and borrow/pinch/steal/be inspired by them.

The image is here is from a game Fiasco by a designer called Jason Morningstar of bullypulpitgames.com. It’s such a different game (they call it a weird game)  and you can see what it’s about on their Fiasco page as well as look at the various downloads.

Why I like it is because it gives you a flavour of tv shows with complex plot lines like Fargo. There are several ‘players’ involved and you’re never quite sure how things are going to turn out; there’s not what you would call a hero. You don’t get that in many computer games so anything that can advance the art is very welcome.

OF course turning it into a computer game would present some challenges. But I’d play it!

 

So much fun from 16 x 16-tixy.land

So much fun from 16 x 16-tixy.land

tixy.landIf you are looking for inspiration for games creation, take a look at tixy.land. It’s a 16 x 16 square of dots whose colour is determined by a user entered JavaScript function. If you click the page, you’ll see new patterns. This was created by a developer Martin Kleppe and you can see other examples in this twitter thread..

The function is limited to 32 characters but even so that gives you a lot of possibilities. Most patterns are dynamic, changing as you watch. It’s quite fascinating.  The pattern shown in the screen shot is from Math.tan(t*(100-y*x)/9). and the actual url (including the code is)

https://tixy.land/?code=Math.tan%28t*%28100-y*x%29%2F9%29

The %28 etc are the HTML encoding of (, while %29 is ) and %2f is /.

You can edit any function on the page so try substituting sin, cos instead of tan. Also abs works as well.

A collection of app ideas

A collection of app ideas

Collections
Image by pencil parker from Pixabay

Now this isn’t a bad thing. On GitHub, someone has built a collection of ideas if you are looking to develop something to further your skills. There always seems top be something about November as a month to do things, whether it’s growing a moustache (“Movember), Writing a 50,000 word novel (NaNoWriMo) or this.

These are in three tiers with 35 Tier 1 “Developers in the early stages of their learning journey. Those who are typically focused on creating user-facing applications.”,  the same number at Tier 2 “Developers at an intermediate stage of learning and experience. They are comfortable in UI/UX, using development tools, and building apps that use API services.” and 20 at Tier 3. “Developers who have all of the above, and are learning more advanced techniques like implementing backend applications and database services.”

If you finish all those, you’ll have done 90 projects. The last 20 of course being the most complex and including such things as a Discord Bot that plays Battleships, an Elevator simulator, a fats food restaurant simulator and the like. There’s no platform or programming language specified.

I’ve seen elevator simulators done before. Single elevator or multiple ones and for varying numbers of storeys.  Optimising the algorithm to minimise the waiting time is interesting and not always obvious. Do you have elevators wait wat floors when not in use or do they sit on the ground floor.

The author of this Florin pop has also completed 100 projects in 100 days if you fancy a challenge.

How to implement a Roguelike

How to implement a Roguelike

Roguelike dungeon
From Wikimedia

A roguelike is a character based fantasy game. By character I mean @^! not an individual as such! A question on the C SubReddit had asked about Project ideas for simple applications and someone had suggested a Roguelike. It’s not a bad idea but probably quite a bit more than just a simple project.

So I suggested breaking it down into stages. Here’s what I said.

Rather than a roguelike in one go (that’s a actually quite a bit of code) so do it in these stages.

  1. A Dungeon level generator. Create rooms and link them by corridors.

  2. Generate a bunch of levels – link them via randomly stairs, pits, transporters.

  3. Add random monsters and treasures in rooms.

  4. Implement a moving player able to navigate through the levels.

  5. Add combat. Weapons, range weapons, spell casting. Add monster hit points.

  6. Turn it into a polished game. Add everything else needed. Permadeath, collecting treasures. Moving monsters.

  7. (Optional) Make it multiplayer and allow PvP.

PvP means allow Player v Player combat. Doing it multiplayer is actually quite a lot of work which is why I made it an option. Rogues are often created using simple ASCII chars for monsters and treasures. Some programmers have used graphics and there are plenty of free graphics sets for 8 x 8 or 16 x 16 pixel sized monsters etc. like the Kenney.nl microrogue set. Shown in action below.

Kenney.nl micro rogue set in action

I am tempted to make this the 3rd game idea for the Raspi game book. 30 years ago I created a multiplayer postal game Quest that is still running albeit on the web not by post. That included a dungeon generator. It wasn’t in C but it’s easy enough to translate Turbo Pascal to C.

Ingenious games in just 13KB of JavaScript

Ingenious games in just 13KB of JavaScript

Last Spartan screenshotI’m not fond of JavaScript but I am still in awe at the ingenuity of people who created a HTML5 game in JavaScript in just 13KB. There’s an annual competition called Js13K and this year there were 220 entries and prizes of $20,000 in total.

When you think that many graphics are way bigger than 13KB this is even more of an accomplishment. It means those games have to mostly draw their own. graphics rather than use prerendered graphical images. It helps that HTML5 includes a canvas drawing area and instructions in JavaScript to draw into it.

The GitHub Blog featured the top ten from this years competition. The picture comes from The Last Spartan which I really liked. Ironically the screen grab image was 121KB, almost eight x the size of the actual game!

If you are ever stuck for ideas for games, take a look at these. Being JavaScript, you can right-click in your browser and View Source (Chrome) or View Page Source (Firefox). Of course, to achieve 13KB, many of them have been minified which means getting rid of all spaces, carriage returns and renders it rather unreadable. This is what it looks like.

Screenshot of last Spartan source code

However the internet taketh and the internet giveth. If you paste this (or any of the source listings) into an online deminifier (aka beautifier) such as beautifier.io then you get all 1622 lines laid out in immaculately indented glory.  It’s actually 73KB in size as a normal listing and still very impressive.

There’s no reason why games can’t be done this way i.e. drawing graphics in C+SDL2 though I doubt I’d get them down to 13KB. My asteroids game which was 2200 lines of C generates a 96 KB exe. But when you add in images, SDL code and sounds etc it comes out at just under 35 MB.

Why C and not C++?

Why C and not C++?

C++ LogoConfession, I can program in C++ though I’m a bit rusty and my C++ knowledge stops short of creating template classes but I can use them.  But given that probably most games these days are programmed in C++ why is this site about C?

Well it’s been mostly personal preference. I like C; it is a heck of a lot simpler than C++ (understatement!) and compilations are very fast! I know most of C though to my chagrin I admit I got include guards wrong for quite a while. I was using them in .c files rather than .h.

Plus, I haven’t really looked into WebAssembly enough. I know it will work with both C and C++. But it has to be said that there is probably only so much you can write about C, so I will be including C++ in the future. I’d planned to do a C++ conversion of my Ebook(s).

Besides which if you google for something involving C, you’d be amazed how many C++ and even C# websites are in the results!

 

 

SSSnakes – a game for the next Ebook

SSSnakes – a game for the next Ebook

Screenshot of snake gameI’ve done a snake game in the past for About. That’s the picture and today I’ve uploaded it complete with source to Github. The thing with snake is, everyone knows it, its old hat and not particularly exciting.

Back in the early 80s the same was true about Breakout games. It was a common trope for game programming, bouncing a ball off a bat to break through a wall.

But then in 1987 along came the Arkanoid game which could be best described as Breakout re-imagined.  More balls, special bricks when when hit gave different features. It made Breakout games cool again for a few years.

So Ssnakes, is my name for a re-imagined snake game.  We’ll throw away losing your life when the snake hits a wall or itself. Only if your snake runs out of space is it dead, or if it is killed by an enemy. And as it travels around it picks up food which gives it energy. You can burn this energy is making it longer, moving faster or .. spawn off a new snake! Also you can attack enemy snakes – spitting venom directly ahead or sinking fangs into an enemy body if  your snake’s head is next to it.

Having 2, 3 or 4 snakes on the go will make it a bit more stressful to control. You only lose a life when you only have one snake left in play and you lose it.

Plus instead of a plain empty arena there will be a few static objects in it.

 

My next Book – Match three

My next Book – Match three

I’ve been thinking about doing a 3rd book – something like ‘More C Games, design and programming’ which would have three games, each with a design and then implemented with explanations and bits of source code and all on Github.  The first game is possibly going to be a Match Three game.

Match tree gameMatch Three games have been around for the best part of a decade and have a basic mechanic of swapping two adjacent pieces to make a line up of three, four or five pieces which get removed.

What makes it more challenging and interesting is the almost limitless number of mechanisms you can build on. For instance when you clear four or five you get special items that when swapped with another special item do something interesting. Or could be you have to get a set of special items and so on.

Or you might have special levels where you have to clear all of one particular shape within a time or Boss levels where the baddy is continually adding hard to remove pieces that clog up the game, or you might have a rotate button that flips the board 90 degrees so you can get rid of hard to remove pieces by having them drop into special buckets beneath the board.

Now I just have to come up with two more games. Suggestions welcomed!