UnderwareDESIGN

PlayBASIC => Beginners => Topic started by: Draco9898 on July 06, 2005, 05:17:16 AM

Title: Fast Flashing?
Post by: Draco9898 on July 06, 2005, 05:17:16 AM
I can't seem to get sprites to flash very quickly, they just end up not flashing a color unless I give it a few seconds to?  :blink:

And yes I'm alternating between Drawmode 2, and DrawMode 2+1024...I'm trying to flash a sprite on/off within a few split seconds

And yes I've prepared the sprites image for FX too, so I don't know what the problem is unless mode changing is a processor intensive process?
Title: Fast Flashing?
Post by: Draco9898 on July 06, 2005, 05:55:12 AM
Hmm nevermind, but my code is acting really weird...huh...*shrugs*

Isn't weird how something won't work in your main project, then you try again from scratch in a new file and it works fine? Heh :)

[pbcode]
CreateImage 1,200,200: RenderToImage 1
BoxC 0,0,200,200,1,RGB(255, 17, 17)
RenderToScreen: PrepareFXImage 1
CreateSprite 1: SpriteImage 1,1: PositionSprite 1,200,200: SpriteDrawMode 1,2
Do
   Cls 0
   Text 10,10,MyFlag
   DrawSprite 1
   MyTime#=MyTime#+1
   If MyTime#>10
 MyTime#=0
 If MyFlag=0
    MyFlag=1
    SpriteDrawMode 1,2
 Else
    MyFlag=0
    SpriteDrawMode 1,2+1024
 EndIf
   EndIf
Sync
Loop
[/code]


Works good for 100's of boxes too:
[code]
HowMany=900
Type tFBoxes
   FlashFlag, Time#
EndType
Dim FBoxes(HowMany) As tFBoxes

CreateImage 1,20,20: RenderToImage 1
BoxC 0,0,200,200,1,RGB(255, 17, 17)
RenderToScreen: PrepareFXImage 1

For X=1 To HowMany
   CreateSprite X: SpriteImage X,1: PositionSprite X,Rnd(GetScreenWidth()),Rnd(400)+100
   SpriteDrawMode X,2: SpriteFlashColour X,RGB(Rnd(255),Rnd(255),0)
Next x   

Do
   Cls 0
   Text 10,10,FPS()
   
   DrawAllSprites
   
   For X=1 To HowMany
 FBoxes(X).Time#=FBoxes(X).Time#+1
 If FBoxes(X).Time#>Rnd(50)
    FBoxes(X).Time#=0
    If FBoxes(X).FlashFlag=0
   FBoxes(X).FlashFlag=1
   SpriteDrawMode X,2
    Else
   FBoxes(X).FlashFlag=0
   SpriteDrawMode X,2+1024
    EndIf
 EndIf
   Next X
Sync
Loop
[/pbcode]
It works, sorry bout' that