Error as described in MBs email to MS
Dependencies: SDFileSystem app epson mbed msp430 pl tests
hangman.h@0:c643d398cdb6, 2018-01-11 (annotated)
- Committer:
- marcbax
- Date:
- Thu Jan 11 13:42:27 2018 +0000
- Revision:
- 0:c643d398cdb6
Marc Bax version 180111. It hangs on the WritePartImage in the RedrawAlphabet routine in hangman.cpp. Within that call it does execute Ypos(), but not Xpos().
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcbax | 0:c643d398cdb6 | 1 | // |
marcbax | 0:c643d398cdb6 | 2 | // Filename: hangman.h |
marcbax | 0:c643d398cdb6 | 3 | // |
marcbax | 0:c643d398cdb6 | 4 | // Class for the hangman game played on pagesensor and pageflexenable. |
marcbax | 0:c643d398cdb6 | 5 | // |
marcbax | 0:c643d398cdb6 | 6 | |
marcbax | 0:c643d398cdb6 | 7 | // include guards |
marcbax | 0:c643d398cdb6 | 8 | |
marcbax | 0:c643d398cdb6 | 9 | #include <memory> |
marcbax | 0:c643d398cdb6 | 10 | #include "mbed.h" |
marcbax | 0:c643d398cdb6 | 11 | #include "log.h" |
marcbax | 0:c643d398cdb6 | 12 | #include "eink.h" |
marcbax | 0:c643d398cdb6 | 13 | //include more files, e.g. where eink display is changed, and to read from SD card |
marcbax | 0:c643d398cdb6 | 14 | |
marcbax | 0:c643d398cdb6 | 15 | namespace Flexbook |
marcbax | 0:c643d398cdb6 | 16 | { |
marcbax | 0:c643d398cdb6 | 17 | |
marcbax | 0:c643d398cdb6 | 18 | class HangmanGame |
marcbax | 0:c643d398cdb6 | 19 | { |
marcbax | 0:c643d398cdb6 | 20 | public: |
marcbax | 0:c643d398cdb6 | 21 | // Constructor needs to be explicit. |
marcbax | 0:c643d398cdb6 | 22 | explicit HangmanGame(); |
marcbax | 0:c643d398cdb6 | 23 | |
marcbax | 0:c643d398cdb6 | 24 | // Destructor |
marcbax | 0:c643d398cdb6 | 25 | ~HangmanGame(); |
marcbax | 0:c643d398cdb6 | 26 | |
marcbax | 0:c643d398cdb6 | 27 | // Routine to determine how to move the cursor after electrode touch |
marcbax | 0:c643d398cdb6 | 28 | char MoveCursor(const bool alphabet[27],const char buttonnumber, char oldpos); |
marcbax | 0:c643d398cdb6 | 29 | |
marcbax | 0:c643d398cdb6 | 30 | // Routine to run after confirming selection of a position in the alphabet matrix |
marcbax | 0:c643d398cdb6 | 31 | bool SelectLetter(const char letterpos, const char word2guess[14], const char wordlength, char* guessed[14], char hangmanstate); |
marcbax | 0:c643d398cdb6 | 32 | |
marcbax | 0:c643d398cdb6 | 33 | // Game status indicator |
marcbax | 0:c643d398cdb6 | 34 | bool finished; |
marcbax | 0:c643d398cdb6 | 35 | // Alphabet matrix is 3 rows with 9 columns. A..M,?,N..Z |
marcbax | 0:c643d398cdb6 | 36 | // Currently selected and previous position on the alphabet matrix |
marcbax | 0:c643d398cdb6 | 37 | char currentpos; |
marcbax | 0:c643d398cdb6 | 38 | char oldpos; |
marcbax | 0:c643d398cdb6 | 39 | |
marcbax | 0:c643d398cdb6 | 40 | // Status indicator for each letter on the alphabet matrix, already used or not? |
marcbax | 0:c643d398cdb6 | 41 | bool alphabet[27]; |
marcbax | 0:c643d398cdb6 | 42 | |
marcbax | 0:c643d398cdb6 | 43 | private: |
marcbax | 0:c643d398cdb6 | 44 | // Word to be guessed, word guessed so far |
marcbax | 0:c643d398cdb6 | 45 | char word[14]; |
marcbax | 0:c643d398cdb6 | 46 | char guessed[14]; |
marcbax | 0:c643d398cdb6 | 47 | |
marcbax | 0:c643d398cdb6 | 48 | // Number of letters in word to be guessed (8-14) |
marcbax | 0:c643d398cdb6 | 49 | char wordlength; |
marcbax | 0:c643d398cdb6 | 50 | |
marcbax | 0:c643d398cdb6 | 51 | // Number of wrong guesses, equals number of elements of hanging man drawn |
marcbax | 0:c643d398cdb6 | 52 | char hangstage; |
marcbax | 0:c643d398cdb6 | 53 | |
marcbax | 0:c643d398cdb6 | 54 | // Function returning x-position on the display of "letterpos" in alphabet matrix |
marcbax | 0:c643d398cdb6 | 55 | int Xpos(const char letterpos); |
marcbax | 0:c643d398cdb6 | 56 | |
marcbax | 0:c643d398cdb6 | 57 | // Function returning y-position on the display of "letterpos" in alphabet matrix |
marcbax | 0:c643d398cdb6 | 58 | int Ypos(const char letterpos); |
marcbax | 0:c643d398cdb6 | 59 | |
marcbax | 0:c643d398cdb6 | 60 | // Routine to redraw the hanging man |
marcbax | 0:c643d398cdb6 | 61 | void DrawMan(const char manstate); |
marcbax | 0:c643d398cdb6 | 62 | |
marcbax | 0:c643d398cdb6 | 63 | // Routine to redraw the alphabet matrix after a cursor move |
marcbax | 0:c643d398cdb6 | 64 | void RedrawAlphabet(const char newpos, const char oldpos, const bool alphabet[27]); |
marcbax | 0:c643d398cdb6 | 65 | |
marcbax | 0:c643d398cdb6 | 66 | // Routine to (re)draw the current word guess, using question marks for unknown characters |
marcbax | 0:c643d398cdb6 | 67 | void DrawWord(const char guessed[14], const char wordlength); |
marcbax | 0:c643d398cdb6 | 68 | |
marcbax | 0:c643d398cdb6 | 69 | // Routine to pick new word to be guessed |
marcbax | 0:c643d398cdb6 | 70 | char ReturnWord(char &word2guess); |
marcbax | 0:c643d398cdb6 | 71 | |
marcbax | 0:c643d398cdb6 | 72 | // routine to count number of words in hangdict file |
marcbax | 0:c643d398cdb6 | 73 | int NumDictWords (); |
marcbax | 0:c643d398cdb6 | 74 | }; |
marcbax | 0:c643d398cdb6 | 75 | |
marcbax | 0:c643d398cdb6 | 76 | } |