blinking (flashing) text
Blitz3D Forums/Blitz3D Programming/blinking (flashing) text
| ||
I'm not sure what I'm asking for but here I go: In the short term goals, I want to create a function that blinks text on and off while the program takes care of other things within the game world. Do, For, and While loops will not work as they can create a endless looping construct which is bad programming practice that even intermediate programmers know about. If I were talking about C++ programming, I might be describing an Windows messaging routine, or if this was DOS, I might be describing an TSR, (Terminate and stay resident). In the long run of things (the big picture) I want this code to be re-useable so that I can use the code in other projects as well as this one. Any help will be appreciated! |
| ||
normaly your programm has a main loop between Repeat Cls Flip 1 Until KeyHit(1) If you want to do thing periodically you have to use a Millisecs() based timer: Global MyTime%=Millisecs() Repeat Cls If MyTime<Millisecs() MyTime =Millisecs()+ 500 ; Display something Endif Flip 1 Until KeyHit(1)If you display something here it will be displayed every 500msec for a short moment. Now we combine this with a On/Off-Flag: Global MyTime%=Millisecs() Global OnOffFlag%=0 Repeat Cls If MyTime<Millisecs() MyTime =Millisecs()+ 500 OnOffFlag=1-OnOffFlag Endif If OnOffFlag=1 ; Display something Endif Flip 1 Until KeyHit(1)Now every 500msec the flag switches from 0 to 1 and next time back from 1 to 0. As long as it is 1 something will be displayd -> blinking! If you do this with entitys, you can "blink" them by making them visible ore not: Global MyTime%=Millisecs() Cube=CreateCube() Global OnOffFlag%=0 Repeat Cls If MyTime<Millisecs() MyTime =Millisecs()+ 500 OnOffFlag=1-OnOffFlag If OnOffFlag=0 HideEntity Cube Else ShowEntity Cube Endif Endif Flip 1 Until KeyHit(1) |
| ||
Smooth version:k=Sin( Millisecs() mod 360 ) Color 255*k,255*k,255*k Text 0,0,"Blah" |
| ||
Thanks K, works perfectly! @Midimaster, Thank you as well. Hey did you read the other posting music software. I believe you were helping me solve a grid problem! |