UnderwareDESIGN

PlayBASIC => Resources => Source Codes => Topic started by: kevin on August 15, 2003, 06:07:56 PM

Title: 500 Rebound Sprites
Post by: kevin on August 15, 2003, 06:07:56 PM
Speed TEST:


500 Rebound Sprite test. Display: 800*600*16 (Full screen exclusive) Sprite Size: 64*64

Play Basic : 43 Fps
Dark Basic Professional: 32 Fps
Dark Basic : 8 Fps

(Test machine Duron 800, GF2 mx 200.... Source Code available Bellow)





[pbcode]

` +====================================================*
`
`        >> PlayBASIC Alpha V1.15 Sprite Test <<
`
`
`               Demo Information:
`               =================
`
`              Sprite Size: 64*64
`        NUmber of Sprites: 500
`              Screen Size: 800 * 600
`             Screen Depth: 16bit
`
`                 Performance:
`                 ============
`
`      43 fps,  On Duron 800, Win Me, GF2mx 200
`
`
` +====================================================*

   cd ".."

   loadimage currentdir$()+"gfx\bubble_64x64.bmp",1


   starsN = 500

   Type Bubble
 x as float
 y as float
 XSpeed as Float
 Yspeed as Float
   EndType

   Dim Stars(StarsN) as Bubble
   
   for starsI=1 to starsN
 stars(starsI).x = rnd(800)
 stars(starsI).y = rnd(600)
 stars(starsI).xspeed = rnd(5)
 stars(starsI).yspeed = rnd(5)

 createsprite starsI
 spriteimage starsI,1
 positionsprite starsI,starsX,starxY
   next starsI

do

   cls 0
   
   inc frames

 for starsI=1 to starsN
    x#=stars(starsI).x+stars(starsI).xspeed
    Y#=stars(starsI).y+stars(starsI).Yspeed

    if X#<0 or X#>800
   stars(starsI).xspeed=stars(starsI).xspeed*-1
    endif
 
    if Y#<0 or Y#>600
   stars(starsI).yspeed=stars(starsI).yspeed*-1
    endif

    positionsprite starsI,x#,y#
 
    stars(starsI).x=x#
    stars(starsI).Y=y#
 next starsI

 DrawAllSprites
   
   if timer()-starttime>1000 then starttime=timer() : fps=frames : frames=0
   centertext 400,20,"FRAMERATE: "+STR$(fps)
   sync

loop
[/pbcode]

Title: 500 Rebound Sprites
Post by: kevin on August 17, 2003, 10:15:40 AM
Dark Basic and Dark Basic Pro version.






sync on
sync rate 0
cd ".."
  load image "gfx\bubble_64x64.bmp",1

  starsN = 500


  Dim Starsx#(StarsN)
  Dim Starsy#(StarsN)
  Dim Starsxspeed#(StarsN)
  Dim Starsyspeed#(StarsN)

  for starsI=1 to starsN
     starsx#(starsi) = rnd(800)
     starsy#(starsi) = rnd(600)
     starsxspeed#(starsi) = rnd(5)
     starsyspeed#(starsi) = rnd(5)

     sprite starsI,starsX,starxY,1
     set sprite starsi,0,1
  next starsI

do

  cls 0

  inc frames

     for starsI=1 to starsN

        x#=starsx#(starsi)+starsxspeed#(starsi)
        y#=starsy#(starsi)+starsyspeed#(starsi)


        if X#<0 or X#>800
           starsxspeed#(starsi)=starsxspeed#(starsi)*-1

        endif

        if Y#<0 or Y#>600
           starsyspeed#(starsi)=starsyspeed#(starsi)*-1
        endif

        sprite starsI,x#,y#,1

        starsx#(starsi)=x#
        starsy#(starsi)=y#

     next starsI

  if timer()-starttime>1000 then starttime=timer() : fps=frames : frames=0
  center text 400,20,"FRAMERATE: "+STR$(fps)
  sync

loop