Making a start!

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

I think we have enough ideas to understand what sort of systems we'll need.
I like writing systems.

I'll be taking previous game/demo code as required and porting it over to a new codebase. Because I often start with a previous project and remove stuff I don't need, I like to start with previous code that already has most of what I want/need.  In this case that's likely to be either Sokoban, or possibly Lemmings.

In particular I think I'll need...

* the 40x22 'character graphics' with scrolling and zooming systems (Sokoban)
* automatic char animation (for the water) possibly from Boulder Dash or Sokoban if it has it
* software sprite system - from lemmings

That should be enough to get me up and running with a rudimentary visualisation of what this might look like.


Decisions to make.

Since I'm opting (for the most part) for 'character' based data we are limited in world size to the amount of RAM I can spare for a 'board'. I won't quote character anymore, but basically it's exactly the same as a character set element (i.e., a shape perhaps in the form of a letter, or an icon, etc). In BoulderDash it's typically bee 40 x 22 (=880 bytes). Given the tons of other buffers required for sprites etc., this is kinda the max. We shall see.  But if I can hit/afford a 32x32 world that works nicely and I'd go with that.

I need to decide the pixel/trixel dimensions of each character. I can of course have different character sets with different dimensions. I already have a really nice/cool python tool that takes an arbitrary number of source images (gif/png/jpg/etc) and produces a combined character set from those (optimised to reduce duplicates). The characters are configurable in size, so we can for example have a character set 8 PF pixels wide x 10 deep.  Or 5 x 33... whatever.  The really cool part of the tool is that it outputs C code (of course), but that it also outputs *matrices* showing which characters go where.

So for example, if I have an alphabet character set and it happens to be called 'alphabet.gif' and it's in the format (say) of characters defined vertically... then the tool outputs a matrix of character usage in the combined character set.  The matrix would let me lookup the letter... e.g., mat_alphabet_gif_grid['P'] would give me the correct character number (from the combined character set) for displaying the letter P.  I've siplified just a tad, but essentially I don't have to remember which numbers are used for the characters. In other words, each source graphics file associates with a similarly named C matrix array, and all source graphics files (in the one command line invocation of the tool) share the one character set. We can have as many character sets as we want (of different character dimensions), but we should use one set for all characters of the same dimension, because we get the benefit of reuse.

Example tool call from GridLock...

python3 tools/cset.py -o cset.c --name charset --width 5 --depth 11 gfx/cars/blank.gif gfx/cars/wall.gif gfx/cars/numbers.gif gfx/cars/car*.gif gfx/cars/blip.gif


So that combines various graphics source files into a single character set (called 'cset.c') each character being 5 pixels wide and 11 trixels deep. The first character is guaranteed to be blank (because it's the first file), and then a few other files, including wildcards... ordering doesn't reall matter.

Sample 'cset.c' attached; you can see where each source graphics file has an associated *_mat[][] file giving the mapping to the correct character numbers.  It's cool because I don't have to keep track of stuff; I just reference the array names.

For example, to draw the word/banner "GRiDLOCK" at left of the play screen, this is all the required code...

// GRIDLOCK banner
unsigned char *q;
for (int i = 0; i < 6; i++) {
q = ADDRESS_OF(i);
*q = gfx_cars_numbers_gif_map[10 + i][0];
}

Essentially; get the RAM address of the top left character in the screen buffer, then draw 6 characters (vertically), getting the character number from the map for the graphics file 'gfx/cars/numbers.gif'. Note the 10+i is just because the workd gridlock starts in the leftmost column
  • at row 10 onwards. The first 10 rows are the digits 0 to 9. I can't stress enough how easy this tool has made things.


Anyway, The first step will be to draw a few 'squarebergs' in graphics files, checking out various character sizes (currently thinking 5 PF wide x 11 trixels (=33 scanlines) deep. Draw a fwe different coloured squarebergs, play with borders on them, or patterns perhaps, and scatter their character numbers fairly randomly around the 32x32 (or whatever) board.

Then I can work on scrolling around the board just to see how it looks.  I might at that stage make it so you're actually controlling a squareberg on which you are supposedly standing. So that squareberg is always onscreen, and as you move it the scroll scrolls appropriately.

Note the existing scroll systems are not *wraparound* nor is the screen draw system, so I'll have to do a bit of rework there, too.

So stage 1 will be that --- get a basic shell up and running, with a scrolling wraparound world populated by squarebergs. I can at that point experiment with squareberg sizes and start to think about how islands are formed and the various game mechanics.

I'm considering open-sourcing the entire codebase, but not really sure if there's an audience big enough or if it would really be used 'properly' by others, if at all.  I mean, what's the point of sharing source code if NOBODY even looks at it or uses it.

Anyway, I'm quite interested to see how this might look - no idea if it would play well as a game, but the sytems should be fun/challenging to write, so off we go...