void draw() { int i; for(i=lewa_sciana; i<=prawa_sciana; i++) { PCD8544_DrawPixel(i, gorna_sciana,PCD8544_Pixel_Set); PCD8544_DrawPixel(i, dolna_sciana,PCD8544_Pixel_Set); } for(i=gorna_sciana; i<=dolna_sciana; i++) { PCD8544_DrawPixel(lewa_sciana, i,PCD8544_Pixel_Set); PCD8544_DrawPixel(prawa_sciana, i,PCD8544_Pixel_Set); } draw_snake(); draw_apple(); draw_score(); PCD8544_Refresh(); }
static void game (void) { int button; redraw(); rb->lcd_update(); /*main loop:*/ while (1) { if(frames==5) { frame(); if(frames > 0) frames = 0; } frames++; if(frames == 0) { die(); } else { if(frames < 0) { if(sillydir != dir) { /*it has, great set frames to a positive value again:*/ frames = 1; } } } if (dead) return; draw_apple(); rb->sleep(HZ/speed); button = rb->button_get(false); #ifdef HAS_BUTTON_HOLD if (rb->button_hold()) button = SNAKE2_PLAYPAUSE; #endif switch (button) { case SNAKE2_UP: case SNAKE2_UP | BUTTON_REPEAT: if (dir != SOUTH) set_direction(NORTH); break; case SNAKE2_RIGHT: case SNAKE2_RIGHT | BUTTON_REPEAT: if (dir != WEST) set_direction(EAST); break; case SNAKE2_DOWN: case SNAKE2_DOWN | BUTTON_REPEAT: if (dir != NORTH) set_direction(SOUTH); break; case SNAKE2_LEFT: case SNAKE2_LEFT | BUTTON_REPEAT: if (dir != EAST) set_direction(WEST); break; #ifdef SNAKE2_RC_QUIT case SNAKE2_RC_QUIT: #endif case SNAKE2_QUIT: quit = 1; return; case SNAKE2_PLAYPAUSE: game_pause(); break; default: if (rb->default_event_handler(button)==SYS_USB_CONNECTED) { quit = 2; return; } break; } } }