Log In  

I was wondering how I would go about making some flashing text for a game-over screen that reads "press z to try again". I tried using modulo however when I attempted this it would display the text for one frame and then show (about) 30 empty frames.

Any help on a simple and effective method would be greatly appreciated.

P#26485 2016-08-04 16:03 ( Edited 2016-09-25 20:40)

:: briac

You can use something like this to achieve this effect:


function _draw()
  if (blink_flag) print "hello"
  if (blink_timer % 30 == 0) blink_flag=not blink_flag
P#26486 2016-08-04 16:35 ( Edited 2016-08-04 20:41)

or some binary magic:

if (band(frame,32)!=0) print "hello"

will blink ~ every second @60hz (use 16 @30fps)

P#26487 2016-08-04 17:10 ( Edited 2016-08-04 21:10)

Here's my super simplistic method for random flashing color text....

PRINT ("GAME OVER",50,50,RND(16))

But I have been wondering how to get text to flash back and forth between 2 colors, like red and blue... for example.

P#29350 2016-09-25 01:36 ( Edited 2016-09-25 05:36)
:: dw817

BAND is a powerful command I must admit. I need to explore it at some point. However, I tend to use MOD for my timing works.

cls() n=0
circfill(0,0,90,5) -- show overlay effect
  if (n%16<8) color(7)
  print("g a m e",48,60)
  print("o v e r",48,68)
  print("press z to try again",24,76)
until btn(4)
P#29351 2016-09-25 01:53 ( Edited 2016-09-25 06:10)

Tiny additional point that actually resetting the counter avoids weirdness at the integer overflow boundary:

n = (n + 1) % 10
color(n == 0 and 1 or 7)

Technically this is also avoided if your frame count is a power of 2, but so far I've found I want more control than that. Resetting also means maintaining a separate counter per effect, which may or may not meet your needs.

P#29386 2016-09-25 14:15 ( Edited 2016-09-25 18:15)
:: dw817

Good point, DDDaaannn. It is possible to let my demo run undisturbed for 18-minutes, yeah, after that it will likely mess up.

P#29397 2016-09-25 16:40 ( Edited 2016-09-25 20:40)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-01-20 13:12 | 0.039s | 2097k | Q:26