How do we get tiles to stick on the game screen? By using some Quickset, you can try use mastic, no not really. What we might discover is that the process is much easier than trying to lay actual tile.
if we pay attention to the demo, when you hit an enemy with a bullet, the enemy changes into a little blue coffin, indicated its death. All we have to do now is find that little bit of code.
So, I look over the code a little and find something that looks suspiciously like a tile setting.
tiles[tmpy * scrw + tmpx]= 68;
let’s give that a little change and recompile to see if it’s the case
tiles[tmpy * scrw + tmpx]= 66;
Boingo, zoingo, yup that’s where it is.
Time to make a quick comment
tiles[tmpy * scrw + tmpx]= 66;//where enemy dies
That does not work on its own though if you comment out the next line.
tilepaint(tmpx, tmpy, tmpx, tmpy);
You will notice that the enemies will simply disappear when you kill them. So they both work in conjunction. You set the tile and must paint the screen with the tiles you set.
So armed with that bit of knowledge, one can generate an entire screen with some settings. Perhaps it could be an array set with the x,y and tile number. We will explore this another day since it will be the basis for the game.
Let’s now open your tile graphics, found in the /GFX folder. Using your favorite graphics editor, open up the file tiles.png
As you can see, the tileset is pretty large, 96 tiles, in fact, more tiles than I need for the game, which I’m pretty sure is eating up the memory. I’ll leave them in place for now, but as memory gets scarce, this will be the first thing I’ll look at.
The Tile numbering scheme starts at 0 and continues on to 95. Below find a nice little numbering scheme…..
I shouldn’t have to say this, but it has happened to me before, the Spectrum has a limited color display and you can have 1 foreground color and 1 background color per 8×8 square. If you accidentally place a 3rd color, the compilation process will look almost ok but will error out.
I happen to be using Paint Shop Pro (use GIMP if you don’t own PSP or Photoshop) and I have made a quick edit to the tileset to define the graphics for the border only.
Here are my new tiles. Notice that I created 4 tiles for top, bottom, left and right as well as 4 tiles for the corners. That’s 8 tiles right away!
Save the tileset and then open your MAP.TMX file to see the new graphics. If you left the TILED program open, just close it and reopen it to observe your new tiles.
For now, that’s all we need, we will modify additional tiles as needed.