Main Menu

Sprite ligntning ?

Started by Crystal Noir, May 18, 2008, 12:11:52 PM

Previous topic - Next topic

Crystal Noir

Hi all :)

I wonder, how to make a sprite lightning ? I mean, for example a flare (Png Image) ? I've found the alpha mode but not the lightening mode, how does it work with PlayBasic ?

To make for example fire or candle etc...

May be we have to use the 3D hardware support ? (1.71) I use the learning version at this time.

thx in advance :)

reno

J'utilise PB1.7x, et ce genre d'effet n'est pas encore dispo :'(
More games ? Go to my website :)
http://www.thereeteam.com/

Crystal Noir

#2
Pourtant dans la version learning on voit ce genre d'effet par ex 3d alpha particle. Mais je pige pas comment ca marche. Enfin dans cet exemple c'est pas vraiment du lightning, mais de l'alpha, mais il me semble qu'elles ont un petit effet lumineux ces particules.

C'est bien dommage, si tu veux qu'on discute plus en détail, contactes moi par mp on pourra causer sur msn ;)

En fait normalement le lightning se fait avec le moteur 3D c'est pour ca que je demandais...


English version :

In the learning version we can see this type of effect for ex 3d alpha particle, but I don't understand how does it work :(
In fact, lightning is normaly made with a 3D hardware engine

Crystal Noir

so, does anyone have an idea  to help me ? :(

kevin


  You'll have to post and example, your question is a bit vague

reno

You have to :

1 - create a 3D sprite,
2 - set the drawing mode,


02 = RotationMode.
04 = AlphaMode. (Variable Alpha Blends the sprite image)
08 = AlphaBlend 50/50
16 = Alpha Addition


3 - use the sprite.

Also, see :
http://www.underwaredesign.com/forums/index.php?topic=2114.0

More modes to come... I hope ::)

PS : je t'ai envoyé un MP ;)
More games ? Go to my website :)
http://www.thereeteam.com/

Crystal Noir

#6
Yes but here, there isn't lightning mode, only alpha :)

QuoteYou'll have to post and example, your question is a bit vague

Here's a sample I've made with an another language (Purebasic).

I've compiled it in two versions :

- the first have the lightning
- the second doesn't have lightning.

This is a candle with a particle effect to make the flame.

With lightning, candle is great and realist, without, you simply have the particle with an alpha channel.

Kevin, test them and you will understand what I try to do with Playbasic :)

You can download these samples here : http://crystalnoir.free.fr/Creations/temp/lightning.zip

PS reno : je t'ai répondu en MP ;)

reno

More games ? Go to my website :)
http://www.thereeteam.com/

thaaks

Should be done using the alpha add mode (16). You need FX sprites for that. Look at the PB help for SpriteDrawMode.

Crystal Noir

I have already read help files about that ^^ but It doesn't work if you have a sample ^^...

thaaks

Hmmm,
I'm having trouble with using several blend modes at once (alpha add and alpha mode resp. alpha fade).

Anyway, I have some sample code that does at least something.

Maybe some experienced alpha mode coder can jump in. It uses the images of your zip file.


; PROJECT : Candle
; AUTHOR  : Thomas Haaks
; CREATED : 19.05.2008
; EDITED  : 20.05.2008
; ---------------------------------------------------------------------

Explicit On

Global candle = LoadNewImage("candle.jpg")
Global flare = LoadNewFxImage("flare.png")
ScaleImage flare, 0.3, 0.3, 0
Global imagex, imagey
Global flareTimer = 0

Type TParticle
x#,y#
yspeed#
sprIndex
alpha#
EndType

Dim FlameParticles(100) As TParticle

Global ParticleCounter = 0

SetFPS 60

TitleScreen "PlayBasic Candle"

imagex = 100
imagey = 100

Do
Cls 0
Print FPS()
Print Str$(ParticleCounter)
Inc flareTimer
If flareTimer > 1
addparticle(FlameParticles().TParticle, imagex+71, imagey+50)
flareTimer = 0
EndIf
updateparticles(FlameParticles().TParticle)
DrawImage candle, imagex, imagey, 0
DrawAllSprites
Sync
Loop


Psub addparticle(particles().TParticle,x#,y#)
Local index

index=GetFreeCell(particles())
particles(index).x=x#
particles(index).y=y#
particles(index).yspeed = -1; RndRange#(0.1, 0.5)
   particles(index).sprIndex = NewSprite(x#, y#, flare)
   particles(index).alpha = 1
   SpriteDrawMode particles(index).sprIndex, 2+16
;   SpriteTransparent particles(index).sprIndex, True
SpriteAlphaAddColour particles(index).sprIndex, RGB(0, 255,255)
   SpriteAlphaLevel particles(index).sprIndex, particles(index).alpha
CenterSpriteHandle particles(index).sprIndex
EndPsub

Psub updateparticles(particles().TParticle)
Local lp
LockBuffer
ParticleCounter = 0
For lp=0 To GetArrayElements(particles().TParticle,1)
If particles(lp)
Inc ParticleCounter
particles(lp).x = particles(lp).x + RndRange#(-1, 1)
particles(lp).y = particles(lp).y + particles(lp).yspeed
particles(lp).alpha = particles(lp).alpha - 0.03
   SpriteAlphaLevel particles(lp).sprIndex, particles(lp).alpha
If particles(lp).alpha <= 0
DeleteSprite particles(lp).sprIndex
particles(lp) = NULL
Else
PositionSprite particles(lp).sprIndex, particles(lp).x, particles(lp).y
EndIf
EndIf
Next
UnLockBuffer
EndPsub


Sorry as it's not yet properly working. But my PlayBasic skills are more than rusty...

Maybe you can post your PureBasic source code to get us started?

Cheers,
Tommy

Crystal Noir

yes ! it's almost the same :)

thaaks

So does it help you? Or do you still have problems?

Cheers,
Tommy

Crystal Noir

I will try to interprate my particle engine with playbasic and I will say to you what :D

kevin