2036 mbed lab4
Dependencies: 4DGL-uLCD-SE PinDetect
Die.cc
- Committer:
- lhanks02
- Date:
- 2022-03-28
- Revision:
- 0:bbda88bee65a
File content as of revision 0:bbda88bee65a:
#include "Die.h" #include <stdlib.h> #include "uLCD_4DGL.h" extern uLCD_4DGL uLCD; DieState Die::getCurrDieState()//setter and getter for state { return currDieState; } void Die::setCurrDieState(DieState v) { currDieState=v; } void Die::rollDie() {//function to roll die, only roll if die is in roll state if(currDieState==ROLL) { int val=rand()%6+1; value = val; } } void Die::drawDie()//function to draw die { uLCD.rectangle(x1,y1,x2,y2,Color); if (value==1) {//if statements displaying certain numbers of dots for each number uLCD.filled_circle(x1+((x2-x1)/2),(y1+(y2-y1)/2), 3, WHITE); } if (value==2) { uLCD.filled_circle(x1+((x2-x1)/4),(y1+((y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+(3*(y2-y1)/4)), 3, WHITE); } if (value==3) { uLCD.filled_circle(x1+((x2-x1)/4),(y1+(3*(y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+((y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+((x2-x1)/2),(y1+((y2-y1)/2)), 3, WHITE); } if (value==4) { uLCD.filled_circle(x1+((x2-x1)/4),(y1+(3*(y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+((y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+(3*(y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+((x2-x1)/4),(y1+((y2-y1)/4)), 3, WHITE); } if (value==5) { uLCD.filled_circle(x1+((x2-x1)/4),(y1+(3*(y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+((y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+(3*(y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+((x2-x1)/4),(y1+((y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+((x2-x1)/2),(y1+((y2-y1)/2)), 3, WHITE); } if (value==6) { uLCD.filled_circle(x1+((x2-x1)/4),(y1+(3*(y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+((y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+(3*(y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+((x2-x1)/4),(y1+((y2-y1)/4)), 3, WHITE); uLCD.filled_circle(x1+((x2-x1)/4),(y1+((y2-y1)/2)), 3, WHITE); uLCD.filled_circle(x1+(3*(x2-x1)/4),(y1+((y2-y1)/2)), 3, WHITE); } } int Die::getx1()//setters and getters for data members { return x1; } int Die::getx2() { return x2; } int Die::gety1() { return y1; } int Die::gety2() { return y2; } int Die::getColor() { return Color; } int Die::getValue() { return value; }