summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/boomshine.lua32
1 files changed, 24 insertions, 8 deletions
diff --git a/apps/plugins/boomshine.lua b/apps/plugins/boomshine.lua
index c160fddf0d..0d0f9c518a 100644
--- a/apps/plugins/boomshine.lua
+++ b/apps/plugins/boomshine.lua
@@ -313,7 +313,7 @@ function start_round(level, goal, nrBalls, total)
313end 313end
314 314
315-- Helper function to display a message 315-- Helper function to display a message
316function display_message(...) 316function display_message(to, ...)
317 local message = string.format(...) 317 local message = string.format(...)
318 local _, w, h = rb.font_getstringsize(message, rb.FONT_UI) 318 local _, w, h = rb.font_getstringsize(message, rb.FONT_UI)
319 local x, y = (rb.LCD_WIDTH - w) / 2, (rb.LCD_HEIGHT - h) / 2 319 local x, y = (rb.LCD_WIDTH - w) / 2, (rb.LCD_HEIGHT - h) / 2
@@ -321,13 +321,29 @@ function display_message(...)
321 rb.lcd_clear_display() 321 rb.lcd_clear_display()
322 set_foreground(DEFAULT_FOREGROUND_COLOR) 322 set_foreground(DEFAULT_FOREGROUND_COLOR)
323 if w > rb.LCD_WIDTH then 323 if w > rb.LCD_WIDTH then
324 rb.lcd_puts_scroll(x/w, y/h, message) 324 rb.lcd_puts_scroll(0, y/h, message)
325 else 325 else
326 rb.lcd_putsxy(x, y, message) 326 rb.lcd_putsxy(x, y, message)
327 end 327 end
328 if to == -1 then
329 local msg = "Press button to exit"
330 w = rb.font_getstringsize(msg, rb.FONT_UI)
331 x = (rb.LCD_WIDTH - w) / 2
332 if x < 0 then
333 rb.lcd_puts_scroll(0, y/h + 1, msg)
334 else
335 rb.lcd_putsxy(x, y + h, msg)
336 end
337 end
328 rb.lcd_update() 338 rb.lcd_update()
329 339
330 rb.sleep(rb.HZ * 2) 340 if to == -1 then
341 rb.sleep(rb.HZ/2)
342 rb.button_clear_queue()
343 rb.button_get(1)
344 else
345 rb.sleep(to)
346 end
331 347
332 rb.lcd_stop_scroll() -- Stop our scrolling message 348 rb.lcd_stop_scroll() -- Stop our scrolling message
333end 349end
@@ -341,26 +357,26 @@ local idx, highscore = 1, 0
341while levels[idx] ~= nil do 357while levels[idx] ~= nil do
342 local goal, nrBalls = levels[idx][1], levels[idx][2] 358 local goal, nrBalls = levels[idx][1], levels[idx][2]
343 359
344 display_message("Level %d: get %d out of %d balls", idx, goal, nrBalls) 360 display_message(rb.HZ*2, "Level %d: get %d out of %d balls", idx, goal, nrBalls)
345 361
346 local exit, score, nrExpandedBalls = start_round(idx, goal, nrBalls, highscore) 362 local exit, score, nrExpandedBalls = start_round(idx, goal, nrBalls, highscore)
347 if exit then 363 if exit then
348 break -- Exiting.. 364 break -- Exiting..
349 else 365 else
350 if nrExpandedBalls >= goal then 366 if nrExpandedBalls >= goal then
351 display_message("You won!") 367 display_message(rb.HZ*2, "You won!")
352 idx = idx + 1 368 idx = idx + 1
353 highscore = highscore + score 369 highscore = highscore + score
354 else 370 else
355 display_message("You lost!") 371 display_message(rb.HZ*2, "You lost!")
356 end 372 end
357 end 373 end
358end 374end
359 375
360if idx > #levels then 376if idx > #levels then
361 display_message("You finished the game with %d points!", highscore) 377 display_message(-1, "You finished the game with %d points!", highscore)
362else 378else
363 display_message("You made it till level %d with %d points!", idx, highscore) 379 display_message(-1, "You made it till level %d with %d points!", idx, highscore)
364end 380end
365 381
366-- Restore user backlight settings 382-- Restore user backlight settings