Accompanying library for Objects. Library contains five shapes that are selected at random by the Objects library and drawn on to the objects on a Nokia N5110 LCD display.
Dependents: Game_Controller_Project
Fruit.cpp@0:1976fca8d66a, 2017-03-27 (annotated)
- Committer:
- Nathanj94
- Date:
- Mon Mar 27 18:32:24 2017 +0000
- Revision:
- 0:1976fca8d66a
- Child:
- 1:d9e03c7482ad
New library;; functions for drawing four different shapes and un-drawing them too to be used in Objects library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nathanj94 | 0:1976fca8d66a | 1 | #include "Fruit.h" |
Nathanj94 | 0:1976fca8d66a | 2 | |
Nathanj94 | 0:1976fca8d66a | 3 | Fruit::Fruit() |
Nathanj94 | 0:1976fca8d66a | 4 | { |
Nathanj94 | 0:1976fca8d66a | 5 | |
Nathanj94 | 0:1976fca8d66a | 6 | } |
Nathanj94 | 0:1976fca8d66a | 7 | |
Nathanj94 | 0:1976fca8d66a | 8 | Fruit::~Fruit() |
Nathanj94 | 0:1976fca8d66a | 9 | { |
Nathanj94 | 0:1976fca8d66a | 10 | |
Nathanj94 | 0:1976fca8d66a | 11 | } |
Nathanj94 | 0:1976fca8d66a | 12 | |
Nathanj94 | 0:1976fca8d66a | 13 | void Fruit::draw_strawberry(int x, int y, N5110 &lcd) |
Nathanj94 | 0:1976fca8d66a | 14 | { |
Nathanj94 | 0:1976fca8d66a | 15 | lcd.setPixel(x,y+2); |
Nathanj94 | 0:1976fca8d66a | 16 | lcd.setPixel(x+5,y+2); |
Nathanj94 | 0:1976fca8d66a | 17 | lcd.drawLine(x+1,y+1,x+4,y+1,1); |
Nathanj94 | 0:1976fca8d66a | 18 | lcd.drawLine(x+2,y+2,x+3,y+2,1); |
Nathanj94 | 0:1976fca8d66a | 19 | lcd.drawLine(x,y+3,x+2,y+5,1); |
Nathanj94 | 0:1976fca8d66a | 20 | lcd.drawLine(x+3,y+5,x+5,y+3,1); |
Nathanj94 | 0:1976fca8d66a | 21 | } |
Nathanj94 | 0:1976fca8d66a | 22 | void Fruit::undraw_strawberry(int x, int y, N5110 &lcd) |
Nathanj94 | 0:1976fca8d66a | 23 | { |
Nathanj94 | 0:1976fca8d66a | 24 | lcd.setPixel(x,y+2); |
Nathanj94 | 0:1976fca8d66a | 25 | lcd.setPixel(x+5,y+2); |
Nathanj94 | 0:1976fca8d66a | 26 | lcd.drawLine(x+1,y+1,x+4,y+1,0); |
Nathanj94 | 0:1976fca8d66a | 27 | lcd.drawLine(x+2,y+2,x+3,y+2,0); |
Nathanj94 | 0:1976fca8d66a | 28 | lcd.drawLine(x,y+3,x+2,y+5,0); |
Nathanj94 | 0:1976fca8d66a | 29 | lcd.drawLine(x+3,y+5,x+5,y+3,0); |
Nathanj94 | 0:1976fca8d66a | 30 | } |
Nathanj94 | 0:1976fca8d66a | 31 | |
Nathanj94 | 0:1976fca8d66a | 32 | void Fruit::draw_pineapple(int x, int y, N5110 &lcd) |
Nathanj94 | 0:1976fca8d66a | 33 | { |
Nathanj94 | 0:1976fca8d66a | 34 | lcd.drawLine(x,y+4,x+1,y+5,1); |
Nathanj94 | 0:1976fca8d66a | 35 | lcd.drawLine(x,y+3,x+2,y+1,1); |
Nathanj94 | 0:1976fca8d66a | 36 | lcd.drawLine(x+2,y+5,x+4,y+3,1); |
Nathanj94 | 0:1976fca8d66a | 37 | lcd.drawLine(x+3,y+2,x+4,y+1,1); |
Nathanj94 | 0:1976fca8d66a | 38 | lcd.drawLine(x+4,y,x+5,y+1,1); |
Nathanj94 | 0:1976fca8d66a | 39 | } |
Nathanj94 | 0:1976fca8d66a | 40 | |
Nathanj94 | 0:1976fca8d66a | 41 | void Fruit::undraw_pineapple(int x, int y, N5110 &lcd) |
Nathanj94 | 0:1976fca8d66a | 42 | { |
Nathanj94 | 0:1976fca8d66a | 43 | lcd.drawLine(x,y+4,x+1,y+5,0); |
Nathanj94 | 0:1976fca8d66a | 44 | lcd.drawLine(x,y+3,x+2,y+1,0); |
Nathanj94 | 0:1976fca8d66a | 45 | lcd.drawLine(x+2,y+5,x+4,y+3,0); |
Nathanj94 | 0:1976fca8d66a | 46 | lcd.drawLine(x+3,y+2,x+4,y+1,0); |
Nathanj94 | 0:1976fca8d66a | 47 | lcd.drawLine(x+4,y,x+5,y+1,0); |
Nathanj94 | 0:1976fca8d66a | 48 | } |
Nathanj94 | 0:1976fca8d66a | 49 | |
Nathanj94 | 0:1976fca8d66a | 50 | void Fruit::draw_pear(int x, int y, N5110 &lcd) |
Nathanj94 | 0:1976fca8d66a | 51 | { |
Nathanj94 | 0:1976fca8d66a | 52 | lcd.drawLine(x,y+3,x+3,y,1); |
Nathanj94 | 0:1976fca8d66a | 53 | lcd.drawLine(x,y+4,x+1,y+5,1); |
Nathanj94 | 0:1976fca8d66a | 54 | lcd.drawLine(x+2,y+5,x+4,y+5,1); |
Nathanj94 | 0:1976fca8d66a | 55 | lcd.drawLine(x+3,y+2,x+4,y+3,1); |
Nathanj94 | 0:1976fca8d66a | 56 | lcd.drawLine(x+5,y+3,x+5,y+4,1); |
Nathanj94 | 0:1976fca8d66a | 57 | } |
Nathanj94 | 0:1976fca8d66a | 58 | |
Nathanj94 | 0:1976fca8d66a | 59 | void Fruit::undraw_pear(int x, int y, N5110 &lcd) |
Nathanj94 | 0:1976fca8d66a | 60 | { |
Nathanj94 | 0:1976fca8d66a | 61 | lcd.drawLine(x,y+3,x+3,y,0); |
Nathanj94 | 0:1976fca8d66a | 62 | lcd.drawLine(x,y+4,x+1,y+5,0); |
Nathanj94 | 0:1976fca8d66a | 63 | lcd.drawLine(x+2,y+5,x+4,y+5,0); |
Nathanj94 | 0:1976fca8d66a | 64 | lcd.drawLine(x+3,y+2,x+4,y+3,0); |
Nathanj94 | 0:1976fca8d66a | 65 | lcd.drawLine(x+5,y+3,x+5,y+4,0); |
Nathanj94 | 0:1976fca8d66a | 66 | } |
Nathanj94 | 0:1976fca8d66a | 67 | |
Nathanj94 | 0:1976fca8d66a | 68 | void Fruit::draw_melon(int x, int y, N5110 &lcd) |
Nathanj94 | 0:1976fca8d66a | 69 | { |
Nathanj94 | 0:1976fca8d66a | 70 | lcd.drawLine(x+1,y+1,x+4,y+1,1); |
Nathanj94 | 0:1976fca8d66a | 71 | lcd.drawLine(x,y+2,x,y+4,1); |
Nathanj94 | 0:1976fca8d66a | 72 | lcd.drawLine(x+1,y+5,x+4,y+5,1); |
Nathanj94 | 0:1976fca8d66a | 73 | lcd.drawLine(x+5,y+2,x+5,y+4,1); |
Nathanj94 | 0:1976fca8d66a | 74 | } |
Nathanj94 | 0:1976fca8d66a | 75 | |
Nathanj94 | 0:1976fca8d66a | 76 | void Fruit::undraw_melon(int x, int y, N5110 &lcd) |
Nathanj94 | 0:1976fca8d66a | 77 | { |
Nathanj94 | 0:1976fca8d66a | 78 | lcd.drawLine(x+1,y+1,x+4,y+1,0); |
Nathanj94 | 0:1976fca8d66a | 79 | lcd.drawLine(x,y+2,x,y+4,0); |
Nathanj94 | 0:1976fca8d66a | 80 | lcd.drawLine(x+1,y+5,x+4,y+5,0); |
Nathanj94 | 0:1976fca8d66a | 81 | lcd.drawLine(x+5,y+2,x+5,y+4,0); |
Nathanj94 | 0:1976fca8d66a | 82 | } |
Nathanj94 | 0:1976fca8d66a | 83 |