Category: Game

Onslaught (aka Slay on Linux) tutorial two published

Onslaught (aka Slay on Linux) tutorial two published

Onslaught linux hexagons screenI’m quite pleased with this. It took about six hours in total to create including the time to create the graphics. Running in Hyper-V under Ubuntu 20.04, it draws a screenful of graphics in about 65 microseconds.

I took the hexagon drawing code from the AboutEmpire.zip code on GitHub and modernised it for SDL2. The Empire code uses Surfaces from SDL1 while this uses Textures from SDL2.

Orange hexagon Blue hexagon There are nine hexagons with all but the dark one having an internal border.

I think the orange and salmon hex look a bit too close, so I’ll change one of them.

The tutorial goes into a bit more depth. about the program (which is just over 200 lines long) and can be found on GitHub in the file Onslaught1.zip.

Interesting article on the state of Linux gaming

Interesting article on the state of Linux gaming

Linux playYes it’s on Medium, but its worth a read. The gist of the article and this one is saying that there’s a problem with Linux for gaming. Also that anyone new to Linux gaming is looking online and finding old articles that suggests that SteamOS is a good distro to use while in reality it hasn’t been updated in a while.  The problem is that Valve (creators of Steam) have let SteamOS languish.

Though its not as if Valve have ignored Linux gaming. They released an open source tool Steam Proton (Link goes to it on GitHub) that lets you run many Windows games (6000 or so)  on Linux. The Linux Steam client includes a copy of Proton.

The problem though is that this hasn’t really helped attract more people to Linux gaming. People I know either play games on Windows or on consoles like PlayStations.  Linux is perceived, wrongly I’m sure as being an inferior game platform.

New Tutorial – Implementing the Windows game Slay

New Tutorial – Implementing the Windows game Slay

Slay gameOne of my favourite casual games is Slay by Sean O’Connor. I bought the full game which sells for $10 and it’s still selling well via his site or Steam. His game is only for Windows so my reimagining (great word!) will be for Linux only including Raspberry Pi.

His game comes with several hundred islands, in four sizes from very small, small, Large and very large. You play against 6 computer players with intelligence ranging from very stupid, stupid, clever to very clever. In addition there are a bunch of predefined maps like Britain or even the world.

Troops exist in four sizes with each size three times bigger than the one below. Your territory must be big enough to support the troops there and if it isn’t they all starve.  Splitting an enemies’ territory to starve his troops is a valid tactic.

Add in with trees which can spread and waste land which spreads even faster and its a cute addictive game.

My game will be called Onslaught and use its own graphics. Islands will be computer generated and hopefully the AI will play a decent game. The first tutorial which just explains the game and the scope of what I intend to do is now available.

 

 

Atoms tutorial three- finishing the game off

Atoms tutorial three- finishing the game off

Atoms 3 screenshotI fixed the bug in the Atoms game and the third tutorial finishes it off. The source code (in this case atoms3.c) has been placed on GitHub and the final version is about 300 lines long.

As well as the bug fix, I added a line to show the number of cells owned by the player and the computer. You can see it after the player move (Player : 41 Computer 16) and after the Computer move.

This whole atoms game was an experiment to see if I can introduce C programming without having to go overboard explaining every statement etc as I’ve done in the past. I think I’ll get back to programming games!

 

Tronus Project 1945 – Coursework

Tronus Project 1945 – Coursework

Project 1945A university student by the pen name of Tronus has put a project from his 3rd year in his degree course on GitHub. The screenshot shows the game running on my PC. The build folder includes a release folder with game exe plus all dlls and game assets in a resources folder below that so you can run it immediately on Windows. ,

I vaguely remember playing a similar game (a vertical scroller) in arcades back in the 1980s. That game was 1942.

The 1945 game has been programmed in C and uses SDL2. As always I took a walk through the source just to compare how it was done say compared to my own efforts. One thing I noticed is that he uses a fixed delay of 11 milliseconds each frame in the game loop by calling SDL_delay(11) rather than setting up the video to sync to the fly back. Is this better or worse? I’m not sure.

I think I prefer my method in case something takes a bit longer. Having a fixed delay means that you could risk overrunning the 16.666 milliseconds allowed per frame. That could never happen with my asteroids game as syncing to the fly back means my game can take as long as 16.66 milliseconds per frame and still not overrun.

 

 

Next atoms tutorial added

Next atoms tutorial added

Atom2sThe first version of the program was 90 lines long but now it has grown to 275. This includes code to let the computer play and checking code plus I’ve refactored it a bit, simplifying the code.  I haven’t extensively tested it and at least one bug has crept in. Occasionally the computer seems to claim ownership of a player cell. This stops you adding one to that cell so its not good.

You are welcome to have a look at the code and fix it. I will in a few days. The code is on GitHub and is a single file atoms2.c. As before its been compiled with Visual Studio 2019 Community edition though it should compile more or less unchanged with gcc, clang etc. It runs in a terminal/command line. You can see the computer playing in the screenshot.

I’ve also added the tutorial for this.

Where are the business games?

Where are the business games?

Entrepreneur image
Image by Gerd Altmann from Pixabay

Back in the 8-bit days there used to be a few business simulation type games about. These were mostly text games; I remember one was a multiplayer game about making and selling televisions; you had to make decisions about how many lines to run in your Factory, how much to spend on marketing, R & D etc. and then each turn the program would determine how many TVs you had sold and whether you made a profit or loss.

The only modern equivalents seems to be games like “Pizza Tycoon” and of course the web/mobile game FarmVille (which has just shut down!) . There are others e.g. Airport Tycoon etc. But the simpler games don’t seem to exist any more.

The type of game I was thinking about were more like business simulations. Back before home computers were popular in the late 1970s, I worked one summer on a farm owned by a bloke who created business games for companies for use as training aids.

One such game I played ran in a games ‘Zine back in the late 70s. The person running the game must have had a computer because each turn I’d receive a complicated printout with all sorts of accounting information on it. Things like Cost of Sales, depreciation of value of stock, cost of storing stock and so on as well as P & L and Balance Sheet. It had to have been written by an accountant!

At the very simplest there are games like Hammurabi where you have to survive multiple years by selling land, planting and harvesting wheat to feed your population. This page on Wikipedia lists nearly 200 commercial and web games. It doesn’t however mention the likes of Dope Wars or even torn.com. Possibly those are perceived more like rpg/mmorpg rather than say pure business simulations.

For the simpler type of games like the ones I was describing, C is not a bad language to implement them in.

 

 

Program a NES game in C

Program a NES game in C

BNES Marioack in the mid 80s I was busy writing games for ZX Spectrum, MSX and CBM-64 and also porting games between 6502 and Z80. That was also when the original NES appeared.  That had a 6502 CPU but a lot less RAM than the CBM-64.

In those days the NES was programmed in assembly language. C was still too new for most things but now, it’s possible to program a NES game in C. Developer Douglas Fraker has produced a series of tutorials on how to create NES games in C using cc65, a C compiler/assembler that takes C code and outputs 6502 assembly language.

His tutorials cover the whole range of things including sprites, how palettes work, music, sound effects, even how to use the Zapper (a stand alone gun-like accessory) with all source code on GitHub.  You can run games on an emulator such as the one that comes with RetroPie.

Reading the page on 6502 ASM Basics brought it all back to me even though it’s 31 years since I last wrote 6502 code.

 

.

Is there a market for games on Linux?

Is there a market for games on Linux?

Ubuntu GamesDon’t get me wrong, I like Linux. I’ve put in enough hours, especially on Raspberry Pi programming but games don’t seem to sell at all well on Linux. For one there’s a massive expectation of free software. Ubuntu comes with plenty of free games and some really good quality ones like 0Ad or Battle of Wesnoth.

The screenshot is from the Games category of the Ubuntu software installer. A very rough count suggests there’s over 420 games available there. Add to that emulators and ROMs (if you can get them) and you end up with almost 20,000 games.

I bought a Retro Pi at a Winter fair a couple of years ago and it came with 18,000 games. It was an Orange PI with a 16GB SD Card running the Retro Pie distribution which is available online. There’s no way the games are legal BTW, I even found four games that I wrote back in the mid 1980s running on the ZX Spectrum and CBM-64 emulators. All of the four games were smaller in size than the screenshot image! (Please don’t ask for a copy of the games. I gave them away with the Orange Pi to a nephew.)

If you are a Linux developer, how many games have you ever bought?

As this article on The Register explains “In the past year, Puppygames has sold 290 of its eight games on Linux and nearly 9,000 on Windows. ”

Most money I’d guess is made by companies producing AAA games especially on console.

So if you restrict yourself to developing games only for the Linux market then I imagine it would be very disheartening. However it’s not difficult to port them to Windows. Or you can look beyond desktop and venture into mobile development and web games. Both are considerably different to desktop games development and have their own problems (like getting your mobile app found when there’s a million others competing against it!). Or you can go down the “Write an ebook book about game development” as I have done.

Wizznic – a cross platform game in C

Wizznic – a cross platform game in C

Wizznic screenshotWizznic is a sliding blocks puzzle game. The game is written in C and used SDL and SDL Gfx. The developer a Danish programmer called Jimmy Christensen has made it freely available on GitHub so you can modify it, do what you want with it. It’s distributed under the GNU GPL (General Public Licence).

The game itself is multi level and there are other levels (DLC – free) available, just get the code on the content page. The game includes an editor which is why I guess there are so many downloads available.

The game itself is for gp2x, Windows and Linux and also includes make files for Pandora and PSP (PlayStation Portable). I’m always curious about the source code and the main game comes in 36 .c files and 37 .h with the biggest file being the 2000 lines of code menu.c.

If you are learning C or just want to see how a game is done, it’s an excellent way to study, especially because it’s cross platform. I suspect it’s SDL 1.25 because it uses surfaces rather than textures as in SDL 2.