Challenge #4 - Real Time Flaming Torch (Game Effects)

Started by kevin, February 09, 2007, 10:59:10 AM

Previous topic - Next topic

kevin





Challenge #4 - Real Time Flaming Torch  (Game Effects)



    This months challenge is to create a fire effect.  The fire in turned will be used to create a flaming torch.  You know, those things the villagers hold while their round up a pose at night, or that you find in caves/tunnels in most games. 

    Your example should show as many torches as you can manage, the more the better, but lets try and keep the FPS over say 30fps.    Also, you can include a backdrop & characters if you like.  Good Luck !



  Fire/Flame Effects Links ?

  * None - Will find some later :)





Submission

* Submissions can be written in any version of PlayBasic

* Submission can only be accepted in Source Code form only.

* Authors can use external Media (images/music) provided you created the media, have permission to use somebody else's media or the media is public domain.

* Zip up your Submissions and please try to keep it smaller than 500K !

* Authors automatically give consent for their submission(s) to distributed and used for promotional purposes via UnderwareDesign.com, PlayBasic code tank.

* Authors can submit as many times as they like.

* To make a submission, zip up your projects source code + media and either post it in this thread, or create your own a thread the Source Codes or Show Case forums and post a link bellow.



Dead Line

No dead line, no time limits.. Lets just see how creative you are :)



Ian Price

I came. I saw. I played some Nintendo.

kevin

Ian,

  It's a coincidence surely..  hmm does make  you wonder where the other challenges come from ? :)


Torch Flames

 Here's a procedural flames effect that can be used to create some flaming torch things.. My old school Duron 800 machine will run 45 of them in 800*600*16 in full screen exclusive.  

  Get Torch Flame Code (login required)  (Version for PB1.63 and bellow)

  Torch Flame Code Update (login required) for PB1.64


Ian Price

I did wonder TBH ;)

Interesting code there, although it's a lot more complex than my version.

Added my version to the Code Tank (login required)

It looks better running than in the screenie (honest!), and it looks nicer still in 800x600


Highest Stats (32bit Full Screen)

640x480 - 100 torches - 458FPS
800x600 - 100 torches - 329FPS



Highest Stats (16bit Full Screen)

640x480 - 100 torches - 781FPS
800x600 - 100 torches - 599FPS
I came. I saw. I played some Nintendo.

Draco9898

I had a little too much fun and it ended up just being a bunch of animated sprites/particles...maybe I'll apply it to some sprite torches later

WinXp HOME edition- Spack 1; 2.41 gighertz Intel Processor; Geforce FX 5200 graphics processor; 512 mb Ram; Direct X 9c
I only get 382 fps @ 100 particles  :'(
74 fps @ 1200 particles
35 fps @ 2600 particles

PlayBASIC Code: [Select]
; PROJECT : Flames
; AUTHOR : Trev/Draco9898/"DragonBytes"
; CREATED : 2/9/2007
; EDITED : 2/10/2007
; ---------------------------------------------------------------------
OpenScreen 640,480,16,2
`SetFPS 60
Dim FlameImgs(5)
RipImage("Image1.png",FlameImgs(),1,5,0,0,12,16,12,0)

`Create Particle Sprites
Type tPrtcles
X#,Y#, Alpha#
XVelo#, YVelo#
SprNum, grpNum
Life
FrameCnt,CurFrm
EndType
ThisMany=100
Dim Prtcles(ThisMany) As tPrtcles
`Init Particle Sprites
For X=0 To ThisMany
Prtcles(X).SprNum=GetFreeSprite()
CreateSprite Prtcles(X).SprNum
InitParticles(X)
Next X

CreateCamera 1

Do
CaptureToScene: ClsScene
ThisFps=Fps()
Text 10,10,"FPS="+STR$(ThisFPS)
Text 10,20,STR$(ThisMany)+" particles"


`Step particles
For X=0 To ThisMany
Prtcles(X).X#=Prtcles(X).X#-Prtcles(X).XVelo#
Prtcles(X).YVelo#=Prtcles(X).YVelo#-0.01
Prtcles(X).Y#=Prtcles(X).Y#-Prtcles(X).YVelo#
`Particles animate
Prtcles(X).FrameCnt=Prtcles(X).FrameCnt+1
If Prtcles(X).FrameCnt>4
Prtcles(X).FrameCnt=0
Prtcles(X).CurFrm=Prtcles(X).CurFrm+1
If Prtcles(X).CurFrm>5
Prtcles(X).CurFrm=3
SpriteImage Prtcles(X).SprNum,FlameImgs(Prtcles(X).CurFrm)
Else
SpriteImage Prtcles(X).SprNum,FlameImgs(Prtcles(X).CurFrm)
EndIf
EndIf
`Particles die
Prtcles(X).Life=Prtcles(X).Life-1
If Prtcles(X).Life<=0
InitParticles(X)
EndIf
`Draw
PositionSprite Prtcles(X).SprNum,Prtcles(X).X#,Prtcles(X).Y#
DrawSprite Prtcles(X).SprNum
Next X

DrawCamera 1
Sync
Loop

Psub InitParticles(X)
Sine#=Sine#+0.08
Prtcles(X).X#=320+Sin(Sine#*14)*Cos(Sine#*2)*138
Prtcles(X).Y#=340-Cos(Sine#*14)*68
Prtcles(X).YVelo#=1
Prtcles(X).XVelo#=RndRange(-2,2)+(Sin(Sine#*22)*4)
Prtcles(X).XVelo#=Prtcles(X).XVelo#/6
Prtcles(X).Life=RndRange(10,151)
`reset animation
Prtcles(X).CurFrm=1: Prtcles(X).FrameCnt=0
SpriteImage Prtcles(X).SprNum,FlameImgs(Prtcles(X).CurFrm)
EndPsub

`Handle Image Ripping
Psub RipImage(LoadImage$,ImageArray(),StartImg,NumbImgs,X,Y,X2,Y2,StepX,StepY)
TempImg=GetFreeImage(): LoadImage LoadImage$,TempImg
RenderToImage TempImg
For I=1 To NumbImgs
NextX=StepX*(I-1)
NextY=StepY*(I-1)
ImageArray(StartImg+(I-1))=GetFreeImage()
GetImage ImageArray(StartImg+(I-1)),X+NextX,Y+NextY,X2+NextX,Y2+NextY
Next I
RenderToScreen
DeleteImage TempImg
EndPsub


DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

Ian Price

1008FPS for 100 particles on my AMD Athlon 64 3400+ (~2.4Ghz) Radeon 9800SE (256Mb), 1024Mb RAM.

Not bad though :)
I came. I saw. I played some Nintendo.

stef


RayRayTea2

#7
Here's what I managed to put together, not sure it qualifies as "CleverCoders", since it's basically the first thing I ever wrote in a way but anyway... It looks like this:


(I wanted to write "PlayBasic but didn't manage). I went with a super simple sprite based approach in order to get a nice framerate. Features: draw sprites according to their "depth", huge numbers of flames on screen, solid framerate.

Once you load it, position the cursor anywhere on the screen and press Space!
(Edit: formatting...)

ATLUS


micky4fun

Hi all

works great here HeyHey , had screen full of flames looked very pretty , all nice n smooth
i just changed the placing of flames to mousebutton , saved me loads of tapping spacebar haha

mick :)