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

Committer:
Nathanj94
Date:
Sat Apr 22 12:32:50 2017 +0000
Revision:
2:15120c2cf507
Parent:
1:d9e03c7482ad
Redundancy removed and files organised ready for notes to be written

Who changed what in which revision?

UserRevisionLine numberNew 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 2:15120c2cf507 13 //STRAWBERRY DRAW/UNDRAW//
Nathanj94 0:1976fca8d66a 14 void Fruit::draw_strawberry(int x, int y, N5110 &lcd)
Nathanj94 0:1976fca8d66a 15 {
Nathanj94 0:1976fca8d66a 16 lcd.setPixel(x,y+2);
Nathanj94 0:1976fca8d66a 17 lcd.setPixel(x+5,y+2);
Nathanj94 0:1976fca8d66a 18 lcd.drawLine(x+1,y+1,x+4,y+1,1);
Nathanj94 0:1976fca8d66a 19 lcd.drawLine(x+2,y+2,x+3,y+2,1);
Nathanj94 0:1976fca8d66a 20 lcd.drawLine(x,y+3,x+2,y+5,1);
Nathanj94 0:1976fca8d66a 21 lcd.drawLine(x+3,y+5,x+5,y+3,1);
Nathanj94 0:1976fca8d66a 22 }
Nathanj94 0:1976fca8d66a 23 void Fruit::undraw_strawberry(int x, int y, N5110 &lcd)
Nathanj94 0:1976fca8d66a 24 {
Nathanj94 0:1976fca8d66a 25 lcd.setPixel(x,y+2);
Nathanj94 0:1976fca8d66a 26 lcd.setPixel(x+5,y+2);
Nathanj94 0:1976fca8d66a 27 lcd.drawLine(x+1,y+1,x+4,y+1,0);
Nathanj94 0:1976fca8d66a 28 lcd.drawLine(x+2,y+2,x+3,y+2,0);
Nathanj94 0:1976fca8d66a 29 lcd.drawLine(x,y+3,x+2,y+5,0);
Nathanj94 0:1976fca8d66a 30 lcd.drawLine(x+3,y+5,x+5,y+3,0);
Nathanj94 0:1976fca8d66a 31 }
Nathanj94 0:1976fca8d66a 32
Nathanj94 2:15120c2cf507 33 //PINEAPPLE DRAW/UNDRAW//
Nathanj94 0:1976fca8d66a 34 void Fruit::draw_pineapple(int x, int y, N5110 &lcd)
Nathanj94 0:1976fca8d66a 35 {
Nathanj94 0:1976fca8d66a 36 lcd.drawLine(x,y+4,x+1,y+5,1);
Nathanj94 0:1976fca8d66a 37 lcd.drawLine(x,y+3,x+2,y+1,1);
Nathanj94 0:1976fca8d66a 38 lcd.drawLine(x+2,y+5,x+4,y+3,1);
Nathanj94 0:1976fca8d66a 39 lcd.drawLine(x+3,y+2,x+4,y+1,1);
Nathanj94 0:1976fca8d66a 40 lcd.drawLine(x+4,y,x+5,y+1,1);
Nathanj94 0:1976fca8d66a 41 }
Nathanj94 0:1976fca8d66a 42
Nathanj94 0:1976fca8d66a 43 void Fruit::undraw_pineapple(int x, int y, N5110 &lcd)
Nathanj94 0:1976fca8d66a 44 {
Nathanj94 0:1976fca8d66a 45 lcd.drawLine(x,y+4,x+1,y+5,0);
Nathanj94 0:1976fca8d66a 46 lcd.drawLine(x,y+3,x+2,y+1,0);
Nathanj94 0:1976fca8d66a 47 lcd.drawLine(x+2,y+5,x+4,y+3,0);
Nathanj94 0:1976fca8d66a 48 lcd.drawLine(x+3,y+2,x+4,y+1,0);
Nathanj94 0:1976fca8d66a 49 lcd.drawLine(x+4,y,x+5,y+1,0);
Nathanj94 0:1976fca8d66a 50 }
Nathanj94 0:1976fca8d66a 51
Nathanj94 2:15120c2cf507 52 //PEAR DRAW/UNDRAW//
Nathanj94 0:1976fca8d66a 53 void Fruit::draw_pear(int x, int y, N5110 &lcd)
Nathanj94 0:1976fca8d66a 54 {
Nathanj94 0:1976fca8d66a 55 lcd.drawLine(x,y+3,x+3,y,1);
Nathanj94 0:1976fca8d66a 56 lcd.drawLine(x,y+4,x+1,y+5,1);
Nathanj94 0:1976fca8d66a 57 lcd.drawLine(x+2,y+5,x+4,y+5,1);
Nathanj94 0:1976fca8d66a 58 lcd.drawLine(x+3,y+2,x+4,y+3,1);
Nathanj94 0:1976fca8d66a 59 lcd.drawLine(x+5,y+3,x+5,y+4,1);
Nathanj94 0:1976fca8d66a 60 }
Nathanj94 0:1976fca8d66a 61
Nathanj94 0:1976fca8d66a 62 void Fruit::undraw_pear(int x, int y, N5110 &lcd)
Nathanj94 0:1976fca8d66a 63 {
Nathanj94 0:1976fca8d66a 64 lcd.drawLine(x,y+3,x+3,y,0);
Nathanj94 0:1976fca8d66a 65 lcd.drawLine(x,y+4,x+1,y+5,0);
Nathanj94 0:1976fca8d66a 66 lcd.drawLine(x+2,y+5,x+4,y+5,0);
Nathanj94 0:1976fca8d66a 67 lcd.drawLine(x+3,y+2,x+4,y+3,0);
Nathanj94 0:1976fca8d66a 68 lcd.drawLine(x+5,y+3,x+5,y+4,0);
Nathanj94 0:1976fca8d66a 69 }
Nathanj94 0:1976fca8d66a 70
Nathanj94 2:15120c2cf507 71 //MELON DRAW/UNDRAW//
Nathanj94 0:1976fca8d66a 72 void Fruit::draw_melon(int x, int y, N5110 &lcd)
Nathanj94 0:1976fca8d66a 73 {
Nathanj94 0:1976fca8d66a 74 lcd.drawLine(x+1,y+1,x+4,y+1,1);
Nathanj94 0:1976fca8d66a 75 lcd.drawLine(x,y+2,x,y+4,1);
Nathanj94 0:1976fca8d66a 76 lcd.drawLine(x+1,y+5,x+4,y+5,1);
Nathanj94 0:1976fca8d66a 77 lcd.drawLine(x+5,y+2,x+5,y+4,1);
Nathanj94 0:1976fca8d66a 78 }
Nathanj94 0:1976fca8d66a 79
Nathanj94 0:1976fca8d66a 80 void Fruit::undraw_melon(int x, int y, N5110 &lcd)
Nathanj94 0:1976fca8d66a 81 {
Nathanj94 0:1976fca8d66a 82 lcd.drawLine(x+1,y+1,x+4,y+1,0);
Nathanj94 0:1976fca8d66a 83 lcd.drawLine(x,y+2,x,y+4,0);
Nathanj94 0:1976fca8d66a 84 lcd.drawLine(x+1,y+5,x+4,y+5,0);
Nathanj94 0:1976fca8d66a 85 lcd.drawLine(x+5,y+2,x+5,y+4,0);
Nathanj94 0:1976fca8d66a 86 }
Nathanj94 1:d9e03c7482ad 87
Nathanj94 2:15120c2cf507 88 //ANTIFRUIT DRAW/UNDRAW//
Nathanj94 1:d9e03c7482ad 89 void Fruit::draw_antifruit(int x, int y, N5110 &lcd)
Nathanj94 1:d9e03c7482ad 90 {
Nathanj94 1:d9e03c7482ad 91 lcd.drawLine(x,y,x+5,y+5,1);
Nathanj94 1:d9e03c7482ad 92 lcd.drawLine(x,y+5,x+5,y,1);
Nathanj94 1:d9e03c7482ad 93 }
Nathanj94 1:d9e03c7482ad 94
Nathanj94 1:d9e03c7482ad 95 void Fruit::undraw_antifruit(int x, int y, N5110 &lcd)
Nathanj94 1:d9e03c7482ad 96 {
Nathanj94 1:d9e03c7482ad 97 lcd.drawLine(x,y,x+5,y+5,0);
Nathanj94 1:d9e03c7482ad 98 lcd.drawLine(x,y+5,x+5,y,0);
Nathanj94 1:d9e03c7482ad 99 }