summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/solitaire.c61
1 files changed, 57 insertions, 4 deletions
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index c34bfe66a6..62105a096c 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -975,6 +975,8 @@ enum move move_card( unsigned char dest_col, unsigned char src_card )
975 if( src_card == NOT_A_CARD ) return MOVE_NOT_OK; 975 if( src_card == NOT_A_CARD ) return MOVE_NOT_OK;
976 /* you can't put a card back on the remains' stack */ 976 /* you can't put a card back on the remains' stack */
977 if( dest_col == REM_COL ) return MOVE_NOT_OK; 977 if( dest_col == REM_COL ) return MOVE_NOT_OK;
978 /* you can't move an unknown card */
979 if( !deck[src_card].known ) return MOVE_NOT_OK;
978 980
979 src_col = find_card_col( src_card ); 981 src_col = find_card_col( src_card );
980 dest_card = find_last_card( dest_col ); 982 dest_card = find_last_card( dest_col );
@@ -1091,11 +1093,62 @@ enum move move_card( unsigned char dest_col, unsigned char src_card )
1091 return MOVE_OK; 1093 return MOVE_OK;
1092} 1094}
1093 1095
1096enum { SOLITAIRE_WIN, SOLITAIRE_QUIT, SOLITAIRE_USB };
1097
1094/** 1098/**
1095 * The main game loop 1099 * Bouncing cards at the end of the game
1096 */ 1100 */
1101int bouncing_cards( void )
1102{
1103 int i, j, x, y, vx, vy, button;
1097 1104
1098enum { SOLITAIRE_WIN, SOLITAIRE_QUIT, SOLITAIRE_USB }; 1105 /* flush the button queue */
1106 while( ( button = rb->button_get( false ) ) != BUTTON_NONE )
1107 {
1108 if( rb->default_event_handler( button ) == SYS_USB_CONNECTED )
1109 return SOLITAIRE_USB;
1110 }
1111
1112 /* fun stuff :) */
1113 for( i = CARDS_PER_SUIT-1; i>=0; i-- )
1114 {
1115 for( j = 0; j < SUITS; j++ )
1116 {
1117 x = LCD_WIDTH-(CARD_WIDTH*4+8+MARGIN)+CARD_WIDTH*j+j*2+1;
1118 y = MARGIN;
1119
1120 vx = rb->rand()%8-5;
1121 if( !vx ) vx = -6;
1122
1123 vy = -rb->rand()%6;
1124
1125 while( x < LCD_WIDTH && x + CARD_WIDTH > 0 )
1126 {
1127 vy += 1;
1128 x += vx;
1129 y += vy;
1130 if( y + CARD_HEIGHT >= LCD_HEIGHT )
1131 {
1132 vy = -vy*3/4;
1133 y = LCD_HEIGHT - CARD_HEIGHT;
1134 }
1135 draw_card( deck[j*CARDS_PER_SUIT+i], x, y, false, false, false );
1136 rb->lcd_update();
1137
1138 button = rb->button_get( false );
1139 if( rb->default_event_handler( button ) == SYS_USB_CONNECTED )
1140 return SOLITAIRE_USB;
1141 if( button == SOL_QUIT || button == SOL_MOVE )
1142 return SOLITAIRE_WIN;
1143 }
1144 }
1145 }
1146 return SOLITAIRE_WIN;
1147}
1148
1149/**
1150 * The main game loop
1151 */
1099 1152
1100int solitaire( void ) 1153int solitaire( void )
1101{ 1154{
@@ -1160,8 +1213,8 @@ int solitaire( void )
1160 /* if there aren't any, that means you won :) */ 1213 /* if there aren't any, that means you won :) */
1161 if( biggest_col_length == 0 && rem == NOT_A_CARD ) 1214 if( biggest_col_length == 0 && rem == NOT_A_CARD )
1162 { 1215 {
1163 rb->splash( HZ*2, true, "You Won :)" ); 1216 rb->splash( HZ, true, "You Won :)" );
1164 return SOLITAIRE_WIN; 1217 return bouncing_cards();
1165 } 1218 }
1166 1219
1167 /* draw the columns */ 1220 /* draw the columns */