Deep C rescue
by
, 02-04-2016 at 09:52 PM (87307 Views)
Great caption, huh?
Introduction
I'm a self-taught programmer that started out with C64 BASIC back in the 1980;ies. I quickly moved on to 6502 assembler and became quite good at coding demos, I'm still impressed what a 8-bit 1MHz CPU is capable of. As a natural next step I moved on to 16-bit assembler on the Amiga (Motorola 68k) and produced a few demos there aswell. Started using C to tie my assembly routines together, and later used it as a high level language to make prototyping faster, then at a later stage most of the code was translated by hand to assembler instructions to get the most out of every CPU cycle!
My last Amiga was a 3000, a remarkable machine! By that time I had gathered quite a large library of function that I could link to, so I started to use C more and more, only dipping into assembler when really needed. Cooperated with a couple of other Swedish guys and made a shoot'em'up thas was about to be published by Digital Illusion (later Dice), but we where never able to present a finsihed product, and when Commodore closed it's doors in 1994 the market for Amiga games died with it. I moved on to IBM compatible PC;s, and one of the first ones I got was a 386 with a 33MHz CPU. The OS was MSDOS and 16 bit real-mode was what all cool kids where hacking in! Got a copy of Turbo C from a friend and started exploring mode 13h (320x200 with 256 colors).
Now what?
I won't bore you anymore with ancient stuff like that, lets skip forward a couple of decades. For over twenty years I've been hacking away in C, during that time maybe 10 game projects has reached alpha-state, 5 of those are quite stable and 1 is a finished, polished game. The latest of them, an Arkanoid/Breakout clone is what brought me here.
The game is finished, polished and very much playable, it runs fine on a Raspberry Pi3 and is tailormade to suite my family, with different game modes like "Mum's revenge" and "Dad's dangerzone". Much because of that it will never be installed on anything else then our RPi. The game itself is simple, but the underlying engine is quite advanced with an Entity-Component system, resource management with reference counting and support for both Lua and Json, the latter used for config files. After the final build and installation of the game I found myself with nothing to do, not a single one of my abandoned projects felt appealing to me so I started to scavenge the internet for ideas. I had decided to use SDL2 for the next project as the original version is a bit outdated now, and by a fluke of luck I stumbled into this site:
http://www.freepascal-meets-sdl.net/
Most of you are probably well known visitors, but it had me at that classic Borland Turbo colorscheme - suddenly I was 20 years younger and full of inspiration. I downloaded Free Pascal, Lazarus and the SDL2 units. Initially I had some trouble with the IDE (Lazarus), but eventually, and with some help, I sorted it out. Never touched Pascal before, and back in my Turbo C days it was the favourite hate-object in 'serious' C communities (we had BBS;es back then, internet wasn't invented). At first it felt awkward, but after exploring it for a while and reading the wiki I began to like it more and more. I've tried C++, but imho it's a great way to ruin the elegance of C - it hurts my eyes! I'm no stranger to OOP concepts, as C can be used in such a manner - data hiding can be done with opaque pointers for example.
After toying around for a couple of hours I decided to port my newly finsihed game to Pascal, or Object Pascal to be more precise. Only took me about two hours to have my GUI code up and running, but the code was a mess and I've rewritten it twice already. Up to now I've ported the basics of the ECS, the resource management system, the GUI and parts of input. I'm fully aware of how big this project really is, don't forget that I've already done it once, and 'Hello, world' tutorials gives me the creeps! Go big or go home!
Captain goes Capitaine
The C version of the engine is named 'Captain' after the game project it was initially designed for, 'Captain Asscrack' - a Gauntlet style game with a pirate theme, and as Blaise Pascal was French, I've named the Pascal version 'Capitaine'. The original C version has been developed for about two years, the game slapped ontop of it took me about a month and a half to finish. The Pascal version should take less time to finish, most of the design is already done. I'm planning to stick as close as possible to the functionality of the original engine, but some sections of it will get considerably easier to implement in a more OOP-friendly language. For example, the sourcecode for the resource management system is nowhere near as large and complex as the original version.
As this is a hobby for me I can't, and will not spend all my sparetime on this project, so from time to time it may be a while between updates, but stay tuned! I'll progress slow and steady as always!