@@ -518,95 +518,99 @@ bool TetrisMatrixDraw::drawText(int x, int yFinish)
518518 for (int numpos = 0 ; numpos < this ->sizeOfValue ; numpos++)
519519 {
520520
521- // Draw falling shape
522- // if (numstates[numpos].blockindex < blocksPerNumber[numstates[numpos].num_to_draw])
523- if (numstates[numpos].blockindex < blocksPerChar[numstates[numpos].num_to_draw -33 ])
521+ if (numstates[numpos].num_to_draw >= 33 )
524522 {
525- finishedAnimating = false ;
526- fall_instr_let current_fall = getFallinstrByAscii (numstates[numpos].num_to_draw , numstates[numpos].blockindex );
527-
528- // Handle variations of rotations
529- uint8_t rotations = current_fall.num_rot ;
530- if (rotations == 1 )
531- {
532- if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 2 ))
533- {
534- rotations = 0 ;
535- }
536- }
537- if (rotations == 2 )
523+ // Draw falling shape
524+ // if (numstates[numpos].blockindex < blocksPerNumber[numstates[numpos].num_to_draw])
525+ if (numstates[numpos].blockindex < blocksPerChar[numstates[numpos].num_to_draw -33 ])
538526 {
539- if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 3 ))
527+ finishedAnimating = false ;
528+ fall_instr_let current_fall = getFallinstrByAscii (numstates[numpos].num_to_draw , numstates[numpos].blockindex );
529+
530+ // Handle variations of rotations
531+ uint8_t rotations = current_fall.num_rot ;
532+ if (rotations == 1 )
540533 {
541- rotations = 0 ;
534+ if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 2 ))
535+ {
536+ rotations = 0 ;
537+ }
542538 }
543- if (numstates[numpos]. fallindex < ( int )(current_fall. y_stop / 3 * 2 ) )
539+ if (rotations == 2 )
544540 {
545- rotations = 1 ;
541+ if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 3 ))
542+ {
543+ rotations = 0 ;
544+ }
545+ if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 3 * 2 ))
546+ {
547+ rotations = 1 ;
548+ }
546549 }
547- }
548- if (rotations == 3 )
549- {
550- if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 4 ))
550+ if (rotations == 3 )
551551 {
552- rotations = 0 ;
552+ if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 4 ))
553+ {
554+ rotations = 0 ;
555+ }
556+ if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 4 * 2 ))
557+ {
558+ rotations = 1 ;
559+ }
560+ if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 4 * 3 ))
561+ {
562+ rotations = 2 ;
563+ }
553564 }
554- if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 4 * 2 ))
555- {
556- rotations = 1 ;
565+ if (this ->scale <= 1 ){
566+ drawShape (current_fall.blocktype ,
567+ this ->tetrisColors [current_fall.color ],
568+ x + current_fall.x_pos + numstates[numpos].x_shift ,
569+ y + numstates[numpos].fallindex - scaledYOffset,
570+ rotations);
571+ } else {
572+ drawLargerShape (this ->scale ,
573+ current_fall.blocktype ,
574+ this ->tetrisColors [current_fall.color ],
575+ x + (current_fall.x_pos * this ->scale ) + numstates[numpos].x_shift ,
576+ y + (numstates[numpos].fallindex * scaledYOffset) - scaledYOffset,
577+ rotations);
557578 }
558- if (numstates[numpos].fallindex < (int )(current_fall.y_stop / 4 * 3 ))
579+ // drawShape(current_fall.blocktype, this->tetrisColors[current_fall.color], x + current_fall.x_pos + numstates[numpos].x_shift, y + numstates[numpos].fallindex - 1, rotations);
580+ numstates[numpos].fallindex ++;
581+
582+ if (numstates[numpos].fallindex > current_fall.y_stop )
559583 {
560- rotations = 2 ;
584+ numstates[numpos].fallindex = 0 ;
585+ numstates[numpos].blockindex ++;
561586 }
562587 }
563- if (this ->scale <= 1 ){
564- drawShape (current_fall.blocktype ,
565- this ->tetrisColors [current_fall.color ],
566- x + current_fall.x_pos + numstates[numpos].x_shift ,
567- y + numstates[numpos].fallindex - scaledYOffset,
568- rotations);
569- } else {
570- drawLargerShape (this ->scale ,
571- current_fall.blocktype ,
572- this ->tetrisColors [current_fall.color ],
573- x + (current_fall.x_pos * this ->scale ) + numstates[numpos].x_shift ,
574- y + (numstates[numpos].fallindex * scaledYOffset) - scaledYOffset,
575- rotations);
576- }
577- // drawShape(current_fall.blocktype, this->tetrisColors[current_fall.color], x + current_fall.x_pos + numstates[numpos].x_shift, y + numstates[numpos].fallindex - 1, rotations);
578- numstates[numpos].fallindex ++;
579588
580- if (numstates[numpos].fallindex > current_fall.y_stop )
581- {
582- numstates[numpos].fallindex = 0 ;
583- numstates[numpos].blockindex ++;
584- }
585- }
586-
587- // Draw already dropped shapes
588- if (numstates[numpos].blockindex > 0 )
589- {
590- for (int i = 0 ; i < numstates[numpos].blockindex ; i++)
589+ // Draw already dropped shapes
590+ if (numstates[numpos].blockindex > 0 )
591591 {
592- fall_instr_let fallen_block = getFallinstrByAscii (numstates[numpos].num_to_draw , i);
593- if (this ->scale <= 1 ){
594- drawShape (fallen_block.blocktype ,
595- this ->tetrisColors [fallen_block.color ],
596- x + fallen_block.x_pos + numstates[numpos].x_shift ,
597- y + fallen_block.y_stop - 1 ,
598- fallen_block.num_rot );
599- } else {
600- drawLargerShape (this ->scale ,
601- fallen_block.blocktype ,
602- this ->tetrisColors [fallen_block.color ],
603- x + (fallen_block.x_pos * this ->scale ) + numstates[numpos].x_shift ,
604- y + (fallen_block.y_stop * scaledYOffset) - scaledYOffset,
605- fallen_block.num_rot );
592+ for (int i = 0 ; i < numstates[numpos].blockindex ; i++)
593+ {
594+ fall_instr_let fallen_block = getFallinstrByAscii (numstates[numpos].num_to_draw , i);
595+ if (this ->scale <= 1 ){
596+ drawShape (fallen_block.blocktype ,
597+ this ->tetrisColors [fallen_block.color ],
598+ x + fallen_block.x_pos + numstates[numpos].x_shift ,
599+ y + fallen_block.y_stop - 1 ,
600+ fallen_block.num_rot );
601+ } else {
602+ drawLargerShape (this ->scale ,
603+ fallen_block.blocktype ,
604+ this ->tetrisColors [fallen_block.color ],
605+ x + (fallen_block.x_pos * this ->scale ) + numstates[numpos].x_shift ,
606+ y + (fallen_block.y_stop * scaledYOffset) - scaledYOffset,
607+ fallen_block.num_rot );
608+ }
609+ // drawShape(fallen_block.blocktype, this->tetrisColors[fallen_block.color], x + fallen_block.x_pos + numstates[numpos].x_shift, y + fallen_block.y_stop - 1, fallen_block.num_rot);
606610 }
607- // drawShape(fallen_block.blocktype, this->tetrisColors[fallen_block.color], x + fallen_block.x_pos + numstates[numpos].x_shift, y + fallen_block.y_stop - 1, fallen_block.num_rot);
608611 }
609612 }
613+
610614 }
611615
612616 return finishedAnimating;
@@ -714,19 +718,21 @@ bool TetrisMatrixDraw::drawNumbers(int x, int yFinish, bool displayColon)
714718 }
715719 }
716720
717- // Hour / minutes divider (blinking)
718- // if (seconds_odd)
719721 if (displayColon)
720722 {
721- int colonSize = 2 * this ->scale ;
722- int xColonPos = x + (TETRIS_DISTANCE_BETWEEN_DIGITS * 2 * this ->scale );
723- display->fillRect (xColonPos, y + (12 * this ->scale ), colonSize, colonSize, this ->tetrisWHITE );
724- display->fillRect (xColonPos, y + (8 * this ->scale ), colonSize, colonSize, this ->tetrisWHITE );
723+ this ->drawColon (x, y, this ->tetrisWHITE );
725724 }
726725
727726 return finishedAnimating;
728727}
729728
729+ void TetrisMatrixDraw::drawColon (int x, int y, uint16_t colonColour){
730+ int colonSize = 2 * this ->scale ;
731+ int xColonPos = x + (TETRIS_DISTANCE_BETWEEN_DIGITS * 2 * this ->scale );
732+ display->fillRect (xColonPos, y + (12 * this ->scale ), colonSize, colonSize, colonColour);
733+ display->fillRect (xColonPos, y + (8 * this ->scale ), colonSize, colonSize, colonColour);
734+ }
735+
730736void TetrisMatrixDraw::intialiseColors (){
731737 this ->tetrisRED = 0xF800 ;
732738 this ->tetrisGREEN = 0x07E0 ;
0 commit comments