Microrealms: An adventure game on the mbed platform

Dependencies:   mbed

Committer:
f3d
Date:
Thu Dec 04 14:17:50 2014 +0000
Revision:
0:4da21a20e2c1
An adventure game called MicroRealms on the mbed platform.  Should work with most mbed enabled devices as it is pretty frugal with resources. ; Requires a dumb terminal program (e.g. hyperterminal,minicom etc)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
f3d 0:4da21a20e2c1 1 // realm.h
f3d 0:4da21a20e2c1 2 // Some game constants
f3d 0:4da21a20e2c1 3 #define MAP_WIDTH 30
f3d 0:4da21a20e2c1 4 #define MAP_HEIGHT 20
f3d 0:4da21a20e2c1 5 #define MAX_NAME_LEN 20
f3d 0:4da21a20e2c1 6 #define MAX_WEAPONS 4
f3d 0:4da21a20e2c1 7
f3d 0:4da21a20e2c1 8
f3d 0:4da21a20e2c1 9 typedef unsigned char byte;
f3d 0:4da21a20e2c1 10 typedef struct {
f3d 0:4da21a20e2c1 11 byte map[MAP_HEIGHT][MAP_WIDTH];
f3d 0:4da21a20e2c1 12
f3d 0:4da21a20e2c1 13 } tRealm;
f3d 0:4da21a20e2c1 14 typedef struct {
f3d 0:4da21a20e2c1 15 char name[MAX_NAME_LEN+1];
f3d 0:4da21a20e2c1 16 byte health;
f3d 0:4da21a20e2c1 17 byte strength;
f3d 0:4da21a20e2c1 18 byte magic;
f3d 0:4da21a20e2c1 19 byte wealth;
f3d 0:4da21a20e2c1 20 byte x,y;
f3d 0:4da21a20e2c1 21 byte Weapon1;
f3d 0:4da21a20e2c1 22 byte Weapon2;
f3d 0:4da21a20e2c1 23 } tPlayer;
f3d 0:4da21a20e2c1 24
f3d 0:4da21a20e2c1 25 // Function prototypes
f3d 0:4da21a20e2c1 26 unsigned prbs();
f3d 0:4da21a20e2c1 27 unsigned random(unsigned range);
f3d 0:4da21a20e2c1 28 void showHelp();
f3d 0:4da21a20e2c1 29 void showGameMessage(char *Msg);
f3d 0:4da21a20e2c1 30 char getUserInput();
f3d 0:4da21a20e2c1 31 void runGame(void);
f3d 0:4da21a20e2c1 32 void initRealm(tRealm *Realm);
f3d 0:4da21a20e2c1 33 void showRealm(tRealm *Realm,tPlayer *thePlayer);
f3d 0:4da21a20e2c1 34 void initPlayer(tPlayer *Player,tRealm *Realm);
f3d 0:4da21a20e2c1 35 void showPlayer(tPlayer *thePlayer);
f3d 0:4da21a20e2c1 36 void step(char Direction,tPlayer *Player,tRealm *Realm);
f3d 0:4da21a20e2c1 37 void setHealth(tPlayer *Player,int health);
f3d 0:4da21a20e2c1 38 void setStrength(tPlayer *Player, byte strength);
f3d 0:4da21a20e2c1 39 int addWeapon(tPlayer *Player, int Weapon);
f3d 0:4da21a20e2c1 40 int doChallenge(tPlayer *Player, int BadGuyIndex);
f3d 0:4da21a20e2c1 41 const char *getWeaponName(int index);
f3d 0:4da21a20e2c1 42 void zap(void);