Does imagesoverlap vs imagescollide still count?
Blitz3D Forums/Blitz3D Beginners Area/Does imagesoverlap vs imagescollide still count?
| ||
Dear all, For the umpteenth time, i'm trying to learn BB again and have come across collision detection. The book I'm reading suggests using imagesoverlap rather than imagescollide for speed. I understand why the science would favour imagesoverlap, but in this day of super speedy computers, if you're writing a simple space invaders or platform game, would the performance really take such a hit? I know I could suck it and see (which I will) but I wanted to know what you guys think. Toby |
| ||
The speed difference is most likely neglible on the majority of current computers (specifically gaming machines. Much ofthe documentation for Blitz relates to typical users with a preferred resolution around 800x768, possibly still requiring 16-bit colour depth and perhaps with limited graphical hardware acceleration and features. I suppose it's mainly relevant for determining your target audience. |
| ||
Nope. 2D graphics acceleration hasn't at advanced, if all, in the past 10 years? This piece of code demonstrates a verrrrrrrrrry slight difference, over 10,000,000 calls. I use a delay so the application setup doesn't affect the time. I get a difference of 75 milli-seconds over 10,000,000 calls. So thats... .0000075 milli-second difference between the two commands. Takes about 10 seconds to run. Graphics 800,600 SetBuffer BackBuffer() Delay 2000 ; delay for setup Global image = CreateImage(50,50) SetBuffer ImageBuffer(image) For loop = 0 To 1000 Color Rnd(0,255),Rnd(0,255),Rnd(0,255) Plot Rand(0,ImageWidth(image)),Rand(0,ImageHeight(image)) Next SetBuffer BackBuffer() Global timer = MilliSecs() For loop = 0 To 10000000 If ImagesCollide(image,Rnd(0,750),Rnd(0,550),0,image,Rnd(0,750),Rnd(0,550),0) Then b = 1 End If Next Global time_collide = MilliSecs() - timer timer = MilliSecs() For loop = 0 To 10000000 If ImagesOverlap(image,Rnd(0,750),Rnd(0,550),image,Rnd(0,750),Rnd(0,550)) Then b = 1 End If Next Global time_overlap = MilliSecs() - timer Text 0,0,"Time taken for 10,000,000 ImagesCollide() - "+time_collide+" millsecs()" Text 0,10,"Time taken for 10,000,000 ImagesOverlap() - "+time_overlap+" millsecs()" Flip WaitKey |
| ||
That's probably the most concise answer I've ever received (even the wife's "I do" was more measured!). I got about 90 difference on mine. I guess I don't need to worry too much. Many thanks, guys. Tobo |