Game entry for the Game Programming Contest sponsored by OutrageousCircuits.com (RETRO Game Console)
Fork of Official_RETRO by
Game.h@4:2d41b942a823, 2015-03-01 (annotated)
- Committer:
- Rogerup
- Date:
- Sun Mar 01 09:34:29 2015 +0000
- Revision:
- 4:2d41b942a823
- Parent:
- 2:6ab46f2e851a
Game Entry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
john_ghielec | 1:cd8a3926f263 | 1 | #include "mbed.h" |
john_ghielec | 1:cd8a3926f263 | 2 | |
john_ghielec | 1:cd8a3926f263 | 3 | #include "DisplayN18.h" |
john_ghielec | 1:cd8a3926f263 | 4 | |
john_ghielec | 1:cd8a3926f263 | 5 | #pragma once |
john_ghielec | 1:cd8a3926f263 | 6 | |
Rogerup | 4:2d41b942a823 | 7 | #define RED 0x1F00 |
Rogerup | 4:2d41b942a823 | 8 | #define GREEN 0xE007 |
Rogerup | 4:2d41b942a823 | 9 | #define BLUE 0x00F8 |
Rogerup | 4:2d41b942a823 | 10 | |
Rogerup | 4:2d41b942a823 | 11 | #define YELLOW 0xFF07 |
Rogerup | 4:2d41b942a823 | 12 | #define CYAN 0xE0FF |
Rogerup | 4:2d41b942a823 | 13 | #define MAGENT 0x1FF8 |
Rogerup | 4:2d41b942a823 | 14 | |
Rogerup | 4:2d41b942a823 | 15 | #define WHITE 0xFFFF |
Rogerup | 4:2d41b942a823 | 16 | #define LGRAY 0x18C6 |
Rogerup | 4:2d41b942a823 | 17 | #define GRAY 0x1084 |
Rogerup | 4:2d41b942a823 | 18 | #define DGRAY 0x0842 |
Rogerup | 4:2d41b942a823 | 19 | #define BLACK 0x0000 |
Rogerup | 4:2d41b942a823 | 20 | |
Rogerup | 4:2d41b942a823 | 21 | #define TABW 16 |
Rogerup | 4:2d41b942a823 | 22 | #define TABH 14 |
Rogerup | 4:2d41b942a823 | 23 | |
Rogerup | 4:2d41b942a823 | 24 | #define WALL 0x01 |
Rogerup | 4:2d41b942a823 | 25 | #define BONG 0x02 |
Rogerup | 4:2d41b942a823 | 26 | #define FREE 0x03 |
Rogerup | 4:2d41b942a823 | 27 | #define MARK 0x04 |
Rogerup | 4:2d41b942a823 | 28 | #define MAR1 0x05 |
Rogerup | 4:2d41b942a823 | 29 | #define BALL 0x10 |
Rogerup | 4:2d41b942a823 | 30 | #define BAL1 0x20 |
Rogerup | 4:2d41b942a823 | 31 | |
Rogerup | 4:2d41b942a823 | 32 | #define TITY 0 |
Rogerup | 4:2d41b942a823 | 33 | #define LEVY 24 |
Rogerup | 4:2d41b942a823 | 34 | #define BESY 48 |
Rogerup | 4:2d41b942a823 | 35 | #define YOUY 72 |
Rogerup | 4:2d41b942a823 | 36 | #define MOVY 96 |
Rogerup | 4:2d41b942a823 | 37 | |
Rogerup | 4:2d41b942a823 | 38 | #define L_INTRO 0 |
Rogerup | 4:2d41b942a823 | 39 | #define L_START (L_INTRO + 1) // 1 1.0 9 |
Rogerup | 4:2d41b942a823 | 40 | #define L_FIRSTBAM (L_START + 1) // 2 1.0 9 |
Rogerup | 4:2d41b942a823 | 41 | #define L_ZIGZAG (L_FIRSTBAM + 1) // 3 1.0 11 |
Rogerup | 4:2d41b942a823 | 42 | #define L_FIRSTPOS (L_ZIGZAG + 1) // 4 1.0 13 |
Rogerup | 4:2d41b942a823 | 43 | #define L_MANYBOX (L_FIRSTPOS + 1) // 41 1.0 9 |
Rogerup | 4:2d41b942a823 | 44 | //#define L_NOBACK (L_MANYBOX + 1) // 470 1.8 26 |
Rogerup | 4:2d41b942a823 | 45 | #define L_FEWMOVES (L_MANYBOX + 1) // 44 2.1 18 |
Rogerup | 4:2d41b942a823 | 46 | #define L_BAMPOS (L_FEWMOVES + 1) // 6 5.7 15 |
Rogerup | 4:2d41b942a823 | 47 | #define L_LABYRINTH (L_BAMPOS + 1) // 59 2.5 98 |
Rogerup | 4:2d41b942a823 | 48 | #define L_FACEFOUR (L_LABYRINTH + 1) // 69 3.1 50 |
Rogerup | 4:2d41b942a823 | 49 | #define L_MANYBAM (L_FACEFOUR + 1) // 101 3.2 28 |
Rogerup | 4:2d41b942a823 | 50 | #define L_CHANGEPOS (L_MANYBAM + 1) // 8 3.7 22 |
Rogerup | 4:2d41b942a823 | 51 | #define L_ONLYTWO (L_CHANGEPOS + 1) // 73 3.9 50 |
Rogerup | 4:2d41b942a823 | 52 | #define L_NUMBLOCKS (L_ONLYTWO + 1) // 94 4.0 54 |
Rogerup | 4:2d41b942a823 | 53 | #define L_SEPARATED (L_NUMBLOCKS + 1) // 10 4.6 17 |
Rogerup | 4:2d41b942a823 | 54 | #define L_NUMBERMIX (L_SEPARATED + 1) // 79 4.7 47 |
Rogerup | 4:2d41b942a823 | 55 | #define L_STEPS (L_NUMBERMIX + 1) // 381 5.0 48 |
Rogerup | 4:2d41b942a823 | 56 | #define L_CHESS (L_STEPS + 1) // 25 5.7 46 |
Rogerup | 4:2d41b942a823 | 57 | #define L_HAMMER (L_CHESS + 1) // 464 6.3 50 |
Rogerup | 4:2d41b942a823 | 58 | #define L_CAREMOVES (L_HAMMER + 1) // 128 6.5 248 |
Rogerup | 4:2d41b942a823 | 59 | #define L_FLUTE (L_CAREMOVES + 1) // 126 6.9 118 |
Rogerup | 4:2d41b942a823 | 60 | #define L_CROSS (L_FLUTE + 1) // 136 7.0 70 |
Rogerup | 4:2d41b942a823 | 61 | #define L_DIAGONAL (L_CROSS + 1) // 445 7.1 78 |
Rogerup | 4:2d41b942a823 | 62 | #define L_LASTSIX (L_DIAGONAL + 1) // 239 7.2 119 |
Rogerup | 4:2d41b942a823 | 63 | #define L_FORTYTWO (L_LASTSIX + 1) // 106 4.9 42 |
Rogerup | 4:2d41b942a823 | 64 | #define L_ALEXAND (L_FORTYTWO + 1) // 7 7.4 23 |
Rogerup | 4:2d41b942a823 | 65 | #define L_CALCULATE (L_ALEXAND + 1) // 123 7.5 76 |
Rogerup | 4:2d41b942a823 | 66 | #define L_MANYBALLS (L_CALCULATE + 1) // 9 8.0 26 |
Rogerup | 4:2d41b942a823 | 67 | #define L_SPIDERBAM (L_MANYBALLS + 1) // 110 8.1 65 |
Rogerup | 4:2d41b942a823 | 68 | #define L_CONFUSE (L_SPIDERBAM + 1) // 135 8.5 37 |
Rogerup | 4:2d41b942a823 | 69 | #define L_PRECISE (L_CONFUSE + 1) // 142 8.8 61 (nao verificado) |
Rogerup | 4:2d41b942a823 | 70 | #define L_ORDER (L_PRECISE + 1) // 113 9.8 50 |
Rogerup | 4:2d41b942a823 | 71 | #define L_GRANDMAST (L_ORDER + 1) // 143 10 299 |
Rogerup | 4:2d41b942a823 | 72 | #define L_LAST (L_GRANDMAST + 0) // LAST LEVEL |
Rogerup | 4:2d41b942a823 | 73 | |
Rogerup | 4:2d41b942a823 | 74 | class Game |
Rogerup | 4:2d41b942a823 | 75 | { |
john_ghielec | 2:6ab46f2e851a | 76 | static const char I2C_ADDR = 0x1C << 1; |
Rogerup | 4:2d41b942a823 | 77 | |
Rogerup | 4:2d41b942a823 | 78 | int tickCounter, tickWin, bamTicksLeft; |
Rogerup | 4:2d41b942a823 | 79 | char lastKey; |
john_ghielec | 1:cd8a3926f263 | 80 | |
Rogerup | 4:2d41b942a823 | 81 | unsigned char table[14][16]; |
Rogerup | 4:2d41b942a823 | 82 | unsigned short change[14]; |
Rogerup | 4:2d41b942a823 | 83 | unsigned short piece[7][7]; |
Rogerup | 4:2d41b942a823 | 84 | int best, moves; |
Rogerup | 4:2d41b942a823 | 85 | short your[32]; |
Rogerup | 4:2d41b942a823 | 86 | int level, oldLevel; |
Rogerup | 4:2d41b942a823 | 87 | bool levelCompleted; |
Rogerup | 4:2d41b942a823 | 88 | unsigned char bamX, bamY; |
john_ghielec | 2:6ab46f2e851a | 89 | |
Rogerup | 4:2d41b942a823 | 90 | DigitalIn left, right, down, up, square, circle; |
Rogerup | 4:2d41b942a823 | 91 | DigitalOut led1, led2; |
john_ghielec | 1:cd8a3926f263 | 92 | PwmOut pwm; |
john_ghielec | 1:cd8a3926f263 | 93 | AnalogIn ain; |
john_ghielec | 1:cd8a3926f263 | 94 | I2C i2c; |
john_ghielec | 1:cd8a3926f263 | 95 | DisplayN18 disp; |
john_ghielec | 1:cd8a3926f263 | 96 | |
Rogerup | 4:2d41b942a823 | 97 | void showNumber(int y, int val); |
john_ghielec | 2:6ab46f2e851a | 98 | |
john_ghielec | 1:cd8a3926f263 | 99 | void initialize(); |
Rogerup | 4:2d41b942a823 | 100 | |
john_ghielec | 2:6ab46f2e851a | 101 | void checkButtons(); |
Rogerup | 4:2d41b942a823 | 102 | |
Rogerup | 4:2d41b942a823 | 103 | void playBam(); |
Rogerup | 4:2d41b942a823 | 104 | void playSound(); |
Rogerup | 4:2d41b942a823 | 105 | |
Rogerup | 4:2d41b942a823 | 106 | void initTable(); |
Rogerup | 4:2d41b942a823 | 107 | void fillTable(char i0, char j0, char h, char w, unsigned char v); |
Rogerup | 4:2d41b942a823 | 108 | void fillTableV(unsigned char v, ...); |
Rogerup | 4:2d41b942a823 | 109 | void showTable(); |
Rogerup | 4:2d41b942a823 | 110 | void moveTable(int di, int dj, int i0, int i2, int j0, int j2); |
Rogerup | 4:2d41b942a823 | 111 | void showPiece(int i, int j); |
Rogerup | 4:2d41b942a823 | 112 | void fillPiece(int x0, int y0, int w, int h, unsigned short v); |
Rogerup | 4:2d41b942a823 | 113 | void fillPieceV(unsigned short color, ...); |
Rogerup | 4:2d41b942a823 | 114 | void showImage( unsigned char x, unsigned char y, unsigned short back, unsigned short front, ... ); |
john_ghielec | 1:cd8a3926f263 | 115 | |
john_ghielec | 1:cd8a3926f263 | 116 | public: |
john_ghielec | 1:cd8a3926f263 | 117 | Game(); |
john_ghielec | 1:cd8a3926f263 | 118 | void tick(); |
john_ghielec | 1:cd8a3926f263 | 119 | }; |