As 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!
Here’s a little C function. It’s not exactly intuitive what it does and I’ve renamed it to prevent giving it away.
float mystery( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y;
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) );
return y;
}
If it helps, this line is really the heart of it.
i = 0x5f3759df - ( i >> 1 );
Mystified? Well it’s a fast inverse square root. No one really knows who wrote it though John Carnack of Quake and Doom fame popularised it. There’s an interesting discussion about the author but no one really knows.
There’s less need for this type of thing nowadays because of all the fast silicon but back 20-25 years ago when graphics processors were in their very infancy, it was a highly useful optimization. Mind you , you’d need to know assembly language inside out to come up with stuff like this.
If 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)
The internet archive (yes them again!) not only has archives of most things I’ve done, but they also have an archive of 7000 games from the Dos era that you can play in your browser. You don’t have to install anything, just click on it and it installs the DosBox emulator for the browser and runs it.
Thankfully they have provided a filter so you can search . Looking through the first page I spotted Rogue and Warlords II, two of my old favourites. The screenshot is me after just having bumped of an Emu. That white square in a corridor between the bottom two rooms.
The collection has loads of all classics; it’s a very nice bit of work. Games from this era (very roughly the 90s) tended to be 2D. It wasn’t until the mid 90s that 3D games like Quake and Doom appeared.
I did a search for Empire in the text box and it found Empire Deluxe (a game I have and occasionally play 27 years after I bought it) plus a load of other games like Master of Orion.
Back in the day I worked as a game designer for MicroProse (yes the Civilization people) from 1992-1993 and though I never met Sid Meier, i did cross swords (metaphorically) with the other cofounder Wild Bill Stealey at a company BBQ (in the UK) by er failing to catch a baseball.
Games back then still came on floppy disk. Installing a game from 18 disks was not a fun task….
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.
This is a 4x game (Explore, Expand, Exploit, Exterminate) . “Select from one of seven races – or craft your own – to explore dozens, hundreds, or even thousands of systems in a galaxy of your choosing. Expand across unique and varied planets and ultimately exterminate – or subjugate – any who stand in your way either in offline single player or up to 28 player multiplayer.” as gog.com put it.
But as well as being available on Gog.com or Steam, it’s also open source but that doesn’t include the music from the game. So you can pay for the game on Gog.com/Steam or download the open source version and build it yourself.
The GitHub website contains the full source code needed to build Star Ruler 2, and all secondary scripts, data files and assets required to run it. It’s 45% C and 22.5% C++ according to GitHub with a sprinkling of Flash (arr ar- saviour of the Universe- er sorry).
In my previous post, stage 1 of creating a RPG was “A Dungeon level generator. Create rooms and link them by corridors.“. Being quite retentive, I dug out my source code from the Quest dungeon generator. It was written in Turbo Pascal back in 1989-1990 and is about 1200 lines long.
The principle was slap down a few random sized rooms (both rectangular and circular in the original) then draw corridors from fixed points in the rooms with up to eight points in a room. Something like the map shown from Paratime Design.
You can go to town in the number of ways of generating a dungeon. When I was 16 i once spent a couple of weeks of my summer off-school time drawing a dungeon on an A2 piece of paper. It had something like 2000 rooms which is quite insane. I wished I’d kept it now; my magnum opus!
Another way I’d considered is draw a grid on the area. My original dungeon area was 150 x 150 points in size. Mind you Turbo Pascal was 16-bit software and no data structure could be bigger than 65536 bytes so the limit would have been 256 x 256. If you draw a grid say at 8 x 8 intervals then when you put a rectangular room down the intersection with the grid provides door points. My original rooms were either small (6-18) or large (10-40) points.
Once the rooms were in place, corridors were drawn until all rooms were linkable. Corridors were drawn out from a door point until they hit another corridor or door point. By building up a list of rooms connected to other rooms, and removing duplicate corridors (rooms directly linked to another room more than once), a minimum dungeon level was built.
After that traps, treasures and monsters were added and an entry point in and out of each level to the one above or below. If you are feeling fancy then you can add a special room or two on each level such as temples, arenas and such like.
If you are short of imagination you could buy the D&D Dungeon Master’s Guide 5th Edition. Appendix A has a very comprehensive guide to creating a random dungeon and stocking it with traps, obstacles, furnishings and monsters.
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.
A Dungeon level generator. Create rooms and link them by corridors.
Generate a bunch of levels – link them via randomly stairs, pits, transporters.
Add random monsters and treasures in rooms.
Implement a moving player able to navigate through the levels.
Add combat. Weapons, range weapons, spell casting. Add monster hit points.
Turn it into a polished game. Add everything else needed. Permadeath, collecting treasures. Moving monsters.
(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.
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.
Most days I scan the web for relevant or interesting stuff and today I found a real treasure. A website where they have curated a list of C and C++ single file libraries. That is libraries that are not multiple files but mostly one. I say mostly because there are a few with 2 or 3 files.
The bulk are in C++ but there are a large number of C/C++ and quite a number of C. All have their licensing; these are open source but licences vary a bit.
It’s worth a trawl through the List. For instance there’s an interpreter for a BASIC dialect scripting language,
Once you ‘get’ pointers they are very easy to use. I think I always got them easily because long ago I used to do game programming in assembly language. When you are accessing blocks of ram indirectly through registers in assembly, then the concept of a pointer in C/C++ comes fairly naturally.
But really, all a pointer is, is a variable that holds an address. That address can be one of several things. It could be to a string of characters, an int or float variable, a struct, an array. In fact it can be anything that can exist in memory.
There are some limitations. It’s not good practice to use a pointer to access the underlying binary of your program, assuming that you can locate it. Plus chances are that code will be in memory that you cannot write to. Data however will let you write to it and pointers make your program far more flexible than without.