int main(void) { char key; //current key press int i = 0, j = 1; //color tracking variable and quote tracking variable int x = 300, y = 200; //starting coordinates color_t c; //current color //set up the screen init_graphics(); clear_screen(); set_colors(); draw_mario(x, y); draw_header(); draw_footer(); //begin color with red c = colors[i++]; do { key = getkey(); if(key == 'a') { clear_mario(x, y); x -= 20; //move mario left draw_mario(x, y); } else if(key == 's') { clear_mario(x, y); y += 30; //move mario down draw_mario(x, y); } else if(key == 'd') { clear_mario(x, y); x += 20; //move mario right draw_mario(x, y); } else if(key == 'w') { clear_mario(x, y); y -= 30; //move mario up draw_mario(x, y); } else if(key == 'r') { draw_rect(x+52, y, 20, 30, c); //draw a rectangle } else if(key == 'f') { fill_rect(x+52, y, 20, 30, c); //draw a filled rectangle } else if(key == '/') { c = colors[i++]; //cycle colors if(i == 8) i = 0; } else if(key == ' ') { //reset counter if needed if(j == 8) j = 0; change_text(j++, c); //change the quote in the header } sleep_ms(20); } while(key != 'q'); exit_graphics(); return 0; }
void draw_screen_display (void) { #if LCD_DEPTH > 1 int saved_fg = rb->lcd_get_foreground (); int saved_bg = rb->lcd_get_background (); #endif int saved_drmode = rb->lcd_get_drawmode (); if (cursor_pos != last_cursor_pos || intersection_size != last_int_size) { cursor_updated (); } #if LCD_DEPTH > 1 rb->lcd_set_backdrop (NULL); rb->lcd_set_foreground (BOARD_COLOR); rb->lcd_set_background (BACKGROUND_COLOR); rb->lcd_set_drawmode (DRMODE_SOLID); #else rb->lcd_set_drawmode (DRMODE_SOLID + DRMODE_INVERSEVID); #endif rb->lcd_clear_display (); rb->lcd_fillrect (pixel_x (POS (MIN_X, MIN_Y)), pixel_y (POS (MIN_X, MIN_Y)), (MAX_X - MIN_X) * intersection_size, (MAX_Y - MIN_Y) * intersection_size); #if LCD_DEPTH > 1 rb->lcd_set_foreground (LINE_COLOR); #else rb->lcd_set_drawmode (DRMODE_SOLID); #endif unsigned int i; for (i = MIN_Y; i < MAX_Y; ++i) { rb->lcd_hline (pixel_x (POS (MIN_X, i)) + LINE_OFFSET + extend_l, pixel_x (POS (MAX_X - 1, i)) + LINE_OFFSET + extend_r, pixel_y (POS (MIN_X, i)) + LINE_OFFSET); } for (i = MIN_X; i < MAX_X; ++i) { rb->lcd_vline (pixel_x (POS (i, MIN_Y)) + LINE_OFFSET, pixel_y (POS (i, MIN_Y)) + LINE_OFFSET + extend_t, pixel_y (POS (i, MAX_Y - 1)) + LINE_OFFSET + extend_b); } draw_all_hoshi (); draw_all_stones (); draw_cursor (cursor_pos); if (draw_variations) { mark_child_variations_sgf (); } draw_all_marks (); draw_footer (); rb->lcd_update (); #if LCD_DEPTH > 1 rb->lcd_set_foreground (saved_fg); rb->lcd_set_background (saved_bg); #endif rb->lcd_set_drawmode (saved_drmode); }