yr
play.cpp@0:de980644a94b, 2021-03-30 (annotated)
- Committer:
- tangguangmin
- Date:
- Tue Mar 30 14:11:21 2021 +0000
- Revision:
- 0:de980644a94b
yrt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tangguangmin | 0:de980644a94b | 1 | #include "play.h" |
tangguangmin | 0:de980644a94b | 2 | |
tangguangmin | 0:de980644a94b | 3 | void store_score() { |
tangguangmin | 0:de980644a94b | 4 | |
tangguangmin | 0:de980644a94b | 5 | if(score > best_score) { |
tangguangmin | 0:de980644a94b | 6 | |
tangguangmin | 0:de980644a94b | 7 | best_score = score; |
tangguangmin | 0:de980644a94b | 8 | |
tangguangmin | 0:de980644a94b | 9 | } |
tangguangmin | 0:de980644a94b | 10 | |
tangguangmin | 0:de980644a94b | 11 | } |
tangguangmin | 0:de980644a94b | 12 | |
tangguangmin | 0:de980644a94b | 13 | void get_start(N5110 &lcd) { |
tangguangmin | 0:de980644a94b | 14 | |
tangguangmin | 0:de980644a94b | 15 | lcd.clear(); |
tangguangmin | 0:de980644a94b | 16 | |
tangguangmin | 0:de980644a94b | 17 | lcd.printString("LET'S START!",1,2); |
tangguangmin | 0:de980644a94b | 18 | |
tangguangmin | 0:de980644a94b | 19 | lcd.refresh(); |
tangguangmin | 0:de980644a94b | 20 | |
tangguangmin | 0:de980644a94b | 21 | thread_sleep_for(100); |
tangguangmin | 0:de980644a94b | 22 | |
tangguangmin | 0:de980644a94b | 23 | // **************0 |
tangguangmin | 0:de980644a94b | 24 | |
tangguangmin | 0:de980644a94b | 25 | lcd.clear(); |
tangguangmin | 0:de980644a94b | 26 | |
tangguangmin | 0:de980644a94b | 27 | lcd.printString("3",40,2); |
tangguangmin | 0:de980644a94b | 28 | |
tangguangmin | 0:de980644a94b | 29 | lcd.refresh(); |
tangguangmin | 0:de980644a94b | 30 | |
tangguangmin | 0:de980644a94b | 31 | thread_sleep_for(100); |
tangguangmin | 0:de980644a94b | 32 | |
tangguangmin | 0:de980644a94b | 33 | // **************3 |
tangguangmin | 0:de980644a94b | 34 | |
tangguangmin | 0:de980644a94b | 35 | lcd.clear(); |
tangguangmin | 0:de980644a94b | 36 | |
tangguangmin | 0:de980644a94b | 37 | lcd.printString("2",40,2); |
tangguangmin | 0:de980644a94b | 38 | |
tangguangmin | 0:de980644a94b | 39 | lcd.refresh(); |
tangguangmin | 0:de980644a94b | 40 | |
tangguangmin | 0:de980644a94b | 41 | thread_sleep_for(100); |
tangguangmin | 0:de980644a94b | 42 | |
tangguangmin | 0:de980644a94b | 43 | // **************2 |
tangguangmin | 0:de980644a94b | 44 | |
tangguangmin | 0:de980644a94b | 45 | lcd.clear(); |
tangguangmin | 0:de980644a94b | 46 | |
tangguangmin | 0:de980644a94b | 47 | lcd.printString("1",40,2); |
tangguangmin | 0:de980644a94b | 48 | |
tangguangmin | 0:de980644a94b | 49 | lcd.refresh(); |
tangguangmin | 0:de980644a94b | 50 | |
tangguangmin | 0:de980644a94b | 51 | thread_sleep_for(100); |
tangguangmin | 0:de980644a94b | 52 | |
tangguangmin | 0:de980644a94b | 53 | // **************1 |
tangguangmin | 0:de980644a94b | 54 | |
tangguangmin | 0:de980644a94b | 55 | } |
tangguangmin | 0:de980644a94b | 56 | |
tangguangmin | 0:de980644a94b | 57 | void show_score(N5110 &lcd, DigitalIn &button_A) { |
tangguangmin | 0:de980644a94b | 58 | |
tangguangmin | 0:de980644a94b | 59 | lcd.clear(); |
tangguangmin | 0:de980644a94b | 60 | |
tangguangmin | 0:de980644a94b | 61 | lcd.printString("BEST SCORE",12,1); |
tangguangmin | 0:de980644a94b | 62 | |
tangguangmin | 0:de980644a94b | 63 | char buffer[14]; |
tangguangmin | 0:de980644a94b | 64 | sprintf(buffer,"%d",best_score); |
tangguangmin | 0:de980644a94b | 65 | lcd.printString(buffer,12,3); |
tangguangmin | 0:de980644a94b | 66 | |
tangguangmin | 0:de980644a94b | 67 | lcd.printString("Press A BACK",0,5); |
tangguangmin | 0:de980644a94b | 68 | |
tangguangmin | 0:de980644a94b | 69 | lcd.refresh(); |
tangguangmin | 0:de980644a94b | 70 | |
tangguangmin | 0:de980644a94b | 71 | while(1) { |
tangguangmin | 0:de980644a94b | 72 | |
tangguangmin | 0:de980644a94b | 73 | if(button_A.read() == 1) { |
tangguangmin | 0:de980644a94b | 74 | choice(); |
tangguangmin | 0:de980644a94b | 75 | } |
tangguangmin | 0:de980644a94b | 76 | } |
tangguangmin | 0:de980644a94b | 77 | |
tangguangmin | 0:de980644a94b | 78 | } |
tangguangmin | 0:de980644a94b | 79 | |
tangguangmin | 0:de980644a94b | 80 | // |
tangguangmin | 0:de980644a94b | 81 | //InGame::InGame() {} |
tangguangmin | 0:de980644a94b | 82 | // |
tangguangmin | 0:de980644a94b | 83 | //void InGame::draw_background1(N5110 &lcd) { |
tangguangmin | 0:de980644a94b | 84 | // |
tangguangmin | 0:de980644a94b | 85 | // lcd.clear(); |
tangguangmin | 0:de980644a94b | 86 | // |
tangguangmin | 0:de980644a94b | 87 | // lcd.drawLine(0,8,84,7,1); |
tangguangmin | 0:de980644a94b | 88 | // lcd.drawRect(23,26,26,4,FILL_BLACK); |
tangguangmin | 0:de980644a94b | 89 | // lcd.drawRect(0,44,84,4,FILL_BLACK); |
tangguangmin | 0:de980644a94b | 90 | // lcd.drawRect(28,40,26,4,FILL_BLACK); |
tangguangmin | 0:de980644a94b | 91 | // lcd.drawRect(67,22,17,11,FILL_TRANSPARENT); |
tangguangmin | 0:de980644a94b | 92 | // |
tangguangmin | 0:de980644a94b | 93 | // lcd.refresh(); |
tangguangmin | 0:de980644a94b | 94 | // |
tangguangmin | 0:de980644a94b | 95 | //} |
tangguangmin | 0:de980644a94b | 96 | |
tangguangmin | 0:de980644a94b | 97 | |
tangguangmin | 0:de980644a94b | 98 | |
tangguangmin | 0:de980644a94b | 99 | |
tangguangmin | 0:de980644a94b | 100 |