UnderwareDESIGN

General => Competitions => CleverCoders => Topic started by: kevin on February 09, 2007, 10:59:10 AM

Title: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: kevin on February 09, 2007, 10:59:10 AM

(http://www.underwaredesign.com/PlayBasicSig.png) (http://www.playbasic.com)


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 (http://www.playbasic.com)

* 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 :)




Return to Challenge Index (http://www.underwaredesign.com/forums/index.php?topic=3225.0)

Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: Ian Price on February 09, 2007, 01:31:10 PM
Ha Ha! I wonder where this idea came from ;)
Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: kevin on February 12, 2007, 09:17:19 AM
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.  

  [plink] Get Torch Flame Code  (http://www.underwaredesign.com/pbct/pbct_dataview.php?key=50)[/plink]  (Version for PB1.63 and bellow)

  [plink] Torch Flame Code Update  (http://www.underwaredesign.com/forums/index.php?topic=3141.0)[/plink] for PB1.64

Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: Ian Price on February 12, 2007, 12:11:45 PM
I did wonder TBH ;)

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

Added my version to the [plink]Code Tank (http://www.underwaredesign.com/pbct/pbct_dataview.php?key=51)[/plink]

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
Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: Draco9898 on February 14, 2007, 06:50:23 AM
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

[pbcode]
; 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
[/pbcode]
Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: Ian Price on February 14, 2007, 07:52:51 AM
1008FPS for 100 particles on my AMD Athlon 64 3400+ (~2.4Ghz) Radeon 9800SE (256Mb), 1024Mb RAM.

Not bad though :)
Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: stef on February 14, 2007, 04:00:15 PM

Nice and fast stuff here! :)
Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: RayRayTea2 on February 20, 2013, 05:29:38 AM
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...)
Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: ATLUS on February 20, 2013, 07:29:17 AM
HeyHey, nice code i like it !
Title: Re: Challenge #4 - Real Time Flaming Torch (Game Effects)
Post by: micky4fun on February 20, 2013, 10:46:37 AM
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 :)