George Sykes ELEC2645 project

Dependencies:   mbed

https://os.mbed.com/media/uploads/el18gs/pixil-frame-0.png

GHOST HUNTER

In a world of ghostly horrors there is much money to be made in underground ghost fighting rings. You've managed to get hold of a Ghostbuster, a special piece of equipment that allows you to catch, train and fight ghosts.

Instructions

Below you will find the instructions for the game. Please note that due to COVID-19 a large part of the game (fighting ghosts) could not be added as it would have required access to a second gamepad which i could not acquire.

Welcome screen

When first started you will be presented with a welcome screen

  • Pot 1 to adjust the contrast on the screen
  • Press A to continue.

Main menu

You have three options, catch ghosts (add ghosts to your inventory), inventory (sell ghosts) or settings(adjust the games settings).

  • Press X and B to move the selection up and down respectively
  • Press A to enter the selected submenu

Catch Ghost

Will now be presented with two challenges. In the first you need to find a ghost, in the second you catch it. Theses stages will start automatically.

Find ghost

Rotate the gamepad on its roll and pitch axis until all the LED's turn on. The ones on the left indicate roll and the right pitch.

  • Rotate the gamepad on it roll and pitch to light up the LED's

Catch ghost

Return the gamepad to a comfortable position and use the joystick to move the crosshairs onto the ghost sprite. When ready press the A button to catch the ghost. You will be told what kind of ghost you have captured and it will be added to your inventory.

  • Press A to catch the ghost
  • Move the joystick to move the crosshairs

Inventory

The inventory allows you to view your ghosts and sell them.

  • Use Pot 1 to scroll through the ghosts
  • Pot 2 to scroll up and down the details of the individual ghosts
  • Press X to prepare to sell a ghost and press again to confirm, if you don't press again the sale screen will disappear after 5 seconds
  • Press Start to return to the main menu

Settings

This menu allows you to adjust some of the settings of the game.

  • Press X to go up one option
  • Press B to go down one option
  • Press A to enter the selected submenu
  • Press Start to return to the main menu

Contrast

Set the contrast of the LCD screen, the contrast will adjust on this screen so you can see the effect (contrast is bounded between 0.4 and 0.6).

  • Pot 1 to increase or decrease the contrast
  • Press A to set the contrast

Button Delay

Set the minimum time between button presses; if this is too low the game will detect two button presses when there was only one, too high and the buttons will seem unresponsive. So as to ensure these issues do not occur while changing the setting button X temporarily operates on the new delay but none of the others will until A is pressed.

  • Pot 1 to increase or decrease the delay
  • Press X to test the new delay, this will toggle the small circle to be filled in or unfilled
  • Press A to save the setting
Committer:
el18gs
Date:
Tue May 12 08:44:30 2020 +0000
Revision:
11:e89dbdb74df5
Parent:
8:4220d116f17c
Child:
13:3b2a4e14937b
Moved display_inventory into the inventory library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el18gs 3:9d811414d35e 1 #include "Inventory.h"
el18gs 3:9d811414d35e 2
el18gs 8:4220d116f17c 3 Inventory::Inventory(SDFileSystem &sd){
el18gs 3:9d811414d35e 4 printf("creating inventory\n");
el18gs 8:4220d116f17c 5 stringvec ghost_list = list_ghosts("/sd/ghosts", sd);
el18gs 3:9d811414d35e 6
el18gs 3:9d811414d35e 7 for(int i = 0; i < ghost_list.size(); i++){
el18gs 3:9d811414d35e 8
el18gs 3:9d811414d35e 9 std::string path = "/sd/ghosts/";
el18gs 3:9d811414d35e 10 path.append(ghost_list[i]);
el18gs 3:9d811414d35e 11 printf("Path to import '%s'\n", path.c_str());
el18gs 3:9d811414d35e 12
el18gs 8:4220d116f17c 13 Ghost temp(path, "/sd/ghosts/", sd);
el18gs 3:9d811414d35e 14 _ghosts.push_back(temp);
el18gs 3:9d811414d35e 15 }
el18gs 3:9d811414d35e 16 }
el18gs 3:9d811414d35e 17
el18gs 8:4220d116f17c 18 void Inventory::regen(SDFileSystem &sd){
el18gs 3:9d811414d35e 19 printf("Regenerating ghost list\n");
el18gs 3:9d811414d35e 20 _ghosts.clear();
el18gs 3:9d811414d35e 21
el18gs 8:4220d116f17c 22 stringvec ghost_list = list_ghosts("/sd/ghosts", sd);
el18gs 3:9d811414d35e 23
el18gs 3:9d811414d35e 24 for(int i = 0; i < ghost_list.size(); i++){
el18gs 3:9d811414d35e 25
el18gs 3:9d811414d35e 26 std::string path = "/sd/ghosts/";
el18gs 3:9d811414d35e 27 path.append(ghost_list[i]);
el18gs 3:9d811414d35e 28 printf("Path to import '%s'\n", path.c_str());
el18gs 3:9d811414d35e 29
el18gs 8:4220d116f17c 30 Ghost temp(path, "/sd/ghosts/", sd);
el18gs 3:9d811414d35e 31 _ghosts.push_back(temp);
el18gs 3:9d811414d35e 32 }
el18gs 3:9d811414d35e 33
el18gs 3:9d811414d35e 34 }
el18gs 3:9d811414d35e 35
el18gs 3:9d811414d35e 36 std::vector<int> Inventory::list_ghost_uids(void){
el18gs 3:9d811414d35e 37 std::vector<int> uids;
el18gs 3:9d811414d35e 38 for(int i = 0; i < _ghosts.size(); i++){
el18gs 3:9d811414d35e 39 uids.push_back(_ghosts[i].get_uid());
el18gs 3:9d811414d35e 40 //printf("Added UID %i to list\n", _ghosts[i].get_uid());
el18gs 3:9d811414d35e 41 }
el18gs 3:9d811414d35e 42
el18gs 3:9d811414d35e 43 return uids;
el18gs 3:9d811414d35e 44 }
el18gs 3:9d811414d35e 45
el18gs 3:9d811414d35e 46 Ghost Inventory::get_ghost_by_uid(int uid){
el18gs 3:9d811414d35e 47 for(int i = 0; i < _ghosts.size(); i++){
el18gs 3:9d811414d35e 48 if(_ghosts[i].get_uid() == uid){
el18gs 3:9d811414d35e 49 return _ghosts[i];
el18gs 3:9d811414d35e 50 }
el18gs 3:9d811414d35e 51 }
el18gs 3:9d811414d35e 52 return _ghosts[0];
el18gs 3:9d811414d35e 53 }
el18gs 3:9d811414d35e 54
el18gs 8:4220d116f17c 55 stringvec Inventory::list_ghosts(std::string path, SDFileSystem &sd)
el18gs 3:9d811414d35e 56 {
el18gs 3:9d811414d35e 57 // Connections to SD card holder on K64F (SPI interface)
el18gs 8:4220d116f17c 58 //SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS
el18gs 3:9d811414d35e 59 //std::string path = "/sd/ghosts";
el18gs 3:9d811414d35e 60 printf("Checking directory for ghosts: %s\n", path.c_str());
el18gs 3:9d811414d35e 61 DIR *d;
el18gs 3:9d811414d35e 62 struct dirent *p;
el18gs 3:9d811414d35e 63
el18gs 3:9d811414d35e 64 stringvec files;
el18gs 3:9d811414d35e 65
el18gs 3:9d811414d35e 66 d = opendir(path.c_str());
el18gs 3:9d811414d35e 67 if (d != NULL) {
el18gs 3:9d811414d35e 68 while ((p = readdir(d)) != NULL) {
el18gs 3:9d811414d35e 69 files.push_back(p->d_name);
el18gs 3:9d811414d35e 70 }
el18gs 3:9d811414d35e 71 } else {
el18gs 3:9d811414d35e 72 printf("Could not open directory!\n");
el18gs 3:9d811414d35e 73 }
el18gs 3:9d811414d35e 74 closedir(d);
el18gs 3:9d811414d35e 75
el18gs 3:9d811414d35e 76 stringvec correct_files;
el18gs 3:9d811414d35e 77
el18gs 3:9d811414d35e 78 for(int i = 0; i < files.size(); i++){
el18gs 3:9d811414d35e 79 if(hasEnding(files[i], ".ghost")){
el18gs 3:9d811414d35e 80 correct_files.push_back(files[i]);
el18gs 3:9d811414d35e 81 }
el18gs 3:9d811414d35e 82 }
el18gs 3:9d811414d35e 83
el18gs 3:9d811414d35e 84 return correct_files;
el18gs 3:9d811414d35e 85 }
el18gs 3:9d811414d35e 86
el18gs 3:9d811414d35e 87 bool Inventory::hasEnding (std::string const &fullString, std::string const &ending) {
el18gs 3:9d811414d35e 88 if (fullString.length() >= ending.length()) {
el18gs 3:9d811414d35e 89 return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
el18gs 3:9d811414d35e 90 } else {
el18gs 3:9d811414d35e 91 return false;
el18gs 3:9d811414d35e 92 }
el18gs 3:9d811414d35e 93 }
el18gs 3:9d811414d35e 94
el18gs 8:4220d116f17c 95 void Inventory::sell_ghost_by_uid(int uid, SDFileSystem &sd){
el18gs 3:9d811414d35e 96 printf("Inside sell function\n");
el18gs 3:9d811414d35e 97 for(int i = 0; i < _ghosts.size(); i++){
el18gs 3:9d811414d35e 98 if(_ghosts[i].get_uid() == uid){
el18gs 3:9d811414d35e 99 printf("Sale target found\n");
el18gs 8:4220d116f17c 100 int value = _ghosts[i].sell(sd);
el18gs 3:9d811414d35e 101 _ghosts.erase(_ghosts.begin() + i);
el18gs 3:9d811414d35e 102 _gold = _gold + value;
el18gs 3:9d811414d35e 103 break;
el18gs 3:9d811414d35e 104 }
el18gs 3:9d811414d35e 105
el18gs 3:9d811414d35e 106 }
el18gs 11:e89dbdb74df5 107 }
el18gs 11:e89dbdb74df5 108
el18gs 11:e89dbdb74df5 109 void Inventory::display_inventory(SDFileSystem &sd,
el18gs 11:e89dbdb74df5 110 N5110 &lcd,
el18gs 11:e89dbdb74df5 111 Gamepad &pad,
el18gs 11:e89dbdb74df5 112 volatile int &g_buttonX_flag,
el18gs 11:e89dbdb74df5 113 volatile int &g_buttonStart_flag)
el18gs 11:e89dbdb74df5 114 {
el18gs 11:e89dbdb74df5 115 printf("viewing inventory\n");
el18gs 11:e89dbdb74df5 116 int which_ghost_state = 0;
el18gs 11:e89dbdb74df5 117 int which_view_state = 0;
el18gs 11:e89dbdb74df5 118 int new_which_view_state = 0;
el18gs 11:e89dbdb74df5 119
el18gs 11:e89dbdb74df5 120 std::vector<inven_state> ghost_fsm;
el18gs 11:e89dbdb74df5 121
el18gs 11:e89dbdb74df5 122 bool regen_inven = true;
el18gs 11:e89dbdb74df5 123 bool scroll_ghost = false;
el18gs 11:e89dbdb74df5 124 bool update = true;
el18gs 11:e89dbdb74df5 125
el18gs 11:e89dbdb74df5 126 while(1) {
el18gs 11:e89dbdb74df5 127 if(regen_inven) {
el18gs 11:e89dbdb74df5 128 regen(sd);
el18gs 11:e89dbdb74df5 129 ghost_fsm = gen_ghost_fsm();
el18gs 11:e89dbdb74df5 130 regen_inven = false;
el18gs 11:e89dbdb74df5 131 which_ghost_state = 0;
el18gs 11:e89dbdb74df5 132 which_view_state = 0;
el18gs 11:e89dbdb74df5 133 }
el18gs 11:e89dbdb74df5 134
el18gs 11:e89dbdb74df5 135 if(update) {
el18gs 11:e89dbdb74df5 136 update = false;
el18gs 11:e89dbdb74df5 137
el18gs 11:e89dbdb74df5 138 if(scroll_ghost) {
el18gs 11:e89dbdb74df5 139 wait_ms(750);
el18gs 11:e89dbdb74df5 140 scroll_ghost = false;
el18gs 11:e89dbdb74df5 141 }
el18gs 11:e89dbdb74df5 142
el18gs 11:e89dbdb74df5 143
el18gs 11:e89dbdb74df5 144 lcd.clear();
el18gs 11:e89dbdb74df5 145
el18gs 11:e89dbdb74df5 146 lcd.printString("Inventory", 0, 0);
el18gs 11:e89dbdb74df5 147 char buffer [64];
el18gs 11:e89dbdb74df5 148
el18gs 11:e89dbdb74df5 149 if(ghost_fsm.size() == 0) {
el18gs 11:e89dbdb74df5 150 lcd.printString("No ghosts", 0, 1);
el18gs 11:e89dbdb74df5 151 lcd.printString("found, exiting", 0, 2);
el18gs 11:e89dbdb74df5 152 lcd.refresh();
el18gs 11:e89dbdb74df5 153 wait(1);
el18gs 11:e89dbdb74df5 154 return;
el18gs 11:e89dbdb74df5 155 } else {
el18gs 11:e89dbdb74df5 156
el18gs 11:e89dbdb74df5 157 if(which_view_state <= 0) {
el18gs 11:e89dbdb74df5 158 sprintf(buffer, "%s", ghost_fsm[which_ghost_state].type.c_str());
el18gs 11:e89dbdb74df5 159 lcd.printString(buffer, 0, 1 - which_view_state);
el18gs 11:e89dbdb74df5 160 }
el18gs 11:e89dbdb74df5 161
el18gs 11:e89dbdb74df5 162 if(which_view_state <= 1) {
el18gs 11:e89dbdb74df5 163 sprintf(buffer, "Name: %s", ghost_fsm[which_ghost_state].name.c_str());
el18gs 11:e89dbdb74df5 164 lcd.printString(buffer, 0, 2 - which_view_state);
el18gs 11:e89dbdb74df5 165 }
el18gs 11:e89dbdb74df5 166
el18gs 11:e89dbdb74df5 167 if(which_view_state <= 2) {
el18gs 11:e89dbdb74df5 168 sprintf(buffer, "Attack: %d", ghost_fsm[which_ghost_state].attack);
el18gs 11:e89dbdb74df5 169 lcd.printString(buffer, 0, 3 - which_view_state);
el18gs 11:e89dbdb74df5 170 }
el18gs 11:e89dbdb74df5 171
el18gs 11:e89dbdb74df5 172 if(which_view_state <= 3) {
el18gs 11:e89dbdb74df5 173 sprintf(buffer, "Defense: %d", ghost_fsm[which_ghost_state].defense);
el18gs 11:e89dbdb74df5 174 lcd.printString(buffer, 0, 4 - which_view_state);
el18gs 11:e89dbdb74df5 175 }
el18gs 11:e89dbdb74df5 176
el18gs 11:e89dbdb74df5 177 if(which_view_state <= 4) {
el18gs 11:e89dbdb74df5 178 sprintf(buffer, "Level: %d", ghost_fsm[which_ghost_state].level);
el18gs 11:e89dbdb74df5 179 lcd.printString(buffer, 0, 5 - which_view_state);
el18gs 11:e89dbdb74df5 180 }
el18gs 11:e89dbdb74df5 181
el18gs 11:e89dbdb74df5 182 if(which_view_state <= 5) {
el18gs 11:e89dbdb74df5 183 sprintf(buffer, "Value: %d", ghost_fsm[which_ghost_state].value);
el18gs 11:e89dbdb74df5 184 lcd.printString(buffer, 0, 6 - which_view_state);
el18gs 11:e89dbdb74df5 185 }
el18gs 11:e89dbdb74df5 186
el18gs 11:e89dbdb74df5 187 if(which_view_state <= 6) {
el18gs 11:e89dbdb74df5 188 sprintf(buffer, "HP Max: %d", ghost_fsm[which_ghost_state].hp_max);
el18gs 11:e89dbdb74df5 189 lcd.printString(buffer, 0, 7 - which_view_state);
el18gs 11:e89dbdb74df5 190 }
el18gs 11:e89dbdb74df5 191
el18gs 11:e89dbdb74df5 192 if(which_view_state <= 7) {
el18gs 11:e89dbdb74df5 193 sprintf(buffer, "HP: %d", ghost_fsm[which_ghost_state].hp);
el18gs 11:e89dbdb74df5 194 lcd.printString(buffer, 0, 7 - which_view_state);
el18gs 11:e89dbdb74df5 195 }
el18gs 11:e89dbdb74df5 196
el18gs 11:e89dbdb74df5 197 lcd.refresh();
el18gs 11:e89dbdb74df5 198 }
el18gs 11:e89dbdb74df5 199
el18gs 11:e89dbdb74df5 200 }
el18gs 11:e89dbdb74df5 201
el18gs 11:e89dbdb74df5 202 if(pad.read_pot2() <= (double) 0.33) {
el18gs 11:e89dbdb74df5 203 new_which_view_state = 0;
el18gs 11:e89dbdb74df5 204 } else if(pad.read_pot2() <= (double) 0.66) {
el18gs 11:e89dbdb74df5 205 new_which_view_state = 1;
el18gs 11:e89dbdb74df5 206 } else {
el18gs 11:e89dbdb74df5 207 new_which_view_state = 2;
el18gs 11:e89dbdb74df5 208 }
el18gs 11:e89dbdb74df5 209
el18gs 11:e89dbdb74df5 210 if(new_which_view_state != which_view_state) {
el18gs 11:e89dbdb74df5 211 update = true;
el18gs 11:e89dbdb74df5 212 which_view_state = new_which_view_state;
el18gs 11:e89dbdb74df5 213 }
el18gs 11:e89dbdb74df5 214
el18gs 11:e89dbdb74df5 215 if(pad.read_pot1() < (double) 0.33) {
el18gs 11:e89dbdb74df5 216 which_ghost_state = ghost_fsm[which_ghost_state].next[1];
el18gs 11:e89dbdb74df5 217 scroll_ghost = true;
el18gs 11:e89dbdb74df5 218 } else if(pad.read_pot1() > (double) 0.66) {
el18gs 11:e89dbdb74df5 219 which_ghost_state = ghost_fsm[which_ghost_state].next[0];
el18gs 11:e89dbdb74df5 220 scroll_ghost = true;
el18gs 11:e89dbdb74df5 221 }
el18gs 11:e89dbdb74df5 222
el18gs 11:e89dbdb74df5 223 if(scroll_ghost) {
el18gs 11:e89dbdb74df5 224 update = true;
el18gs 11:e89dbdb74df5 225 }
el18gs 11:e89dbdb74df5 226
el18gs 11:e89dbdb74df5 227 if(g_buttonX_flag) {
el18gs 11:e89dbdb74df5 228 printf("X button pressed\n");
el18gs 11:e89dbdb74df5 229 update = true;
el18gs 11:e89dbdb74df5 230 g_buttonX_flag = 0;
el18gs 11:e89dbdb74df5 231 lcd.drawRect(0,16,84,16, FILL_WHITE);
el18gs 11:e89dbdb74df5 232 lcd.printString("Press again",10,2);
el18gs 11:e89dbdb74df5 233 lcd.printString("to sell",20,3);
el18gs 11:e89dbdb74df5 234
el18gs 11:e89dbdb74df5 235 //wait_ms(50);
el18gs 11:e89dbdb74df5 236
el18gs 11:e89dbdb74df5 237 Timer t;
el18gs 11:e89dbdb74df5 238 t.start();
el18gs 11:e89dbdb74df5 239
el18gs 11:e89dbdb74df5 240 g_buttonX_flag = 0;
el18gs 11:e89dbdb74df5 241 bool sell = false;
el18gs 11:e89dbdb74df5 242
el18gs 11:e89dbdb74df5 243 while(t.read() <= 5) {
el18gs 11:e89dbdb74df5 244 int time = t.read();
el18gs 11:e89dbdb74df5 245 bool changed = false;
el18gs 11:e89dbdb74df5 246 if(time == 0) {
el18gs 11:e89dbdb74df5 247 lcd.printString("5",60,3);
el18gs 11:e89dbdb74df5 248 changed = true;
el18gs 11:e89dbdb74df5 249 } else if (time == 1) {
el18gs 11:e89dbdb74df5 250 lcd.printString("4",60,3);
el18gs 11:e89dbdb74df5 251 changed = true;
el18gs 11:e89dbdb74df5 252 } else if (time == 2) {
el18gs 11:e89dbdb74df5 253 lcd.printString("3",60,3);
el18gs 11:e89dbdb74df5 254 changed = true;
el18gs 11:e89dbdb74df5 255 } else if (time == 3) {
el18gs 11:e89dbdb74df5 256 lcd.printString("2",60,3);
el18gs 11:e89dbdb74df5 257 changed = true;
el18gs 11:e89dbdb74df5 258 } else if (time == 4) {
el18gs 11:e89dbdb74df5 259 lcd.printString("1",60,3);
el18gs 11:e89dbdb74df5 260 changed = true;
el18gs 11:e89dbdb74df5 261 } else if (time == 5) {
el18gs 11:e89dbdb74df5 262 lcd.printString("0",60,3);
el18gs 11:e89dbdb74df5 263 changed = true;
el18gs 11:e89dbdb74df5 264 }
el18gs 11:e89dbdb74df5 265
el18gs 11:e89dbdb74df5 266 if(g_buttonX_flag) {
el18gs 11:e89dbdb74df5 267 printf("button X pressed\n");
el18gs 11:e89dbdb74df5 268 g_buttonX_flag = 0;
el18gs 11:e89dbdb74df5 269 //wait_ms(50);
el18gs 11:e89dbdb74df5 270 sell = true;
el18gs 11:e89dbdb74df5 271 }
el18gs 11:e89dbdb74df5 272
el18gs 11:e89dbdb74df5 273 if(changed) {
el18gs 11:e89dbdb74df5 274 lcd.refresh();
el18gs 11:e89dbdb74df5 275 }
el18gs 11:e89dbdb74df5 276
el18gs 11:e89dbdb74df5 277 if(sell) {
el18gs 11:e89dbdb74df5 278 printf("Exiting to sell\n");
el18gs 11:e89dbdb74df5 279 break;
el18gs 11:e89dbdb74df5 280 }
el18gs 11:e89dbdb74df5 281
el18gs 11:e89dbdb74df5 282 }
el18gs 11:e89dbdb74df5 283
el18gs 11:e89dbdb74df5 284 if(sell) {
el18gs 11:e89dbdb74df5 285 printf("Running sell function\n");
el18gs 11:e89dbdb74df5 286 sell_ghost_by_uid(ghost_fsm[which_ghost_state].uid, sd);
el18gs 11:e89dbdb74df5 287 regen_inven = true;
el18gs 11:e89dbdb74df5 288 update = true;
el18gs 11:e89dbdb74df5 289 //wait_ms(500);
el18gs 11:e89dbdb74df5 290 }
el18gs 11:e89dbdb74df5 291
el18gs 11:e89dbdb74df5 292 } else if(g_buttonStart_flag) {
el18gs 11:e89dbdb74df5 293 g_buttonStart_flag = 0;
el18gs 11:e89dbdb74df5 294 return;
el18gs 11:e89dbdb74df5 295 }
el18gs 11:e89dbdb74df5 296
el18gs 11:e89dbdb74df5 297 }
el18gs 11:e89dbdb74df5 298
el18gs 11:e89dbdb74df5 299 }
el18gs 11:e89dbdb74df5 300
el18gs 11:e89dbdb74df5 301 std::vector<inven_state> Inventory::gen_ghost_fsm()
el18gs 11:e89dbdb74df5 302 {
el18gs 11:e89dbdb74df5 303 std::vector<inven_state> ghost_fsm;
el18gs 11:e89dbdb74df5 304
el18gs 11:e89dbdb74df5 305 std::vector<int> uids = list_ghost_uids();
el18gs 11:e89dbdb74df5 306
el18gs 11:e89dbdb74df5 307 sort(uids.begin(), uids.end());
el18gs 11:e89dbdb74df5 308
el18gs 11:e89dbdb74df5 309 for(int i = 0; i < uids.size(); i++) {
el18gs 11:e89dbdb74df5 310 Ghost ghost_temp = get_ghost_by_uid(uids[i]);
el18gs 11:e89dbdb74df5 311 inven_state temp;
el18gs 11:e89dbdb74df5 312 temp.uid = ghost_temp.get_uid();
el18gs 11:e89dbdb74df5 313 temp.name = ghost_temp.get_name();
el18gs 11:e89dbdb74df5 314 temp.type = ghost_temp.get_type_string();
el18gs 11:e89dbdb74df5 315 temp.attack = ghost_temp.get_attack();
el18gs 11:e89dbdb74df5 316 temp.defense = ghost_temp.get_defense();
el18gs 11:e89dbdb74df5 317 temp.level = ghost_temp.get_level();
el18gs 11:e89dbdb74df5 318 temp.xp = ghost_temp.get_xp();
el18gs 11:e89dbdb74df5 319 temp.value = ghost_temp.get_value();
el18gs 11:e89dbdb74df5 320 temp.hp_max = ghost_temp.get_hp_max();
el18gs 11:e89dbdb74df5 321 temp.hp = ghost_temp.get_hp();
el18gs 11:e89dbdb74df5 322
el18gs 11:e89dbdb74df5 323 ghost_fsm.push_back(temp);
el18gs 11:e89dbdb74df5 324 //printf("Added Ghost UID %i to fsm\n", temp.uid);
el18gs 11:e89dbdb74df5 325 printf("%s\n", temp.name.c_str());
el18gs 11:e89dbdb74df5 326 }
el18gs 11:e89dbdb74df5 327
el18gs 11:e89dbdb74df5 328 for(int i = 0; i < ghost_fsm.size(); i++) {
el18gs 11:e89dbdb74df5 329 if (i == 0) {
el18gs 11:e89dbdb74df5 330 int next[2] = {1, ghost_fsm.size() - 1};
el18gs 11:e89dbdb74df5 331 ghost_fsm[i].next[0] = next[0];
el18gs 11:e89dbdb74df5 332 ghost_fsm[i].next[1] = next[1];
el18gs 11:e89dbdb74df5 333 } else if (i == ghost_fsm.size() - 1) {
el18gs 11:e89dbdb74df5 334 int next[2] = {0, ghost_fsm.size() - 2};
el18gs 11:e89dbdb74df5 335 ghost_fsm[i].next[0] = next[0];
el18gs 11:e89dbdb74df5 336 ghost_fsm[i].next[1] = next[1];
el18gs 11:e89dbdb74df5 337 } else {
el18gs 11:e89dbdb74df5 338 int next[2] = {i + 1, i - 1};
el18gs 11:e89dbdb74df5 339 ghost_fsm[i].next[0] = next[0];
el18gs 11:e89dbdb74df5 340 ghost_fsm[i].next[1] = next[1];
el18gs 11:e89dbdb74df5 341 }
el18gs 11:e89dbdb74df5 342 }
el18gs 11:e89dbdb74df5 343
el18gs 11:e89dbdb74df5 344 return ghost_fsm;
el18gs 3:9d811414d35e 345 }