Thursday, May 13, 2010

Pygridz Class Definitions

Today the Internet was down most of the day, and I used that time to define my initial Pygridz classes. The morning after I wrote the rest of this post, I coded the following 5 classes as a Python script (not including load/save game). There are 5 classes, from highest to lowest level:
  1. Game
  2. Level
  3. Room
  4. Tilex (set of one or more tiles)
  5. Pattern (matrix of ones and zeroes)
Game:

  • levelList: list of levels
  • roomList: list of rooms
  • tlxList: list of tilex objects
  • patList: list of patterns
  • levelIdx, roomIdx, tlxIdx, patIdx: pointers to linked lists of available (unused) levels, rooms, tilexes, and patterns
Level:

  • levId: level no.
  • height: no. of rows
  • width: no. columns
  • color: background color
  • penColor: color of grid lines
  • roomList: list of room indices
Room:

  • romId: room no.
  • levId: level no.
  • tlxList: list of tilex indices

Tilex:

  • tlxId: tilex no.
  • romId: room no.
  • levId: level no.
  • zOrder: display order, from back to front (equals zero for main tilex object of a room)
  • row: row no. of upper left corner
  • col: col no. of upper left corner
  • height: no. of rows
  • width: no. of columns
  • color: color of tiles
  • penColor: color of grid lines
  • fileName: file name of bitmap, if any
  • patId: pattern no. (if fileName is empty)

Pattern:

  • patId: pattern no.
  • patBits: list of h strings (composed of ones and zeroes), each of length w, where h = height and w = width

The above 5 classes will be used by the original version of the Map Editor to create maps of rooms (one map for each level), where rooms contain tilex objects (each tilex is a set of one or more tiles, all of the same color). Some tilex objects contain a bitmap, and are the same size as a single tile.

The 4 classes other than the Game class are each stored on disk in the form of comma-delimited text files. Each of those 4 files are stored in the following directory: C:\Docs\Pygridz\Data\Games\TicTacToe\, where TicTacToe is just a sample game name. For fields which are lists (of indices or strings), each list element appears on a separate line in the text file, preceded by an asterisk character (*). For records which correspond to available (unused) objects, the corresponding line in the text file consists of the index no. of the next available (unused) record, preceded by a slash character (/). Colors are represented by 3 values (RGB) separated by spaces, each value between 0 and 255, all enclosed in parentheses.

No comments:

Post a Comment