Mode15 demo program (220x176x16 colors)
Dependencies: PokittoLib
Mode15.cpp@0:50603ea12729, 2018-04-02 (annotated)
- Committer:
- Pokitto
- Date:
- Mon Apr 02 22:37:46 2018 +0000
- Revision:
- 0:50603ea12729
Mode 15 demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pokitto | 0:50603ea12729 | 1 | /* Pokitto drawBitmap example - draws a Pokitto icon by @trelemar */ |
Pokitto | 0:50603ea12729 | 2 | |
Pokitto | 0:50603ea12729 | 3 | #include "Pokitto.h" // include Pokitto library |
Pokitto | 0:50603ea12729 | 4 | #include "monkey16.h" |
Pokitto | 0:50603ea12729 | 5 | |
Pokitto | 0:50603ea12729 | 6 | Pokitto::Core mygame; //create Pokitto application instance |
Pokitto | 0:50603ea12729 | 7 | |
Pokitto | 0:50603ea12729 | 8 | void drawBlurb(const char* text, int x, int y, uint8_t fc, uint8_t bgc) { |
Pokitto | 0:50603ea12729 | 9 | for (int tx=-1;tx<2;tx++) { |
Pokitto | 0:50603ea12729 | 10 | for (int ty=-1;ty<2;ty++) { |
Pokitto | 0:50603ea12729 | 11 | mygame.display.setColor(bgc,15); |
Pokitto | 0:50603ea12729 | 12 | mygame.display.setInvisibleColor(15); |
Pokitto | 0:50603ea12729 | 13 | mygame.display.setCursor(x+tx,y+ty); |
Pokitto | 0:50603ea12729 | 14 | mygame.display.print(text); |
Pokitto | 0:50603ea12729 | 15 | } |
Pokitto | 0:50603ea12729 | 16 | } |
Pokitto | 0:50603ea12729 | 17 | mygame.display.setCursor(x,y); |
Pokitto | 0:50603ea12729 | 18 | mygame.display.setColor(fc,bgc); |
Pokitto | 0:50603ea12729 | 19 | mygame.display.setInvisibleColor(bgc); |
Pokitto | 0:50603ea12729 | 20 | mygame.display.print(text); |
Pokitto | 0:50603ea12729 | 21 | } |
Pokitto | 0:50603ea12729 | 22 | |
Pokitto | 0:50603ea12729 | 23 | |
Pokitto | 0:50603ea12729 | 24 | int main () { |
Pokitto | 0:50603ea12729 | 25 | int x=0,y=20; |
Pokitto | 0:50603ea12729 | 26 | mygame.begin(); // start the application |
Pokitto | 0:50603ea12729 | 27 | mygame.display.load565Palette(monkey16_pal); //load the palette for the image |
Pokitto | 0:50603ea12729 | 28 | mygame.display.setColor(1,0); // set foreground and background colors from palette |
Pokitto | 0:50603ea12729 | 29 | mygame.display.setFont(fontMonkey); // choose a lovely font |
Pokitto | 0:50603ea12729 | 30 | mygame.display.setInvisibleColor(0); |
Pokitto | 0:50603ea12729 | 31 | /* the "while" loop runs as long as the program is running */ |
Pokitto | 0:50603ea12729 | 32 | while (mygame.isRunning()) { |
Pokitto | 0:50603ea12729 | 33 | /* mygame.update() is processed whenever it is time to update the screen */ |
Pokitto | 0:50603ea12729 | 34 | if (mygame.update()) { |
Pokitto | 0:50603ea12729 | 35 | x-=2; |
Pokitto | 0:50603ea12729 | 36 | if (x<-90) x=-90; |
Pokitto | 0:50603ea12729 | 37 | else if (x>0) x = 0; |
Pokitto | 0:50603ea12729 | 38 | mygame.display.drawBitmap(x,16,monkey161); |
Pokitto | 0:50603ea12729 | 39 | mygame.display.drawBitmap(x+160,16,monkey162); |
Pokitto | 0:50603ea12729 | 40 | if (x<-82) { |
Pokitto | 0:50603ea12729 | 41 | drawBlurb("The New Mode15!!",10,62,14,0); |
Pokitto | 0:50603ea12729 | 42 | } |
Pokitto | 0:50603ea12729 | 43 | if (x<-88) { |
Pokitto | 0:50603ea12729 | 44 | drawBlurb("Nice!",130,82,10,0); |
Pokitto | 0:50603ea12729 | 45 | } |
Pokitto | 0:50603ea12729 | 46 | |
Pokitto | 0:50603ea12729 | 47 | } |
Pokitto | 0:50603ea12729 | 48 | } |
Pokitto | 0:50603ea12729 | 49 | return 0; // this is "good programming manners". Program informs it ended without errors |
Pokitto | 0:50603ea12729 | 50 | } |
Pokitto | 0:50603ea12729 | 51 |