![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
All there but errors need fixing
main.cpp@2:55092965eadd, 2020-05-23 (annotated)
- Committer:
- el18rs
- Date:
- Sat May 23 13:59:06 2020 +0000
- Revision:
- 2:55092965eadd
- Parent:
- 1:35dba0833c7d
- Child:
- 3:522c6f850e91
Title screens and shapes designed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el18rs | 2:55092965eadd | 1 | /* |
eencae | 0:b7f1f47bb26a | 2 | ELEC2645 Embedded Systems Project |
eencae | 0:b7f1f47bb26a | 3 | School of Electronic & Electrical Engineering |
eencae | 0:b7f1f47bb26a | 4 | University of Leeds |
eencae | 0:b7f1f47bb26a | 5 | 2019/20 |
eencae | 0:b7f1f47bb26a | 6 | |
el18rs | 1:35dba0833c7d | 7 | Name: Ruby Smith |
el18rs | 1:35dba0833c7d | 8 | Username: el18rs |
el18rs | 1:35dba0833c7d | 9 | Student ID Number: 201259470 |
el18rs | 1:35dba0833c7d | 10 | Date: 22/05/20 |
eencae | 0:b7f1f47bb26a | 11 | */ |
eencae | 0:b7f1f47bb26a | 12 | |
eencae | 0:b7f1f47bb26a | 13 | // includes |
eencae | 0:b7f1f47bb26a | 14 | #include "mbed.h" |
eencae | 0:b7f1f47bb26a | 15 | #include "Gamepad.h" |
eencae | 0:b7f1f47bb26a | 16 | #include "N5110.h" |
eencae | 0:b7f1f47bb26a | 17 | |
eencae | 0:b7f1f47bb26a | 18 | |
eencae | 0:b7f1f47bb26a | 19 | // objects |
eencae | 0:b7f1f47bb26a | 20 | Gamepad pad; |
eencae | 0:b7f1f47bb26a | 21 | N5110 lcd; |
eencae | 0:b7f1f47bb26a | 22 | |
el18rs | 2:55092965eadd | 23 | |
el18rs | 2:55092965eadd | 24 | int ScreenHeight = 84; |
el18rs | 2:55092965eadd | 25 | int ScreenWidth = 48; |
el18rs | 2:55092965eadd | 26 | string block[7] // store tetromino blocks as a w-string |
el18rs | 2:55092965eadd | 27 | |
el18rs | 2:55092965eadd | 28 | |
el18rs | 2:55092965eadd | 29 | |
el18rs | 2:55092965eadd | 30 | |
el18rs | 2:55092965eadd | 31 | /* int Rotate(int px, int py, int r) |
el18rs | 2:55092965eadd | 32 | { |
el18rs | 2:55092965eadd | 33 | int pi = 0; |
el18rs | 2:55092965eadd | 34 | switch (r % 4); |
el18rs | 2:55092965eadd | 35 | { |
el18rs | 2:55092965eadd | 36 | case 0: pi = py * 4 + px; // shape width = 4 |
el18rs | 2:55092965eadd | 37 | break; |
el18rs | 2:55092965eadd | 38 | |
el18rs | 2:55092965eadd | 39 | case 1: pi = 12 + py - (px * 4); // rotates the shape by 90 degrees |
el18rs | 2:55092965eadd | 40 | break; |
el18rs | 2:55092965eadd | 41 | |
el18rs | 2:55092965eadd | 42 | case 2: pi = 15 - (py * 4) - px; // rotates the shape by 180 degrees |
el18rs | 2:55092965eadd | 43 | break; |
el18rs | 2:55092965eadd | 44 | |
el18rs | 2:55092965eadd | 45 | case 3: pi = 3 - py + (px * 4); // rotates the shape by 270 degrees |
el18rs | 2:55092965eadd | 46 | break; |
el18rs | 2:55092965eadd | 47 | |
el18rs | 2:55092965eadd | 48 | } |
el18rs | 2:55092965eadd | 49 | return pi; |
el18rs | 2:55092965eadd | 50 | } |
el18rs | 2:55092965eadd | 51 | */ |
el18rs | 2:55092965eadd | 52 | |
el18rs | 2:55092965eadd | 53 | void title() |
el18rs | 2:55092965eadd | 54 | { |
el18rs | 2:55092965eadd | 55 | using namespace std: |
el18rs | 2:55092965eadd | 56 | |
el18rs | 2:55092965eadd | 57 | system("cls"); |
el18rs | 2:55092965eadd | 58 | |
el18rs | 2:55092965eadd | 59 | cout << "--------------------------------------------------------\n"; |
el18rs | 2:55092965eadd | 60 | |
el18rs | 2:55092965eadd | 61 | cout << "------- ------- ------- ------- --- -----\n"; |
el18rs | 2:55092965eadd | 62 | cout << " | | | | | | | ||n"; |
el18rs | 2:55092965eadd | 63 | cout << " | | | | | | |\n"; |
el18rs | 2:55092965eadd | 64 | cout << " | ----- | ------- | -----\n"; |
el18rs | 2:55092965eadd | 65 | cout << " | | | | | | |\n"; |
el18rs | 2:55092965eadd | 66 | cout << " | | | | | | | |\n"; |
el18rs | 2:55092965eadd | 67 | cout << " | ------- | | | --- -----\n"; |
el18rs | 2:55092965eadd | 68 | |
el18rs | 2:55092965eadd | 69 | cout << "\t<menu>\n"; |
el18rs | 2:55092965eadd | 70 | cout << "\t1: Start Game\n\t2: Quit\n\n"; |
el18rs | 2:55092965eadd | 71 | |
el18rs | 2:55092965eadd | 72 | cout << "---------------------------------------------------------\n"; |
el18rs | 2:55092965eadd | 73 | |
el18rs | 2:55092965eadd | 74 | } |
el18rs | 2:55092965eadd | 75 | |
el18rs | 2:55092965eadd | 76 | int GameOver() |
el18rs | 2:55092965eadd | 77 | { |
el18rs | 2:55092965eadd | 78 | using namespace std; |
el18rs | 2:55092965eadd | 79 | |
el18rs | 2:55092965eadd | 80 | char a; |
el18rs | 2:55092965eadd | 81 | cout << " ----- - - - ------- ------- - - -------- ------\n"; |
el18rs | 2:55092965eadd | 82 | cout << "| | | | || || | | | | | | | |\n"; |
el18rs | 2:55092965eadd | 83 | cout << "| | | | | | | | | | | | | | |\n"; |
el18rs | 2:55092965eadd | 84 | cout << "| ---- | | | | | ----- | | | | ------ ------\n"; |
el18rs | 2:55092965eadd | 85 | cout << "| | |-----| | | | | | | | | | |\n"; |
el18rs | 2:55092965eadd | 86 | cout << "| | | | | | | | | | | | | |\n"; |
el18rs | 2:55092965eadd | 87 | cout << " ----- | | | | ------- ------- | -------- | |\n"; |
el18rs | 2:55092965eadd | 88 | cout << "\n\nPress any key\n"; |
el18rs | 2:55092965eadd | 89 | |
el18rs | 2:55092965eadd | 90 | return 0; |
el18rs | 2:55092965eadd | 91 | } |
eencae | 0:b7f1f47bb26a | 92 | int main() |
eencae | 0:b7f1f47bb26a | 93 | { |
eencae | 0:b7f1f47bb26a | 94 | |
el18rs | 2:55092965eadd | 95 | |
eencae | 0:b7f1f47bb26a | 96 | } |
eencae | 0:b7f1f47bb26a | 97 |