![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Allow user to connect multiple screen.
Graphics.h@0:052d0f82433e, 2015-03-11 (annotated)
- Committer:
- Ratchapong
- Date:
- Wed Mar 11 05:00:37 2015 +0000
- Revision:
- 0:052d0f82433e
Working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ratchapong | 0:052d0f82433e | 1 | #include "uLCD_Multiscreen.h" |
Ratchapong | 0:052d0f82433e | 2 | |
Ratchapong | 0:052d0f82433e | 3 | struct vec2 { |
Ratchapong | 0:052d0f82433e | 4 | float x; |
Ratchapong | 0:052d0f82433e | 5 | float y; |
Ratchapong | 0:052d0f82433e | 6 | }; |
Ratchapong | 0:052d0f82433e | 7 | |
Ratchapong | 0:052d0f82433e | 8 | |
Ratchapong | 0:052d0f82433e | 9 | class Renderer; |
Ratchapong | 0:052d0f82433e | 10 | |
Ratchapong | 0:052d0f82433e | 11 | |
Ratchapong | 0:052d0f82433e | 12 | class Block |
Ratchapong | 0:052d0f82433e | 13 | { |
Ratchapong | 0:052d0f82433e | 14 | friend Renderer; |
Ratchapong | 0:052d0f82433e | 15 | |
Ratchapong | 0:052d0f82433e | 16 | private: |
Ratchapong | 0:052d0f82433e | 17 | |
Ratchapong | 0:052d0f82433e | 18 | vec2 next_coord; |
Ratchapong | 0:052d0f82433e | 19 | vec2 next_size; |
Ratchapong | 0:052d0f82433e | 20 | |
Ratchapong | 0:052d0f82433e | 21 | public: |
Ratchapong | 0:052d0f82433e | 22 | bool updated; |
Ratchapong | 0:052d0f82433e | 23 | bool locked; |
Ratchapong | 0:052d0f82433e | 24 | |
Ratchapong | 0:052d0f82433e | 25 | bool render; |
Ratchapong | 0:052d0f82433e | 26 | vec2 coord; |
Ratchapong | 0:052d0f82433e | 27 | vec2 size; |
Ratchapong | 0:052d0f82433e | 28 | |
Ratchapong | 0:052d0f82433e | 29 | int color; |
Ratchapong | 0:052d0f82433e | 30 | |
Ratchapong | 0:052d0f82433e | 31 | vec2 prev_coord; |
Ratchapong | 0:052d0f82433e | 32 | vec2 prev_size; |
Ratchapong | 0:052d0f82433e | 33 | |
Ratchapong | 0:052d0f82433e | 34 | Block() : updated(true), locked(false), render(true) { |
Ratchapong | 0:052d0f82433e | 35 | coord.x = 0; |
Ratchapong | 0:052d0f82433e | 36 | coord.y = 0; |
Ratchapong | 0:052d0f82433e | 37 | color = RED; |
Ratchapong | 0:052d0f82433e | 38 | size.x = 2; |
Ratchapong | 0:052d0f82433e | 39 | size.y = 2; |
Ratchapong | 0:052d0f82433e | 40 | } |
Ratchapong | 0:052d0f82433e | 41 | |
Ratchapong | 0:052d0f82433e | 42 | virtual void next_swap(){ |
Ratchapong | 0:052d0f82433e | 43 | coord = next_coord; |
Ratchapong | 0:052d0f82433e | 44 | size = next_size; |
Ratchapong | 0:052d0f82433e | 45 | |
Ratchapong | 0:052d0f82433e | 46 | } |
Ratchapong | 0:052d0f82433e | 47 | |
Ratchapong | 0:052d0f82433e | 48 | void store_prev() { |
Ratchapong | 0:052d0f82433e | 49 | prev_coord = coord; |
Ratchapong | 0:052d0f82433e | 50 | prev_size = size; |
Ratchapong | 0:052d0f82433e | 51 | } |
Ratchapong | 0:052d0f82433e | 52 | |
Ratchapong | 0:052d0f82433e | 53 | void copy() { |
Ratchapong | 0:052d0f82433e | 54 | prev_coord = coord; |
Ratchapong | 0:052d0f82433e | 55 | prev_size = size; |
Ratchapong | 0:052d0f82433e | 56 | |
Ratchapong | 0:052d0f82433e | 57 | next_coord = coord; |
Ratchapong | 0:052d0f82433e | 58 | next_size = size; |
Ratchapong | 0:052d0f82433e | 59 | |
Ratchapong | 0:052d0f82433e | 60 | } |
Ratchapong | 0:052d0f82433e | 61 | |
Ratchapong | 0:052d0f82433e | 62 | |
Ratchapong | 0:052d0f82433e | 63 | }; |
Ratchapong | 0:052d0f82433e | 64 | |
Ratchapong | 0:052d0f82433e | 65 | |
Ratchapong | 0:052d0f82433e | 66 | class Scene |
Ratchapong | 0:052d0f82433e | 67 | { |
Ratchapong | 0:052d0f82433e | 68 | public: |
Ratchapong | 0:052d0f82433e | 69 | int bg; |
Ratchapong | 0:052d0f82433e | 70 | Block paddle; |
Ratchapong | 0:052d0f82433e | 71 | |
Ratchapong | 0:052d0f82433e | 72 | }; |
Ratchapong | 0:052d0f82433e | 73 | |
Ratchapong | 0:052d0f82433e | 74 | |
Ratchapong | 0:052d0f82433e | 75 | class Renderer |
Ratchapong | 0:052d0f82433e | 76 | { |
Ratchapong | 0:052d0f82433e | 77 | private: |
Ratchapong | 0:052d0f82433e | 78 | public: |
Ratchapong | 0:052d0f82433e | 79 | uLCD_Multiscreen& g; |
Ratchapong | 0:052d0f82433e | 80 | int background; |
Ratchapong | 0:052d0f82433e | 81 | vec2 screen; |
Ratchapong | 0:052d0f82433e | 82 | |
Ratchapong | 0:052d0f82433e | 83 | Renderer(uLCD_Multiscreen& gfx, vec2 screen) : g(gfx), screen(screen) { |
Ratchapong | 0:052d0f82433e | 84 | } |
Ratchapong | 0:052d0f82433e | 85 | void render(Scene s) { |
Ratchapong | 0:052d0f82433e | 86 | |
Ratchapong | 0:052d0f82433e | 87 | |
Ratchapong | 0:052d0f82433e | 88 | //draw paddle |
Ratchapong | 0:052d0f82433e | 89 | { |
Ratchapong | 0:052d0f82433e | 90 | Block* b = &(s.paddle); |
Ratchapong | 0:052d0f82433e | 91 | if(b->updated) { |
Ratchapong | 0:052d0f82433e | 92 | //draw over where it was |
Ratchapong | 0:052d0f82433e | 93 | g.unfilledCirlce(b->prev_coord.x, b->prev_coord.y, 10, background); //x1,y1,x2,y2,color |
Ratchapong | 0:052d0f82433e | 94 | //draw new location |
Ratchapong | 0:052d0f82433e | 95 | g.unfilledCirlce(b->coord.x, b->coord.y, 10, b->color); //x1,y1,x2,y2,color |
Ratchapong | 0:052d0f82433e | 96 | |
Ratchapong | 0:052d0f82433e | 97 | b->updated = false; |
Ratchapong | 0:052d0f82433e | 98 | } |
Ratchapong | 0:052d0f82433e | 99 | } |
Ratchapong | 0:052d0f82433e | 100 | |
Ratchapong | 0:052d0f82433e | 101 | |
Ratchapong | 0:052d0f82433e | 102 | |
Ratchapong | 0:052d0f82433e | 103 | |
Ratchapong | 0:052d0f82433e | 104 | } |
Ratchapong | 0:052d0f82433e | 105 | }; |