void ticTacToeDisplay_drawO(uint8_t row, uint8_t column) { //position the y coordinate correctly depending on row number if(row == TICTACTOEDISPLAY_ROW_TOP)//top row { row = TICTACTOEDISPLAY_ONE_SIXTH_HEIGHT;//middle of O is between rows } else if(row == TICTACTOEDISPLAY_ROW_MIDDLE)//middle row { row = TICTACTOEDISPLAY_HALF_HEIGHT;//middle of O is between rows } else if(row == TICTACTOEDISPLAY_ROW_BOTTOM)//bottom row { row = TICTACTOEDISPLAY_FIVE_SIXTH_HEIGHT;//middle of O is between rows } //position the x coordinate correctly depending on column number if(column == TICTACTOEDISPLAY_COLUMN_LEFT)//left column { column = TICTACTOEDISPLAY_ONE_SIXTH_WIDTH;//middle of O is between columns } else if(column == TICTACTOEDISPLAY_COLUMN_MIDDLE)//middle column { column = TICTACTOEDISPLAY_HALF_WIDTH;//middle of O is between columns } else if(column == TICTACTOEDISPLAY_COLUMN_RIGHT)//right column { display_drawCircle(TICTACTOEDISPLAY_FIVE_SIXTH_WIDTH, row, TICTACTOEDISPLAY_CIRCLE_RADIUS, TICTACTOEDISPLAY_GREEN); return;//in this case the column number was too big for uint8_t column to hold (267) so jut manually draw this one } display_drawCircle(column, row, TICTACTOEDISPLAY_CIRCLE_RADIUS, TICTACTOEDISPLAY_GREEN);//draw the O character }
void TicTacToeDisplay_drawO(uint8_t row, uint8_t column) { uint16_t X_ORIGIN = (column*ONE_THIRD_WIDTH) + ONE_THIRD_WIDTH/2; uint16_t Y_ORIGIN = (row * ONE_THIRD_HEIGHT)+ ONE_THIRD_HEIGHT/2; display_drawCircle(X_ORIGIN, Y_ORIGIN, X_OFFSET, DISPLAY_GREEN); }
// Draws an O at the specified row and column. void ticTacToeDisplay_drawO(uint8_t row, uint8_t column) { switch (row) { case 0: switch(column) { case 0: display_drawCircle(TICTACTOE_DISP_COLUMN_0_PT, TICTACTOE_DISP_ROW_0_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; case 1: display_drawCircle(TICTACTOE_DISP_COLUMN_1_PT, TICTACTOE_DISP_ROW_0_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; case 2: display_drawCircle(TICTACTOE_DISP_COLUMN_2_PT, TICTACTOE_DISP_ROW_0_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; default:break; } break; case 1: switch(column) { case 0: display_drawCircle(TICTACTOE_DISP_COLUMN_0_PT, TICTACTOE_DISP_ROW_1_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; case 1: display_drawCircle(TICTACTOE_DISP_COLUMN_1_PT, TICTACTOE_DISP_ROW_1_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; case 2: display_drawCircle(TICTACTOE_DISP_COLUMN_2_PT, TICTACTOE_DISP_ROW_1_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; default:break; } break; case 2: switch(column) { case 0: display_drawCircle(TICTACTOE_DISP_COLUMN_0_PT, TICTACTOE_DISP_ROW_2_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; case 1: display_drawCircle(TICTACTOE_DISP_COLUMN_1_PT, TICTACTOE_DISP_ROW_2_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; case 2: display_drawCircle(TICTACTOE_DISP_COLUMN_2_PT, TICTACTOE_DISP_ROW_2_PT, TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW); break; default:break; } break; default:break; } }
int main() { display_init(); // Must init all of the software and underlying hardware for LCD. display_fillScreen(DISPLAY_BLACK); // Blank the screen. display_setRotation(0); display_drawLine(0,0,240,320,GREEN); display_drawLine(240,0,0,320 ,GREEN); display_drawCircle(120,80,30,RED); display_fillCircle(120,240,30,RED); display_drawTriangle(90,160,45,134,45,186,YELLOW); display_fillTriangle(150,160,195,134,195,186,YELLOW); }
void game_draw(void) { int i; // reset buffer at startup display_clear(); // Draw players players_draw(); // Draw ball display_drawCircle(ball->Location.x, ball->Location.y, ball->Radius); // Draw goals for(i = 20; i < LCD_HEIGHT - 20; i++) { display_drawPixel(5, i, 1); display_drawPixel(LCD_WIDTH - 6, i, 1); } display_flush(); }