October 02, 2006

Game area, the screen, the world map

Hello again,

It's time to speak about the game screen (room).

As I decided all rooms will be built up by 2x2 tiles. To conserve memory (again...), I decided to I won't use the whole screen, only a portion of it. My idea was a 40x20 chars large area, in addition of a "information panel" at the bottom of the screen, 40x5 sized, and with another charset. But I didn't like the 40x20 sized area, it seemed to wide and flat. I changed its size to 36x20, saving 20 bytes per room. This way each room will contain 18 * 10 = 180 tiles. In addition, I have to store the datas of enemies also, like this:
  • which sprite graphic
  • sprite color
  • starting position on screen
  • which direction it starts to move first
  • how long its path length
  • movement speed
Let you allow me to explain these attributes with the help of another image:


What can we see? A room with some walls and platfoms, and two enemies with different colors. The blue one will start moving down appr. 12 characters then will turn back. The other will go left first 23 characters and turns back (its path length is 23). BTW this is a bad example, as you see they cross eachothers' path which I have to avoid in future room planning :)

Now how can I arrange these rooms to create a world?

I could store some more datas about all screens, for example:
  • if player goes out of screen at upper side, which room he gets
  • if player goes out of screen at right side, which room he gets
  • and so on...
This is acceptable, only 4 extra bytes (the 4 directions player can leave a room) per room.

There is another way (and more) I may choose: take a paper with grid on it, and write numbers in the cells. That's all. I declare an array, hmm, 16x16 in size, I put a room number into cells, and voilá! I don't have to define where can I go from this room, etc. If I go right side of room and there's no wall which could block my way, I just look in world map which room is right from actual room. It needs less code to manage in Plus/4, and easier to implement its editor on the PC. Am I lazy?

A small worldmap, just as a sample:

It's a 3x2 world, with five rooms, first row: 1-2-3, last row: 0-4-5. From room 2 I can go to 1 and 3 and 4. It's not defined, but there's no any objects which block your way.


Next time I try to explain how tile graphics banking work... See ya soon!

3 comments:

Anonymous said...

When will you return to the land of the living???

Anonymous said...

Fantastic reading! But why the slow updates!?

KiCHY said...

Sry for late respond. From now I'll try to update more frequently (lost interest, etc.)