/* draws the toggled spots */ static void flipit_toggle(void) { spots[cursor_pos] = 1-spots[cursor_pos]; toggle[cursor_pos] = 1-toggle[cursor_pos]; draw_spot(cursor_pos); if (cursor_pos%5 > 0) { spots[cursor_pos-1] = 1-spots[cursor_pos-1]; draw_spot(cursor_pos-1); } if (cursor_pos%5 < 4) { spots[cursor_pos+1] = 1-spots[cursor_pos+1]; draw_spot(cursor_pos+1); } if (cursor_pos/5 > 0) { spots[cursor_pos-5] = 1-spots[cursor_pos-5]; draw_spot(cursor_pos-5); } if (cursor_pos/5 < 3) { spots[cursor_pos+5] = 1-spots[cursor_pos+5]; draw_spot(cursor_pos+5); } moves++; draw_info_panel(); if (flipit_finished()) clear_cursor(); }
void draw_lengths(float sman[SIZE],int length,float xcent,float ycent,int spots,float head_r,int color){ //draws a stickman based on its angle matrix, gfx_color(color,color,color); //center, whether you want spots, the length of int F; //the limbs, the radius of the head, and color float xp=xcent,yp=ycent,nx,ny; //(so you can make a grey one to show where last for(F=0;F<SIZE;F++){ //frame was) nx=xp+length*cos(sman[F]); ny=yp-length*sin(sman[F]); if(F==0||F==1||F==4||F==5||F==8||F==9||F==10||F==13||F==14){ draw_width(2.5,xp,yp,nx,ny); } if(spots==1){ if(F==0||F==1||F==2||F==5||F==6||F==9||F==10||F==11||F==14||F==15){ draw_spot(xp,yp,length/10,1,0,color); } if(F==17){ nx=xp+head_r*2*cos(sman[F]); ny=yp-head_r*2*sin(sman[F]); draw_spot(nx,ny,length/10,1,0,color); } } if(F==SIZE-1){ draw_spot(xp+(head_r)*cos(sman[F]),yp-(head_r)*sin(sman[F]),head_r,.3,1,color); } xp=nx; yp=ny; } }
static void draw_playfield(void) { int i, w; rb->lcd_clear_display(); rb->lcd_setfont(moves_font); #if LCD_WIDTH > LCD_HEIGHT rb->lcd_vline(IMAGE_WIDTH, 0, LCD_HEIGHT-1); w = rb->lcd_getstringsize("Moves", NULL, NULL); rb->lcd_putsxy((IMAGE_WIDTH+1+(LCD_WIDTH-IMAGE_WIDTH-1)/2) - w / 2, 10, "Moves"); rb->snprintf(s, sizeof(s), "%d", moves); w = rb->lcd_getstringsize(s, NULL, NULL); rb->lcd_putsxy((IMAGE_WIDTH+1+(LCD_WIDTH-IMAGE_WIDTH-1)/2) - w / 2, moves_y, s); #else (void)w; rb->lcd_hline(0, LCD_WIDTH-1, IMAGE_HEIGHT); rb->lcd_putsxyf(3, moves_y, "Moves: %d", moves); #endif /* draw spots to the lcd */ for (i=0; i<NUM_SPOTS; i++) draw_spot(spots[i], (i%SPOTS_X)*SPOTS_WIDTH, (i/SPOTS_X)*SPOTS_HEIGHT); rb->lcd_update(); }
/* move a piece in any direction */ static void move_spot(int x, int y) { int i, w; spots[hole] = spots[hole-x-SPOTS_X*y]; hole -= (x+SPOTS_X*y); moves++; rb->lcd_setfont(moves_font); #if LCD_WIDTH > LCD_HEIGHT rb->snprintf(s, sizeof(s), "%d", moves); w = rb->lcd_getstringsize(s, NULL, NULL); rb->lcd_putsxy((IMAGE_WIDTH+1+(LCD_WIDTH-IMAGE_WIDTH-1)/2) - w / 2, moves_y, s); #else (void)w; rb->snprintf(s, sizeof(s), "Moves: %d", moves); rb->lcd_putsxy(3, moves_y, s); #endif for(i=1;i<=4;i++) { draw_spot(HOLE_ID, (hole%SPOTS_X)*SPOTS_WIDTH, (hole/SPOTS_X)*SPOTS_HEIGHT); draw_spot(spots[hole], (hole%SPOTS_X)*SPOTS_WIDTH + (i*x*SPOTS_WIDTH)/5, (hole/SPOTS_X)*SPOTS_HEIGHT + (i*y*SPOTS_HEIGHT)/5); rb->lcd_update(); rb->sleep(HZ/50); } draw_spot(HOLE_ID, (hole%SPOTS_X)*SPOTS_WIDTH, (hole/SPOTS_X)*SPOTS_HEIGHT); draw_spot(spots[hole], ((hole%SPOTS_X)+x)*SPOTS_WIDTH, ((hole/SPOTS_X)+y)*SPOTS_HEIGHT); rb->lcd_update(); spots[hole] = HOLE_ID; }
/* initialize the board */ static void flipit_init(void) { int i; rb->lcd_clear_display(); for (i=0; i<20; i++) { spots[i]=1; toggle[i]=1; draw_spot(i); } rb->lcd_update(); for (i=0; i<20; i++) { cursor_pos = (rb->rand() % 20); flipit_toggle(); } cursor_pos = 0; draw_cursor(); moves = 0; draw_info_panel(); rb->lcd_update(); }
/* called function from outside */ enum plugin_status plugin_start(const void* parameter) { int i, rc; (void)parameter; #ifdef HAVE_LCD_COLOR rb->lcd_set_background(LCD_WHITE); rb->lcd_set_foreground(LCD_BLACK); #endif #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif rb->splash(HZ, "FlipIt!"); #ifdef HAVE_LCD_BITMAP /* print instructions */ rb->lcd_clear_display(); rb->lcd_setfont(FONT_SYSFIXED); #if CONFIG_KEYPAD == RECORDER_PAD rb->lcd_putsxy(2, 8, "[OFF] to stop"); rb->lcd_putsxy(2, 18, "[PLAY] toggle"); rb->lcd_putsxy(2, 28, "[F1] shuffle"); rb->lcd_putsxy(2, 38, "[F2] solution"); rb->lcd_putsxy(2, 48, "[F3] step by step"); #elif CONFIG_KEYPAD == ONDIO_PAD rb->lcd_putsxy(2, 8, "[OFF] to stop"); rb->lcd_putsxy(2, 18, "[MODE] toggle"); rb->lcd_putsxy(2, 28, "[M-LEFT] shuffle"); rb->lcd_putsxy(2, 38, "[M-UP] solution"); rb->lcd_putsxy(2, 48, "[M-RIGHT] step by step"); #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ (CONFIG_KEYPAD == IRIVER_H300_PAD) rb->lcd_putsxy(2, 8, "[STOP] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[MODE] shuffle"); rb->lcd_putsxy(2, 38, "[PLAY] solution"); rb->lcd_putsxy(2, 48, "[REC] step by step"); #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ (CONFIG_KEYPAD == IPOD_3G_PAD) || \ (CONFIG_KEYPAD == IPOD_1G2G_PAD) rb->lcd_putsxy(2, 8, "[S-MENU] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[S-LEFT] shuffle"); rb->lcd_putsxy(2, 38, "[S-PLAY] solution"); rb->lcd_putsxy(2, 48, "[S-RIGHT] step by step"); #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD rb->lcd_putsxy(2, 8, "[POWER] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[REC] shuffle"); rb->lcd_putsxy(2, 38, "[PLAY..] solution"); rb->lcd_putsxy(2, 48, "[PLAY] step by step"); #elif CONFIG_KEYPAD == GIGABEAT_PAD rb->lcd_putsxy(2, 8, "[POWER] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[MENU] shuffle"); rb->lcd_putsxy(2, 38, "[VOL+] solution"); rb->lcd_putsxy(2, 48, "[VOL-] step by step"); #elif CONFIG_KEYPAD == IRIVER_H10_PAD rb->lcd_putsxy(2, 8, "[POWER] to stop"); rb->lcd_putsxy(2, 18, "[REW] toggle"); rb->lcd_putsxy(2, 28, "[PL-LEFT] shuffle"); rb->lcd_putsxy(2, 38, "[PL-RIGHT] solution"); rb->lcd_putsxy(2, 48, "[PL-UP] step by step"); #elif CONFIG_KEYPAD == GIGABEAT_S_PAD rb->lcd_putsxy(2, 8, "[BACK] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[MENU] shuffle"); rb->lcd_putsxy(2, 38, "[VOL+] solution"); rb->lcd_putsxy(2, 48, "[VOL-] step by step"); #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ (CONFIG_KEYPAD == SANSA_C200_PAD) rb->lcd_putsxy(2, 8, "[POWER] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[REC-LEFT] shuffle"); rb->lcd_putsxy(2, 38, "[REC-RIGHT] solution"); rb->lcd_putsxy(2, 48, "[REC-SEL] step by step"); #elif CONFIG_KEYPAD == IAUDIO_M3_PAD rb->lcd_putsxy(2, 8, "[REC] to stop"); rb->lcd_putsxy(2, 18, "[PLAY] toggle"); rb->lcd_putsxy(2, 28, "[MODE] shuffle"); rb->lcd_putsxy(2, 38, "[MENU..] solution"); rb->lcd_putsxy(2, 48, "[MENU] step by step"); #endif #ifdef HAVE_TOUCHSCREEN rb->lcd_putsxy(2, 8, "[BOTTOMLEFT] to stop"); rb->lcd_putsxy(2, 18, "[CENTRE] toggle"); rb->lcd_putsxy(2, 28, "[TOPRIGHT] shuffle"); rb->lcd_putsxy(2, 38, "[BOTTOMLEFT] solution"); rb->lcd_putsxy(2, 48, "[BOTTOMRIGHT] step by step"); #endif rb->lcd_update(); #else /* HAVE_LCD_CHARCELLS */ if (!init_gfx()) return PLUGIN_ERROR; #endif rb->button_get_w_tmo(HZ*3); rb->lcd_clear_display(); draw_info_panel(); for (i=0; i<20; i++) { spots[i]=1; draw_spot(i); } rb->lcd_update(); rb->sleep(HZ*3/2); rb->srand(*rb->current_tick); rc = flipit_loop(); #ifdef HAVE_LCD_CHARCELLS release_gfx(); #endif return rc; }
/* clear the cursor where it is */ static inline void clear_cursor(void) { draw_spot( cursor_pos ); }