Making a Sprite Glow?
-
- Enthusiast
- Posts: 346
- Joined: Fri Oct 10, 2003 12:42 am
- Location: Tampa,FL,USA
- Contact:
Making a Sprite Glow?
Is there a way to make a sprite glow without slowing the program down much?
-
- Enthusiast
- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
the fastest would be to create a glow effect around the sprite with a series of animated sprites ... like these:



the glow sprites would be alphablended and rendered first then the main object sprite would be rendered on top of the glow .. the glow sprites would be animated through the sequence. Although their isn't much frames the effect looks just fine and is fairly simple.



the glow sprites would be alphablended and rendered first then the main object sprite would be rendered on top of the glow .. the glow sprites would be animated through the sequence. Although their isn't much frames the effect looks just fine and is fairly simple.
<br>"I deliver Justice, not Mercy"
    - Codemonger, 2004 A.D.
    - Codemonger, 2004 A.D.
-
- Enthusiast
- Posts: 346
- Joined: Fri Oct 10, 2003 12:42 am
- Location: Tampa,FL,USA
- Contact:
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
-
- Enthusiast
- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
This might help a bit, I whipped this up tonight. Heres a link to download the file with images included in exe as binaries
http://codemonger.com/uploads/CodeBlend.exe
heres the code .. uncommented as i just threw it together quickly... Also you could change the sprite3dblendmode to get some cool effects. Anyway hope this helps
http://codemonger.com/uploads/CodeBlend.exe
heres the code .. uncommented as i just threw it together quickly... Also you could change the sprite3dblendmode to get some cool effects. Anyway hope this helps

Code: Select all
Result = OpenWindow(0, 100, 200, 400, 400, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Codemonger Blend Test")
UseJPEGImageDecoder()
InitSprite()
InitSprite3D()
OpenWindowedScreen(Result, 0, 0, 400, 400, AutoStretch, 0, 0)
CatchSprite(0, ?CodemongerLogo,#PB_Sprite_Texture)
CatchSprite(1, ?RightArrow)
CatchSprite(2, ?RightGlow1,#PB_Sprite_Texture)
CatchSprite(3, ?RightGlow2,#PB_Sprite_Texture)
CatchSprite(4, ?RightGlow3,#PB_Sprite_Texture)
CatchSprite(5, ?RightGlow4,#PB_Sprite_Texture)
CreateSprite3D(0, 0)
CreateSprite3D(2, 2)
CreateSprite3D(3, 3)
CreateSprite3D(4, 4)
CreateSprite3D(5, 5)
GlowVar = 2
GlowMod = 1
Repeat
XOffset = WindowMouseX() - 11
YOffset = WindowMouseY() - 13
If CurrentTime - OldTime > 50
OldTime = CurrentTime
GlowVar = GlowVar + GlowMod
EndIf
Start3D()
ZoomSprite3D(0, 400, 400)
Sprite3DQuality(1)
DisplaySprite3D(0,0,0,255)
Sprite3DQuality(0)
Sprite3DBlendingMode(5, 7)
If GlowVar <> 1
DisplaySprite3D(GlowVar, -18+XOffset, -13+YOffset,255)
EndIf
Stop3D()
Select GlowVar
Case 5
GlowMod = -1
Case 1
GlowMod = 1
EndSelect
DisplayTransparentSprite(1,XOffset,YOffset)
FlipBuffers()
CurrentTime = timeGetTime_()
FPS = FPS + 1
If CurrentTime-OldFPSTime => 1000
FPSCount = FPS
FPS = 0
OldFPSTime = timeGetTime_()
EndIf
StartDrawing(WindowOutput())
DrawText("FPS: " + Str(FPSCount))
StopDrawing()
EventID.l = WindowEvent()
Until EventID = #PB_Event_CloseWindow
End
CodemongerLogo: IncludeBinary "CodemongerLogo.bmp"
RightGlow1: IncludeBinary "RightGlow1.jpg"
RightGlow2: IncludeBinary "RightGlow2.jpg"
RightGlow3: IncludeBinary "RightGlow3.jpg"
RightGlow4: IncludeBinary "RightGlow4.jpg"
RightArrow: IncludeBinary "RightArrow.bmp"
<br>"I deliver Justice, not Mercy"
    - Codemonger, 2004 A.D.
    - Codemonger, 2004 A.D.
-
- Enthusiast
- Posts: 346
- Joined: Fri Oct 10, 2003 12:42 am
- Location: Tampa,FL,USA
- Contact:
-
- Enthusiast
- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
-
- Enthusiast
- Posts: 346
- Joined: Fri Oct 10, 2003 12:42 am
- Location: Tampa,FL,USA
- Contact:
As a token of my thanks, I have created 2 small programs demonstrating what you have tought me about the glow effect. You can download them here:
http://www.1matthew.com/downloads/Samples.zip (about 40KB zipped)
Thanks again! I am going to make a game also using my newly learned glow effect and the ability to includebinary which I also picked up from your code.



http://www.1matthew.com/downloads/Samples.zip (about 40KB zipped)
Thanks again! I am going to make a game also using my newly learned glow effect and the ability to includebinary which I also picked up from your code.




Running demos

I have P4, 512MB ram and Fx5600 card.
-
- Enthusiast
- Posts: 346
- Joined: Fri Oct 10, 2003 12:42 am
- Location: Tampa,FL,USA
- Contact:
-
- Enthusiast
- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
DriakTravo very cool examples, makes for great plasma or laser effects

maybe you need your nvidia graphics drivers updated ... i have a fx5200 and works great here.Why is that I have problems getting a lot of example code to run on my machine? I was interested in this product but find that 50% of the game/graphics examples do not work!
I have P4, 512MB ram and Fx5600 card.
<br>"I deliver Justice, not Mercy"
    - Codemonger, 2004 A.D.
    - Codemonger, 2004 A.D.
-
- Enthusiast
- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
If you are having the same or similar problems as monkeyx pls refer to this thread
viewtopic.php?t=11717
viewtopic.php?t=11717
<br>"I deliver Justice, not Mercy"
    - Codemonger, 2004 A.D.
    - Codemonger, 2004 A.D.