is this possible ??
BlitzMax Forums/BlitzMax Programming/is this possible ??
| ||
i am looking for a way to flash text but leave it flashing whilst the program does other things a bit like the old Spectrum used to do i know the spectrum flash was run under interrupt via the rom but could this be possible in blitzmax ??? Lee |
| ||
Probably doable by hooking flip. From the docs:'This function will be automagically called every Flip Function MyHook:Object( id,data:Object,context:Object ) Global count count:+1 If count Mod 10=0 Print "Flips="+count End Function 'Add our hook to the system AddHook FlipHook,MyHook 'Some simple graphics Graphics 640,480,0 While Not KeyHit( KEY_ESCAPE ) Cls DrawText MouseX()+","+MouseY(),0,0 Flip Wend |
| ||
cheers for that dan :) i see where your coming from but i know its like a nostalgia thing but like the speccy it also used inverse to flash the text like a on / off idea thats what i mean :) |
| ||
Yeah, just put your text drawing code in the hook function, have it draw a rectangle and then some text on top and every second or so, swap the rectangle/text colours. |
| ||
your idea worked a treat but as the program progressed the flips speed-ed up its not constant nearly what i want but not quite there someone actually wrote a spectrum emulator on blitz i wonder how they emulated the the flash aspect would be interesting to see lee |
| ||
Don't swap the colours based on how many flips have happened, when you swap the colours, use Millisecs().'start of program FlashTime = Millisecs() FlashInterval = 1000 * 2 'replace the 2 with the number of seconds between flashes 'every flip if Millisecs() > FlashTime + FlashInterval then 'swap colours and do FlashTime = Millisecs() endif |
| ||
Also take care of having a constant "flip amount per second" (aka "FPS") - else you will have dynamically adjusted flash times. You could also have a timer based approach - this changes values according to a timer ticking ("labelOn = true/off"). Each time you draw the scene you then "if labelOn then Drawtext(label,...)". bye Ron |
| ||
I agree with Derron, though I would add that you need to use a modified timer for toggling the cursor "draw" flag, as you usually have a standard timer used for emitting rendering events. You can use this... http://www.blitzbasic.com/codearcs/codearcs.php?code=3138 ...in the following manner: |
| ||
wow guys cheers for the response , i will look into it and see what i can come up with its a shame i cant just create a gif and let blitz display it in the main loop i am in but that seems long winded for one little gif lol cheers lee |
| ||
i tried the above code only to get this Unable to convert from '<unknown>' to 'TTimer' that was from the Tcallbacktimer file lee |
| ||
On what line is that happening? It doesn't happen on mine. Are you sure that the example code is one separate file that imports 'TCallbackTimer.bmx?' Because no usage of TTimer is made in that import. |
| ||
its in here '; ID: 3138 '; Author: Kryzon '; Date: 2014-07-20 02:26:53 '; Title: Callback Timer '; Description: A modified BRL.Timer Object that on each tick calls a BlitzMax Function that you specify. Import BRL.Timer Type TCallbackTimer Method Ticks:Int() Return _ticks End Method Method Stop() If Not _handle Return bbTimerStop _handle,Self _handle=0 _func=Null _data=Null End Method it stops on the line bbtimerstop _handle,self when compiling cheers |
| ||
i am using a mac pro (but i don't think that will make a difference ) will it ?? Lee |
| ||
Oh, I realized what is the error. This was my oversight, I apologize. You need to modify your BlitzMax/mod/brl.mod/timer.mod/timer.bmx file. There's the following: Extern Function bbTimerStart( hertz#,timer:TTimer ) Function bbTimerStop( handle,timer:TTimer ) End ExternChange the "timer:TTimer" parameter to this: Extern Function bbTimerStart( hertz#,timer:Object ) Function bbTimerStop( handle,timer:Object ) End ExternYou changed it to be of type "Object." It still works the same, but now it will accept other types of object (such as that "callback timer"). |
| ||
yes it worked great cheers Lee B |