summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/minesweeper.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index e60cfb4688..81ed24096a 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -234,6 +234,7 @@ void minesweeper_init(void){
234void minesweeper_putmines(int p, int x, int y){ 234void minesweeper_putmines(int p, int x, int y){
235 int i,j; 235 int i,j;
236 236
237 mine_num = 0;
237 for(i=0;i<height;i++){ 238 for(i=0;i<height;i++){
238 for(j=0;j<width;j++){ 239 for(j=0;j<width;j++){
239 if(rb->rand()%100<p && !(y==i && x==j)){ 240 if(rb->rand()%100<p && !(y==i && x==j)){
@@ -470,26 +471,33 @@ int minesweeper(void)
470/* plugin entry point */ 471/* plugin entry point */
471enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 472enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
472{ 473{
474 bool exit = false;
473 /* plugin init */ 475 /* plugin init */
474 TEST_PLUGIN_API(api); 476 TEST_PLUGIN_API(api);
475 (void)parameter; 477 (void)parameter;
476 rb = api; 478 rb = api;
477 /* end of plugin init */ 479 /* end of plugin init */
478 480
479 switch(minesweeper()){ 481 while(!exit) {
480 case MINESWEEPER_WIN: 482 switch(minesweeper()){
481 rb->splash(HZ*2, true, "You Win :)"); 483 case MINESWEEPER_WIN:
482 break; 484 rb->splash(HZ*2, true, "You Win :)");
483 485 break;
484 case MINESWEEPER_LOSE: 486
485 rb->splash(HZ*2, true, "You Lost :("); 487 case MINESWEEPER_LOSE:
486 break; 488 rb->splash(HZ*2, true, "You Lost :(");
487 489 break;
488 case MINESWEEPER_USB: 490
489 return PLUGIN_USB_CONNECTED; 491 case MINESWEEPER_USB:
490 492 return PLUGIN_USB_CONNECTED;
491 default: 493
492 break; 494 case MINESWEEPER_QUIT:
495 exit = true;
496 break;
497
498 default:
499 break;
500 }
493 } 501 }
494 502
495 return PLUGIN_OK; 503 return PLUGIN_OK;