For the final project, we will create a two-dimensional tile-based game based on the classic 8-bit NES game, The Legend of Zelda. Our game, however, will be a vast improvement over its predecessor, featuring better graphics, better sound, and more aggressive and cunning artificial intelligence. The object of the game is to guide your character, Link, to the end of the dungeon, where he must defeat the foul beast Lockwamentus.
Like any game, Zelda 291 is a project of much greater magnitude than any machine problem we have done so far. The most difficult part of the project will undoubtedly be getting each team member's modules to fit into a whole. See individual module writeups below for more information on the challenging aspects of each element of the game.
Zelda 291 is designed with a very
modular structure in mind. The following diagram illustrates the
basic game design:
IGL is where the main game loop takes place and
most of the decisions internal to the game's logic are made. When
IGL decides it is time for the sprites to be
drawn or needs to detect collisions between objects, it does so
through function calls provided by G & A.
When it needs a sound played, it does that through S
& M's functions, and when it's time for the monsters
to do something, it calls functions made accessible by AI.
Input's keyboard interrupts notify IGL
of keypresses, and a new timer handler polls for joystick and
gamepad input, notifying IGL in a like manner.
By communicating in this manner, the various modules will
hopefully be able to combine to form a fully-functional game.
What follows is a list of the data structures which the various modules will have to access; see individual module writeups for non-public data structures specific to those modules.
GameObjectGameObject structure is a generalized
data structure that represents everything from the player
character, Link, to the foul monsters he must defeat, to
a boomerang thrown by such a monster. Following is a list
of this structure's fields:gobj_type db ? - A byte value
indicating the type of object the structure
represents. gobj_x dw ? - The x-coordinate of
the upper-left corner of the object. gobj_y db ? - The y-coordinate of
the upper-left corner of the object. gobj_curr_frame db ? - The index of
the object's current animation frame in its
Sprite frame array. gobj_sprite_ptr dd ? - A pointer to
the object's Sprite structure. gobj_counter db 0 - A counter used
for the object's animation sequences. gobj_max_hp db ? - The maximum
number of hit points the object can have. One hit
point = one half-heart. gobj_curr_hp db ? - The current
number of hit points the object has. gobj_damage db ? - The number of hit
points the object can remove from a character. gobj_status dw 0 - A word indicating
the status of the object:gobj_is_moving db 0 - A flag
indicating whether the object is moving or not. gobj_speed db ? - The current speed
of the object, relative to that of Link. gobj_possession_link dw 0 - If this
object is a weapon, this points to its owner; if
it's a character, it points to the weapon it
owns. gobj_collision_link dw 0 - A pointer
to the GameObject this object has just collided
with, if applicable. gobj_background_pg_1 dd 0 - A
pointer to the object's background image buffer
for video memory page 1(see the Graphics & Animation
page for more on this). gobj_background_pg_2 dd 0 - A
pointer to the object's background image buffer
for video memory page 2. gobj_x_pg_1 db ? - The x-coordinate
of the object when it was scanned from page 1. gobj_y_pg_1 db ? - The y-coordinate
of the object when it was scanned from page 1. gobj_x_pg_2 db ? - The x-coordinate
of the object when it was scanned from page 2. gobj_y_pg_2 db ? - The y-coordinate
of the object when it was scanned from page 2. gobj_AI_Misc db ? - A miscellaneous
byte used by artificial intelligence.
TileMapTileMap structure contains the tile
mappings for a given room. Its fields are as follows:tmp_graphics db 16 dup('G') tmp_graphics1 db 16 dup('G') tmp_graphics2 db 16 dup('G') tmp_graphics3 db 16 dup('G') tmp_graphics4 db 16 dup('G') tmp_graphics5 db 16 dup('G') tmp_graphics6 db 16 dup('G') tmp_graphics7 db 16 dup('G') tmp_graphics8 db 16 dup('G') tmp_graphics9 db 16 dup('G') tmp_graphics10 db 16 dup('G') - Each
of these strings holds the graphical tile mapping
for one row of the room. The value of a byte at
(i, j) in this grid is the index of the desired
graphics tile in the tile array. tmp_walkability db 16 dup('W') tmp_walkability1 db 16 dup('W') tmp_walkability2 db 16 dup('W') tmp_walkability3 db 16 dup('W') tmp_walkability4 db 16 dup('W') tmp_walkability5 db 16 dup('W') tmp_walkability6 db 16 dup('W') tmp_walkability7 db 16 dup('W') tmp_walkability8 db 16 dup('W') tmp_walkability9 db 16 dup('W') tmp_walkability10 db 16 dup('W') -
Each string holds the walkability tile mapping
for one row of the room. The value of a byte at
(i, j) in this grid is either TILE_FREE(objects
can walk freely over the tile), TILE_WALL(nothing
can walk over the tile), or TILE_DOOR(Link
can walk over the tile, and should be moved to
the next room).
GameRoomGameRoom structure represents a room of
the game's dungeon. Its fields are as follows:grm_tile_map TileMap {} - The room's
tile mapping. grm_enemy_data_array GameObject
MAX_NUM_ENEMIES dup({}) - The room's array
containing the enemies within. grm_special db ? - A general-purpose
"special effect" field used for such
exceptional cases as when a door should open only
when all enemies have been defeated. grm_room_north_ptr dw ?, grm_room_east_ptr
dw ?, grm_room_south_ptr dw ?, grm_room_west_ptr
dw ? - Pointers to the GameRoom structures
representing the adjacent rooms in each of the
cardinal directions from this room. grm_room_AI_anger db 0 - A variable
used by artificial intelligence to increase the
aggressiveness of the monsters in the room as
they are picked off.
Here you will find links to writeups similar to this one for
each of the five primary game elements which will describe the
details of the implementation and challenges of the appropriate
element.