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
Diff: Fruit.cpp
- Revision:
- 0:1976fca8d66a
- Child:
- 1:d9e03c7482ad
diff -r 000000000000 -r 1976fca8d66a Fruit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Fruit.cpp Mon Mar 27 18:32:24 2017 +0000 @@ -0,0 +1,83 @@ +#include "Fruit.h" + +Fruit::Fruit() +{ + +} + +Fruit::~Fruit() +{ + +} + +void Fruit::draw_strawberry(int x, int y, N5110 &lcd) +{ + lcd.setPixel(x,y+2); + lcd.setPixel(x+5,y+2); + lcd.drawLine(x+1,y+1,x+4,y+1,1); + lcd.drawLine(x+2,y+2,x+3,y+2,1); + lcd.drawLine(x,y+3,x+2,y+5,1); + lcd.drawLine(x+3,y+5,x+5,y+3,1); +} +void Fruit::undraw_strawberry(int x, int y, N5110 &lcd) +{ + lcd.setPixel(x,y+2); + lcd.setPixel(x+5,y+2); + lcd.drawLine(x+1,y+1,x+4,y+1,0); + lcd.drawLine(x+2,y+2,x+3,y+2,0); + lcd.drawLine(x,y+3,x+2,y+5,0); + lcd.drawLine(x+3,y+5,x+5,y+3,0); +} + +void Fruit::draw_pineapple(int x, int y, N5110 &lcd) +{ + lcd.drawLine(x,y+4,x+1,y+5,1); + lcd.drawLine(x,y+3,x+2,y+1,1); + lcd.drawLine(x+2,y+5,x+4,y+3,1); + lcd.drawLine(x+3,y+2,x+4,y+1,1); + lcd.drawLine(x+4,y,x+5,y+1,1); +} + +void Fruit::undraw_pineapple(int x, int y, N5110 &lcd) +{ + lcd.drawLine(x,y+4,x+1,y+5,0); + lcd.drawLine(x,y+3,x+2,y+1,0); + lcd.drawLine(x+2,y+5,x+4,y+3,0); + lcd.drawLine(x+3,y+2,x+4,y+1,0); + lcd.drawLine(x+4,y,x+5,y+1,0); +} + +void Fruit::draw_pear(int x, int y, N5110 &lcd) +{ + lcd.drawLine(x,y+3,x+3,y,1); + lcd.drawLine(x,y+4,x+1,y+5,1); + lcd.drawLine(x+2,y+5,x+4,y+5,1); + lcd.drawLine(x+3,y+2,x+4,y+3,1); + lcd.drawLine(x+5,y+3,x+5,y+4,1); +} + +void Fruit::undraw_pear(int x, int y, N5110 &lcd) +{ + lcd.drawLine(x,y+3,x+3,y,0); + lcd.drawLine(x,y+4,x+1,y+5,0); + lcd.drawLine(x+2,y+5,x+4,y+5,0); + lcd.drawLine(x+3,y+2,x+4,y+3,0); + lcd.drawLine(x+5,y+3,x+5,y+4,0); +} + +void Fruit::draw_melon(int x, int y, N5110 &lcd) +{ + lcd.drawLine(x+1,y+1,x+4,y+1,1); + lcd.drawLine(x,y+2,x,y+4,1); + lcd.drawLine(x+1,y+5,x+4,y+5,1); + lcd.drawLine(x+5,y+2,x+5,y+4,1); +} + +void Fruit::undraw_melon(int x, int y, N5110 &lcd) +{ + lcd.drawLine(x+1,y+1,x+4,y+1,0); + lcd.drawLine(x,y+2,x,y+4,0); + lcd.drawLine(x+1,y+5,x+4,y+5,0); + lcd.drawLine(x+5,y+2,x+5,y+4,0); +} + \ No newline at end of file