Adventure Game
Description:
Write a program that will allow someone to play an adventure game similar to the original
Dungeon game. The program should require the player to navigate a 10x10 grid from a starting
location to an ending location while avoiding various pitfalls (monsters, dead ends, etc). The
player wins if he/she makes it to the end and escapes alive.
Suggestion for Adding Graphics:
Save the retro_pack.png file to your current MATLAB folder (the folder in which you will write
your game program). The sprites in this file are 16 by 16 pixels and organized into rows of 32.
Since there are so many sprites, you may want to copy the ones you want into the provided
retro_blank.png to make things easier.
Graphics Example:
Load Graphics Data:
% Initialize scene
my_scene = simpleGameEngine('retro_pack.png',16,16,4);
% Set up variables to name the various sprites
% The formula here is: (row-1)*32 + column
blank_sprite = 1;
sword_sprite = 28*32+3;
boots_sprite = 23*32+9;
shield_sprite = 26*32+9;
potion_sprite = 23*32+27;
monster_sprite = 9*32+19;
player_sprite = 27;
door_sprite = 9*32+11;
empty_room_sprite = 17;
% Display empty board
rooms_display = empty_room_sprite * ones(10,10);
drawScene(my_scene,rooms_display)
Note: If you dock the
figure by clicking on the
arrow, it will stay on the
screen the entire time for
viewing.
Displaying Game Images on the Game Board:
Example:
The player starts at position (1,1)
The exit door is located at position (10,10)
The following items are placed at the following positions:
o Sword (5,5)
o Shield (3,4)
o Boots (6,9)
o Health Potion (2,8)
o Monsters (3,7), (8,8), and (7,3)
% Now set up A second layer with the game pieces
gameboard_display = blank_sprite * ones(10,10);
gameboard_display(1,1) = player_sprite;
gameboard_display(10,10) = door_sprite;
gameboard_display(5,5) = sword_sprite;
gameboard_display(3,4) = shield_sprite;
gameboard_display(6,9) = boots_sprite;
gameboard_display(2,8) = potion_sprite;
gameboard_display(3,7) = monster_sprite;
gameboard_display(8,8) = monster_sprite;
gameboard_display(7,3) = monster_sprite;
drawScene(my_scene,rooms_display,gameboard_display)
Moving the Player on the Board
Suppose the player moves from location (1,1) to location (2,1)
% Move the player from (1,1) to (2,1)
gameboard_display(1,1) = blank_sprite;
gameboard_display(2,1) = player_sprite;
drawScene(my_scene,rooms_display,gameboard_display)
Other Notes:
Use the “warning” command to suppress warnings when displaying images (you should
place this at the beginning of your program).
warning('off','all'); % turns off all warning messages
You will likely need to maintain array(s) that contains the locations/properties of the
various objects in the world, then write a function that creates the gameboard_display
matrix above from those arrays.
Gameplay Suggestions:
Below are several suggestions for different styles of gameplay that can be incorporated. You
may use all or none of these suggestions in developing your game.
Keep track of the players stats throughout the course of the game. Some stats you will
likely need to maintain (but are certainly not limited to) are:
o Health
o Attack ability
o Defense ability
o Movement speed
Use the items to enhance the stats of the player. For instance, picking up the sword can
increase the damage done, finding the boots can increase the number of spaces a player
can move, etc.
Options for Monsters:
o Easiest: Position monsters randomly throughout the board and show them to the
user.
o Moderate: Position monsters randomly throughout the board but do not show the
player where they are. When the player encounters a monster, allow him/her to
choose whether to fight or run away.
o Difficult: Position monsters randomly throughout the board and show them to the
user, but allow them to move freely. Once the player gets within a certain
distance, have the monsters attempt to catch the player.
o Insane: Position monsters randomly throughout the board and allow them to move
freely, but do not show them to the user. Once the player gets within a certain
distance, have the monsters attempt to catch the player.
o Have monsters guard the items.
o Have a super monster which guards the exit, so the user must gain enough
strength to defeat the super monster to win the game.
Options for fighting monsters:
o Easy: subtract the defense of the defender from the attack of the attacker and
subtract the remainder from the health of the defender
o Moderate: use a random value to increase or decrease the attack ability or defense
ability to simulate making a great attack or defense or a poor attack or defense
o Difficult: Use a rock-paper-scissors mechanic to resolve battles: the player and
computer each choose a strategy (rock, paper, or scissors, but come up with some
more flavorful names for them) and who chose what determines the effectiveness
of their attacks (or determines who gets to attack).
Options for defeating a monster:
o Defeating a monster simply allows you to move to that location
o Defeating a monster increases the stats of the player
o Defeating a monster provides experience; once the experience of the player
reaches a certain level, unlocks a special ability