Everything Hogweed, All The Time

zxlib

What is ZXLIB?

Hogweed Software’s ZXLIB is an object-orientated C++ library for writing 2D games of the sort which used to abound on the ZX Spectrum and its contemporaries, while taking advantage of the vast increase in memory and graphical ability of machines today. If like me you grew up with those computers and always enjoyed the old classics like Manic Miner, Jet Set Willy, and Atic Atac, the quirkiness of characters like Hungry Horace and Miner Willy, and the countless variations on the old arcade games like Space Invaders, Asteroids and the like, and thought it would be even more fun writing your own similar games on the PC in a modern programming language, then ZXLIB is the library for you. Likewise if you want to program your own completely new and original 2D game for the PC. If on the other hand you want to be merely a cog in the wheel working on on a “cutting edge” (but maybe not that original) game for 15 year old “serious gamers” which requires astrophysics PhDs and artists of the ability of Leonardo to write, as well as 128MB of RAM and a 2 gigahertz processor to run, then you’d best look elsewhere… 🙂

Features

Running on Linux and Windows, and potentially a whole range of other systems, ZXLIB is based on SDL, a very good cross platform multimedia library which allows low-level graphical manipulation. You should know something about SDL before starting to use ZXLIB; however, ZXLIB allows you to bypass the low-level details of manipulating graphics memory and concentrate on the higher-level entities in your game. It contains classes for the following:

Sprites, Creatures and Monsters. A sprite is a movable graphic in your game, such as the hero of the game (like Pacman, Miner Willy or Hungry Horace), the monsters (invaders, ghosts, flying pigs, Maria the housekeeper…) or inanimate objects like bullets or arrows. What makes a sprite special compared to a regular graphic is that it can be drawn on the screen without erasing what’s underneath. A creature is a sprite that’s alive, i.e. Pacman and the ghosts are creatures, but a bullet isn’t. It differs from a plain sprite in that it has a given number of lives. A monster is a further-specialised creature, which can chase another!

The game Arena. The arena encapsulates the actual screen when you’re playing the game. Like a real arena – like a football ground or concert hall for instance – it contains not only the playing area itself, but also room for scores and other status information. The arena provides the bounds which limit where the sprites can move, and you can also load a background image as “wallpaper” for your arena.

The game itself.As well as encapsulating the creatures in your game and the arena, with ZXLIB the actual game itself is encapsulated as an object. To write your own game you derive your own game class from the base Game class which provides the basic functionality for a game, and override methods to respond to keyboard and mouse input, to provide the actual action and to refresh the screen. For those of you very happy with object-orientated programming, and in particular, GUI programming, this provides a nice way to program which allows you to skip the basic mechanics of how a game runs; but it is perfectly possible to use the sprite and arena classes without using the game class at all. More on this in lesson 2 of the tutorial.

Simple font classes To allow you to write text on the screen, ZXLIB contains simple classes for bitmapped fonts (those represented as pixel grids with all characters of equal width), and truetype fonts (those which appear on the screen as they would on print, with unequal widths for different characters, e.g. Times and the like).

What you should know

To start using ZXLIB you should be comfortable with programming in C++, including classes, objects and inheritance, as well as error handling with exceptions. You should also know the basics of the SDL library, though anything you don’t understand you can always look up in that library’s documentation.

Categories

Hogweed Software is a US corporation started by a team of venture capitalists and assorted entrepreneurs, with the aim of making as much money as possible from dodgy products in a couple of years, before selling all the rights to Global Megacorp Inc and making even more.

Only kidding... Hogweed is basically, er, just me. So what's my programming history (other than ZX Basic back in the 1980s :-) ) ? Well, I started programming in C on Unix when I started my PhD in antibody structure prediction. A couple of years later I got my first PC (a secondhand 386) and did a few games and graphics utilities in Borland's Turbo C++ on DOS on that, basically new versions of Pacman, Space Invaders and the like plus software to design the graphics. Later I upgraded to a Pentium II with Windows 95, the machine I still use now, and started playing around with Java, again coding one or two games plus a graphical designing program which avoided the need to use GIFs and JPEGs with Java images, something that came about when I discovered at the time (1998) that there were no free programs to convert BMP to GIF and JPEG files, an essential task given that Win95 supported no format other than BMP. In the meantime, my interest in C and C++ programming on the PC waned as I was greatly put off by the ghastly-looking Windows API and Microsoft Foundation Classes: my first taste of GUI coding had been the Java AWT and those basically sucked in comparison... :-)

Being used to Unix at work I'd always been vaguely interested in Linux, but had been put off by the awkward installation until around a year ago when I discovered version 7.2 of Mandrake which promised an easy installation. Well, on it went and so I enjoyed the ability to use the powerful shell and compile/make tools that I'd been used to at work. It also meant I could do much of my work at home which was nice :-) My first programming project was a designer and player for those text adventures that you used to get on the ZX Spectrum (coming soon here...); later I also discovered that graphical programming in C++ was far nicer under Unix/Linux than Windows, thanks to a great number of well designed libraries, which reawakened my interest in this. Subsequent discovery that many of these were actually cross-platform - available for Windows too - encouraged me to get going on Hogweed's first release, Mapmaker, more of which can be found here .