Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Renderer/Renderer.cpp
- Revision:
- 39:41dcf1604fdf
- Parent:
- 33:02c5048b3b3f
- Child:
- 46:824ec81ff578
--- a/Renderer/Renderer.cpp Mon Apr 29 15:23:07 2019 +0000 +++ b/Renderer/Renderer.cpp Tue May 07 16:57:26 2019 +0000 @@ -3,9 +3,7 @@ N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Renderer::Renderer() { - for(int i = 0; i < 6; i++){ //set the selection cubes faces to visible - selectionCube.getFace(i).setVisible(true); - } + selectionCube.setVisible(); } void Renderer::init() { @@ -33,7 +31,6 @@ void Renderer::drawFace(Face *face, float angle) { //Draw a single face from a cube float points[4][3]; float y, x; - for(int vertex = 0; vertex < 4; vertex++) { for(int axis = 0; axis < 3; axis++) { @@ -63,7 +60,7 @@ points[3][2]); //Calculate difference between bottom horizontal edge x coordinates diffY2 = yTo2D(points[2][1], points[2][2])-yTo2D(points[3][1], points[3][2]); //Calculate difference between left horizontal edge y coordinates - if(diffX2 != 0 && face->getVisible()) { + if(diffX2 != 0) { stepBottomY = (float)diffY2/(float)diffX2; //increment multiplier for Y axis on bottom edge of face stepTopX = (float)diffX1/(float)diffX2; //increment multiplier for X axis on top edge of face stepTopY = (float)diffY1/(float)diffX2; //increment multiplier for Y axis on top edge of face @@ -120,7 +117,9 @@ } } for (int f = 0; f< noOfCubes*6 ; f++) { //draw each face from furthest away to closest - drawFace(&faceArray[f], angle/15); + if (faceArray[f].getVisible()) { + drawFace(&faceArray[f], angle/15); + } } } @@ -249,7 +248,7 @@ lcd.printString("joystick",17,1); lcd.printString("to move",20,2); lcd.printString("left and right.",0,3); - lcd.printString("(Press A)",17,5); + lcd.printString("(Press B)",17,5); } void Renderer::drawHelpScreen2(){ //draw the second help screen @@ -257,7 +256,7 @@ lcd.printString("cubes as they",3,1); lcd.printString("move closer",10,2); lcd.printString("to you",25,3); - lcd.printString("(Press A)",17,5); + lcd.printString("(Press B)",17,5); } void Renderer::drawHelpScreen3(){ //draw the third help screen @@ -265,10 +264,10 @@ lcd.printString("smallest",17,1); lcd.printString("touch can",15,2); lcd.printString("kill you",17,3); - lcd.printString("(Press A)",17,5); + lcd.printString("(Press B)",17,5); } void Renderer::drawHelpScreen4(){ //draw the fourth help screen lcd.printString("Good luck!",15,1); - lcd.printString("(Press A)",17,5); + lcd.printString("(Press B)",17,5); } \ No newline at end of file