![](/media/cache/profiles/301b144af4d1614dbcf92f9710be50fb.jpg.50x50_q85.jpg)
Race around the city collecting the flags while avoiding those that stand in the way of your mission. Make no mistake you will need to be quick to outwit your opponents, they are smart and will try to box you in. I wrote this game to prove that writing a game with scrolling scenery is possible even with the limited 6kB of RAM available. I had to compromise sound effects for features, I wanted multiple opponents, I wanted to be able to drop smoke bombs to trap the opponents but all this required memory so the sound effects had to take a back seat.
main.cpp@1:1b8125937f28, 2015-02-01 (annotated)
- Committer:
- taylorza
- Date:
- Sun Feb 01 00:43:25 2015 +0000
- Revision:
- 1:1b8125937f28
- Parent:
- 0:d85c449aca6d
Minor updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
taylorza | 0:d85c449aca6d | 1 | #include "mbed.h" |
taylorza | 0:d85c449aca6d | 2 | #include "Constants.h" |
taylorza | 0:d85c449aca6d | 3 | #include "Canvas.h" |
taylorza | 0:d85c449aca6d | 4 | #include "GameEngine.h" |
taylorza | 0:d85c449aca6d | 5 | #include "Assets.h" |
taylorza | 0:d85c449aca6d | 6 | #include "GameScreen.h" |
taylorza | 1:1b8125937f28 | 7 | #include "Beeper.h" |
taylorza | 0:d85c449aca6d | 8 | |
taylorza | 1:1b8125937f28 | 9 | static const uint16_t palette[] = |
taylorza | 0:d85c449aca6d | 10 | { |
taylorza | 0:d85c449aca6d | 11 | Color565::Black, |
taylorza | 0:d85c449aca6d | 12 | Color565::Blue, |
taylorza | 0:d85c449aca6d | 13 | Color565::Red, |
taylorza | 0:d85c449aca6d | 14 | 0xfe20 |
taylorza | 0:d85c449aca6d | 15 | }; |
taylorza | 0:d85c449aca6d | 16 | |
taylorza | 1:1b8125937f28 | 17 | void showIntro(); |
taylorza | 1:1b8125937f28 | 18 | |
taylorza | 0:d85c449aca6d | 19 | GameScreen gameScreen; |
taylorza | 0:d85c449aca6d | 20 | |
taylorza | 1:1b8125937f28 | 21 | //char buffer[10]; |
taylorza | 1:1b8125937f28 | 22 | //Timer timer; |
taylorza | 0:d85c449aca6d | 23 | |
taylorza | 0:d85c449aca6d | 24 | main() |
taylorza | 0:d85c449aca6d | 25 | { |
taylorza | 0:d85c449aca6d | 26 | Game::Surface.setPalette((uint16_t*)palette); |
taylorza | 1:1b8125937f28 | 27 | Game::Surface.clearScreen(0); |
taylorza | 0:d85c449aca6d | 28 | Game::Surface.setOrientation(LCD_ST7735::Rotate270, false); |
taylorza | 0:d85c449aca6d | 29 | |
taylorza | 1:1b8125937f28 | 30 | showIntro(); |
taylorza | 1:1b8125937f28 | 31 | |
taylorza | 1:1b8125937f28 | 32 | Game::Surface.clearScreen(HUD_BACKGROUND); |
taylorza | 1:1b8125937f28 | 33 | |
taylorza | 1:1b8125937f28 | 34 | // timer.start(); |
taylorza | 1:1b8125937f28 | 35 | // int lastTime = timer.read_us(); |
taylorza | 1:1b8125937f28 | 36 | |
taylorza | 1:1b8125937f28 | 37 | // int updateCounter = 0; |
taylorza | 0:d85c449aca6d | 38 | while(true) |
taylorza | 1:1b8125937f28 | 39 | { |
taylorza | 0:d85c449aca6d | 40 | gameScreen.update(); |
taylorza | 0:d85c449aca6d | 41 | gameScreen.draw(); |
taylorza | 1:1b8125937f28 | 42 | /* |
taylorza | 0:d85c449aca6d | 43 | int time = timer.read_us(); |
taylorza | 1:1b8125937f28 | 44 | int elapsedTime = time - lastTime; |
taylorza | 0:d85c449aca6d | 45 | lastTime = time; |
taylorza | 0:d85c449aca6d | 46 | |
taylorza | 1:1b8125937f28 | 47 | sprintf(buffer, "%d", elapsedTime); |
taylorza | 0:d85c449aca6d | 48 | Game::Surface.drawString(font_ibm, 104, 120, buffer); |
taylorza | 0:d85c449aca6d | 49 | |
taylorza | 0:d85c449aca6d | 50 | ++updateCounter; |
taylorza | 1:1b8125937f28 | 51 | */ |
taylorza | 0:d85c449aca6d | 52 | } |
taylorza | 1:1b8125937f28 | 53 | } |
taylorza | 1:1b8125937f28 | 54 | |
taylorza | 1:1b8125937f28 | 55 | void showIntro() |
taylorza | 1:1b8125937f28 | 56 | { |
taylorza | 1:1b8125937f28 | 57 | // Title |
taylorza | 1:1b8125937f28 | 58 | Game::Surface.drawBitmap(22, 0, titleGraphics, 0, 0, 115, 22, Color565::Aqua, Color565::Black); |
taylorza | 1:1b8125937f28 | 59 | |
taylorza | 1:1b8125937f28 | 60 | // Image |
taylorza | 1:1b8125937f28 | 61 | Game::Surface.drawBitmap(51, 50, titleGraphics, 0, 24, 57, 29, Color565::Blue, Color565::Black); |
taylorza | 1:1b8125937f28 | 62 | |
taylorza | 1:1b8125937f28 | 63 | // Press [] to start |
taylorza | 1:1b8125937f28 | 64 | Game::Surface.drawBitmap(43, 102, titleGraphics, 60, 24, 73, 8, Color565::White, Color565::Black); |
taylorza | 1:1b8125937f28 | 65 | |
taylorza | 1:1b8125937f28 | 66 | // (c)2015 |
taylorza | 1:1b8125937f28 | 67 | Game::Surface.drawBitmap(44, 120, titleGraphics, 60, 34, 71, 8, Color565::White, Color565::Black); |
taylorza | 1:1b8125937f28 | 68 | |
taylorza | 1:1b8125937f28 | 69 | while (!GameInput::isSquarePressed()); |
taylorza | 1:1b8125937f28 | 70 | } |