Labyrinth of the Minotaur A simple roguelike/RPG using a nokia 5110 screen

Dependencies:   N5110 PowerControl mbed

Committer:
ThomasBGill
Date:
Fri May 08 22:24:44 2015 +0000
Revision:
28:b3a597b38b60
Parent:
27:1ad2408ba702
Child:
29:89bc8c8aa8ac
Graphics added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThomasBGill 26:0dd71fc0ede4 1 #include "N5110.h"
ThomasBGill 26:0dd71fc0ede4 2 #include "PowerControl/PowerControl.h"
ThomasBGill 26:0dd71fc0ede4 3 #include "PowerControl/EthernetPowerControl.h"
ThomasBGill 26:0dd71fc0ede4 4 #include "WorldBuilder.h"
ThomasBGill 26:0dd71fc0ede4 5 #include "Graphics.h"
ThomasBGill 26:0dd71fc0ede4 6
ThomasBGill 26:0dd71fc0ede4 7 // vcc sce rst dc mosi clk led
ThomasBGill 26:0dd71fc0ede4 8 N5110 lcd(p5, p6, p7, p8, p11, p13, p21);
ThomasBGill 26:0dd71fc0ede4 9 InterruptIn Act(p22);
ThomasBGill 26:0dd71fc0ede4 10 InterruptIn Start(p23);
ThomasBGill 28:b3a597b38b60 11 InterruptIn Up(p30);
ThomasBGill 28:b3a597b38b60 12 InterruptIn Down(p27);
ThomasBGill 28:b3a597b38b60 13 InterruptIn Left(p24);
ThomasBGill 28:b3a597b38b60 14 InterruptIn Right(p29);
ThomasBGill 26:0dd71fc0ede4 15 AnalogIn Noise(p19);
ThomasBGill 26:0dd71fc0ede4 16
ThomasBGill 26:0dd71fc0ede4 17 #define USR_POWERDOWN (0x104)
ThomasBGill 26:0dd71fc0ede4 18
ThomasBGill 26:0dd71fc0ede4 19 LocalFileSystem local("local"); // create local filesystem
ThomasBGill 26:0dd71fc0ede4 20
ThomasBGill 26:0dd71fc0ede4 21 struct TILES {
ThomasBGill 26:0dd71fc0ede4 22 char Symbol; // Symbol for this tile
ThomasBGill 26:0dd71fc0ede4 23 bool Passable; // Can tile be walked on
ThomasBGill 26:0dd71fc0ede4 24 };
ThomasBGill 26:0dd71fc0ede4 25
ThomasBGill 26:0dd71fc0ede4 26 TILES TileList[] = {
ThomasBGill 26:0dd71fc0ede4 27 { '#', false }, // 0- WALL
ThomasBGill 26:0dd71fc0ede4 28 { '.', true }, // 1- FLOOR
ThomasBGill 26:0dd71fc0ede4 29 { '+', true }, // 2- ENTER
ThomasBGill 26:0dd71fc0ede4 30 { 'x', true }, // 3- EXIT
ThomasBGill 26:0dd71fc0ede4 31 { '.', true }, // 4- FLOOR_SEEN
ThomasBGill 26:0dd71fc0ede4 32 { '=', true }, // 5- CHEST
ThomasBGill 26:0dd71fc0ede4 33 { '/', true }, // 6- CHEST_OPENED
ThomasBGill 26:0dd71fc0ede4 34 };
ThomasBGill 26:0dd71fc0ede4 35
ThomasBGill 26:0dd71fc0ede4 36 struct ITEMS {
ThomasBGill 26:0dd71fc0ede4 37 char ItemName[15]; //Item name
ThomasBGill 26:0dd71fc0ede4 38 int ItemValue; //Damage/ armour value
ThomasBGill 26:0dd71fc0ede4 39 };
ThomasBGill 26:0dd71fc0ede4 40
ThomasBGill 26:0dd71fc0ede4 41 ITEMS ItemList[] = {
ThomasBGill 26:0dd71fc0ede4 42 //Weapons
ThomasBGill 26:0dd71fc0ede4 43 { "Dagger", 4 }, //0
ThomasBGill 26:0dd71fc0ede4 44 { "Axe", 5 }, //1
ThomasBGill 26:0dd71fc0ede4 45 { "Mace", 6 }, //2
ThomasBGill 26:0dd71fc0ede4 46 { "Sword", 7 }, //3
ThomasBGill 26:0dd71fc0ede4 47 { "Warhammer", 8 }, //4
ThomasBGill 26:0dd71fc0ede4 48 //Armour
ThomasBGill 26:0dd71fc0ede4 49 { "Cloth armour", 1 }, //5
ThomasBGill 26:0dd71fc0ede4 50 { "Leather armour", 2 }, //6
ThomasBGill 26:0dd71fc0ede4 51 { "Studded armour", 3 }, //7
ThomasBGill 26:0dd71fc0ede4 52 { "Chainmail vest", 4 }, //8
ThomasBGill 26:0dd71fc0ede4 53 { "Plate armour", 5 }, //9
ThomasBGill 26:0dd71fc0ede4 54 };
ThomasBGill 26:0dd71fc0ede4 55
ThomasBGill 26:0dd71fc0ede4 56 struct ENEMIES {
ThomasBGill 26:0dd71fc0ede4 57 char EName[9]; //Enemy name
ThomasBGill 26:0dd71fc0ede4 58 int EHealth; //Enemy health
ThomasBGill 26:0dd71fc0ede4 59 int EDamage; //Enemy damage
ThomasBGill 26:0dd71fc0ede4 60 int EArmour; //Enemy armour
ThomasBGill 26:0dd71fc0ede4 61 int EDodge; //Enemy dodge chance
ThomasBGill 26:0dd71fc0ede4 62 int EHit; //Enemy hit chance
ThomasBGill 26:0dd71fc0ede4 63 int ESpd; //Enemy speed (used for running away during fights)
ThomasBGill 26:0dd71fc0ede4 64 int EPoints; //How many points the monster is worth
ThomasBGill 26:0dd71fc0ede4 65 };
ThomasBGill 26:0dd71fc0ede4 66
ThomasBGill 26:0dd71fc0ede4 67 ENEMIES EnemyList[] = {
ThomasBGill 26:0dd71fc0ede4 68 //Name HP Dmg Arm Dg Ht Spd Pts
ThomasBGill 26:0dd71fc0ede4 69 { "Huge Rat", 5, 3, 0, 25, 70, 40, 1 }, //0- Huge Rat
ThomasBGill 26:0dd71fc0ede4 70 { "Goblin", 6, 3, 1, 25, 60, 30, 3 }, //1- Goblin
ThomasBGill 26:0dd71fc0ede4 71 { "Skeleton", 8, 4, 2, 10, 50, 10, 5 }, //2- Skeleton
ThomasBGill 26:0dd71fc0ede4 72 { "Wraith", 5, 4, 0, 40, 60, 50, 10 }, //3- Wraith
ThomasBGill 26:0dd71fc0ede4 73 { "Ogre", 10, 7, 3, 10, 35, 15, 15 }, //4- Ogre
ThomasBGill 26:0dd71fc0ede4 74 { "Minotaur", 15, 8, 4, 20, 45, 100, 50 }, //5- Minotaur
ThomasBGill 26:0dd71fc0ede4 75 };
ThomasBGill 26:0dd71fc0ede4 76
ThomasBGill 26:0dd71fc0ede4 77 //Variables
ThomasBGill 26:0dd71fc0ede4 78 int ActFlag = 0;
ThomasBGill 26:0dd71fc0ede4 79 int StartFlag = 0;
ThomasBGill 26:0dd71fc0ede4 80 int DirFlag = 0;
ThomasBGill 26:0dd71fc0ede4 81
ThomasBGill 26:0dd71fc0ede4 82 //Space type player is on
ThomasBGill 26:0dd71fc0ede4 83 int pSpace;
ThomasBGill 26:0dd71fc0ede4 84
ThomasBGill 26:0dd71fc0ede4 85 //Player Health
ThomasBGill 26:0dd71fc0ede4 86 int ph = 15;
ThomasBGill 26:0dd71fc0ede4 87
ThomasBGill 26:0dd71fc0ede4 88 //Player weapon
ThomasBGill 26:0dd71fc0ede4 89 int pw = 0; //0 to 4
ThomasBGill 26:0dd71fc0ede4 90
ThomasBGill 26:0dd71fc0ede4 91 //Player armour
ThomasBGill 26:0dd71fc0ede4 92 int pa = 5; //5 to 9
ThomasBGill 26:0dd71fc0ede4 93
ThomasBGill 26:0dd71fc0ede4 94 //Player score
ThomasBGill 26:0dd71fc0ede4 95 int score = -100; //100 level, x monster, 10 chest, -2 running away
ThomasBGill 26:0dd71fc0ede4 96
ThomasBGill 26:0dd71fc0ede4 97 //High scores
ThomasBGill 26:0dd71fc0ede4 98 int HScore1;
ThomasBGill 26:0dd71fc0ede4 99 int HScore2;
ThomasBGill 26:0dd71fc0ede4 100 int HScore3;
ThomasBGill 26:0dd71fc0ede4 101 int HScore4;
ThomasBGill 26:0dd71fc0ede4 102
ThomasBGill 26:0dd71fc0ede4 103 bool BossFight = false;
ThomasBGill 26:0dd71fc0ede4 104
ThomasBGill 26:0dd71fc0ede4 105 //Voids
ThomasBGill 26:0dd71fc0ede4 106 int semihost_powerdown();
ThomasBGill 26:0dd71fc0ede4 107
ThomasBGill 26:0dd71fc0ede4 108 void ActPressed();
ThomasBGill 26:0dd71fc0ede4 109 void StartPressed();
ThomasBGill 26:0dd71fc0ede4 110 void DirPressed();
ThomasBGill 26:0dd71fc0ede4 111
ThomasBGill 26:0dd71fc0ede4 112 void writeDataToFile();
ThomasBGill 27:1ad2408ba702 113 void readDataFromFile();
ThomasBGill 27:1ad2408ba702 114 void HighScoreCheck();
ThomasBGill 26:0dd71fc0ede4 115
ThomasBGill 28:b3a597b38b60 116 void FlashScreen();
ThomasBGill 28:b3a597b38b60 117 void DrawGraphic(int p, int x, int y);
ThomasBGill 28:b3a597b38b60 118
ThomasBGill 26:0dd71fc0ede4 119 void Intro();
ThomasBGill 26:0dd71fc0ede4 120 void MainMenu();
ThomasBGill 26:0dd71fc0ede4 121 void Options();
ThomasBGill 26:0dd71fc0ede4 122 void LevelScreen();
ThomasBGill 26:0dd71fc0ede4 123 void GameLoop();
ThomasBGill 26:0dd71fc0ede4 124 void PlayerCamera();
ThomasBGill 26:0dd71fc0ede4 125 void PlayerMove();
ThomasBGill 26:0dd71fc0ede4 126 void Fight();
ThomasBGill 26:0dd71fc0ede4 127 void MonsterAttack(int m);
ThomasBGill 26:0dd71fc0ede4 128 void StartMenu();
ThomasBGill 26:0dd71fc0ede4 129 void Map();
ThomasBGill 26:0dd71fc0ede4 130 void DrawMap();
ThomasBGill 26:0dd71fc0ede4 131 void FlashPlayerLocation();
ThomasBGill 26:0dd71fc0ede4 132 void MapLegend();
ThomasBGill 26:0dd71fc0ede4 133 void Inventory();
ThomasBGill 26:0dd71fc0ede4 134 void Chest();
ThomasBGill 26:0dd71fc0ede4 135 void getItem();
ThomasBGill 26:0dd71fc0ede4 136 void BoobyTrap();
ThomasBGill 26:0dd71fc0ede4 137 void RevealMap();
ThomasBGill 26:0dd71fc0ede4 138 void Potion();
ThomasBGill 26:0dd71fc0ede4 139 void GameOver();
ThomasBGill 26:0dd71fc0ede4 140 void ScoreScreen();
ThomasBGill 26:0dd71fc0ede4 141 void HighScoreScreen();