![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Game codes for Pokemon Academy Yiu Fai Kwok - 201198802 I have read the University Regulations on Plagiarism and state that the work covered by this declaration is my own and does not contain any unacknowledged work from other sources.
Dependencies: mbed FXOS8700CQ mbed-rtos
Game_three/Book/Book.cpp@34:3ddfaa217eca, 2019-05-09 (annotated)
- Committer:
- yfkwok
- Date:
- Thu May 09 00:41:05 2019 +0000
- Revision:
- 34:3ddfaa217eca
- Parent:
- 28:a6726a3f8e6d
09/05/2019 - Last commit before submission
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yfkwok | 21:704d938acf5d | 1 | #include "Book.h" |
yfkwok | 21:704d938acf5d | 2 | |
yfkwok | 21:704d938acf5d | 3 | Book::Book() |
yfkwok | 21:704d938acf5d | 4 | { |
yfkwok | 21:704d938acf5d | 5 | |
yfkwok | 21:704d938acf5d | 6 | } |
yfkwok | 21:704d938acf5d | 7 | |
yfkwok | 21:704d938acf5d | 8 | Book::~Book() |
yfkwok | 21:704d938acf5d | 9 | { |
yfkwok | 21:704d938acf5d | 10 | |
yfkwok | 21:704d938acf5d | 11 | } |
yfkwok | 21:704d938acf5d | 12 | |
yfkwok | 21:704d938acf5d | 13 | void Book::init(int position) |
yfkwok | 21:704d938acf5d | 14 | { |
yfkwok | 21:704d938acf5d | 15 | // 4 possibilities. Get random modulo and set initial position accordingly |
yfkwok | 28:a6726a3f8e6d | 16 | if (position == 3) { |
yfkwok | 28:a6726a3f8e6d | 17 | _x = 35; |
yfkwok | 28:a6726a3f8e6d | 18 | _y = 0; |
yfkwok | 28:a6726a3f8e6d | 19 | } else if (position == 2) { |
yfkwok | 28:a6726a3f8e6d | 20 | _x = 0; |
yfkwok | 28:a6726a3f8e6d | 21 | _y = 17; |
yfkwok | 21:704d938acf5d | 22 | } else if (position == 1) { |
yfkwok | 28:a6726a3f8e6d | 23 | _x = 70; |
yfkwok | 28:a6726a3f8e6d | 24 | _y = 17; |
yfkwok | 28:a6726a3f8e6d | 25 | } else if (position == 0) { |
yfkwok | 28:a6726a3f8e6d | 26 | _x = 35; |
yfkwok | 21:704d938acf5d | 27 | _y = 35; |
yfkwok | 21:704d938acf5d | 28 | } |
yfkwok | 21:704d938acf5d | 29 | } |
yfkwok | 21:704d938acf5d | 30 | |
yfkwok | 21:704d938acf5d | 31 | void Book::draw(N5110 &lcd) |
yfkwok | 21:704d938acf5d | 32 | { |
yfkwok | 21:704d938acf5d | 33 | int Book_data [14][14] = { |
yfkwok | 27:4bcdfb212467 | 34 | {0,0,0,0,0,0,0,0,0,1,0,0,0,0}, |
yfkwok | 27:4bcdfb212467 | 35 | {0,0,0,0,0,0,1,1,1,1,1,0,0,0}, |
yfkwok | 27:4bcdfb212467 | 36 | {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, |
yfkwok | 27:4bcdfb212467 | 37 | {1,1,1,1,1,1,1,1,1,1,1,1,0,0}, |
yfkwok | 27:4bcdfb212467 | 38 | {1,1,1,1,1,1,1,1,1,1,1,1,0,0}, |
yfkwok | 27:4bcdfb212467 | 39 | {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, |
yfkwok | 27:4bcdfb212467 | 40 | {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, |
yfkwok | 27:4bcdfb212467 | 41 | {0,0,1,1,1,1,1,1,1,1,1,1,1,1}, |
yfkwok | 27:4bcdfb212467 | 42 | {0,0,1,1,1,1,1,1,1,1,1,1,1,1}, |
yfkwok | 27:4bcdfb212467 | 43 | {0,0,0,1,1,1,1,1,1,1,1,1,1,0}, |
yfkwok | 27:4bcdfb212467 | 44 | {0,0,0,1,1,1,1,1,1,1,0,0,0,0}, |
yfkwok | 27:4bcdfb212467 | 45 | {0,0,0,0,1,1,1,0,0,0,0,1,1,1}, |
yfkwok | 27:4bcdfb212467 | 46 | {0,0,0,0,1,0,0,0,1,1,1,0,0,0}, |
yfkwok | 27:4bcdfb212467 | 47 | {0,0,0,0,0,1,1,1,0,0,0,0,0,0}, |
yfkwok | 21:704d938acf5d | 48 | }; |
yfkwok | 21:704d938acf5d | 49 | // Sprite for the book |
yfkwok | 21:704d938acf5d | 50 | lcd.drawSprite(_x, _y, 14, 14, (int*)Book_data); |
yfkwok | 21:704d938acf5d | 51 | } |
yfkwok | 21:704d938acf5d | 52 | |
yfkwok | 21:704d938acf5d | 53 | Vector2D Book::get_pos() |
yfkwok | 21:704d938acf5d | 54 | { |
yfkwok | 21:704d938acf5d | 55 | Vector2D p = {_x,_y}; |
yfkwok | 21:704d938acf5d | 56 | return p; |
yfkwok | 21:704d938acf5d | 57 | } |
yfkwok | 21:704d938acf5d | 58 | |
yfkwok | 21:704d938acf5d | 59 | void Book::set_pos(Vector2D p) |
yfkwok | 21:704d938acf5d | 60 | { |
yfkwok | 21:704d938acf5d | 61 | _x = p.x; |
yfkwok | 21:704d938acf5d | 62 | _y = p.y; |
yfkwok | 21:704d938acf5d | 63 | } |