Im writing a program where I need to do lots of collision checks per frame between a 32x32 pixel character and the background bitmap (1024x768 16bit depth).
However this is Really slow in Blitz Max. I wrote a test program and my program would only do about 28 of these collisions (debug build off) before dropping frames (at 60fps like all good arcade games).
However using the same program, but with collisions between a 32x32 square and another 32x32 square I could do about 3000 of these before dropping frames.
I thought I might be able to get around this by using GrabImage to grab the 32x32 piece of the background under the main character square - but this turns out to be really slow too.
I really think that the ImagesCollide function could be speeded up when doing a collision between a very large bitmap and a small bitmap, because surely it only needs to check a very small square of the larger image - the rest is irrevelent.
Would it also be possible to do a fast version of GrabImage?, because I could imagine situations where it would be time saving to grab parts of the background, and do collision checks on them.
I would be very happy with a faster ImagesCollide function though. Maybe someone could check if it is also slow on their computer - just in case it is my gfx card? Thank you :) Rico
Heres my code (Does anyone know why the timer doesn't work - I was trying to time the function. I'm still learning)
-change the ncol number to alter the number of collisions
-------------------------------------------------
However this is Really slow in Blitz Max. I wrote a test program and my program would only do about 28 of these collisions (debug build off) before dropping frames (at 60fps like all good arcade games).
However using the same program, but with collisions between a 32x32 square and another 32x32 square I could do about 3000 of these before dropping frames.
I thought I might be able to get around this by using GrabImage to grab the 32x32 piece of the background under the main character square - but this turns out to be really slow too.
I really think that the ImagesCollide function could be speeded up when doing a collision between a very large bitmap and a small bitmap, because surely it only needs to check a very small square of the larger image - the rest is irrevelent.
Would it also be possible to do a fast version of GrabImage?, because I could imagine situations where it would be time saving to grab parts of the background, and do collision checks on them.
I would be very happy with a faster ImagesCollide function though. Maybe someone could check if it is also slow on their computer - just in case it is my gfx card? Thank you :) Rico
Heres my code (Does anyone know why the timer doesn't work - I was trying to time the function. I'm still learning)
-change the ncol number to alter the number of collisions
-------------------------------------------------
Graphics 1024,768,16 DrawRect 0,0,32,32 image:TImage=CreateImage(32,32) image2:TImage=CreateImage(32,32) GrabImage(image,0,0,0) GrabImage(image2,0,0,0) back2= CreateImage(32,32) back:TImage=LoadImage("RMedia\backdropB.png") SetBlend SOLIDBLEND timer=CreateTimer(1000) Cls x=0;y=200;xv=1;ncol=28 Repeat DrawImage back,0,0 DrawText tm+" "+tm2,0,0 x=x+xv If x>992 Then x=992;xv=-xv If x<0 Then x=0;xv=-xv tm=TimerTicks(timer) For t=1 To ncol test=ImagesCollide(image,x,y,0,back,0,0,0) Next tm2=TimerTicks(timer)-tm DrawImage image,x,y,0 Flip 1 Until KeyDown(KEY_ESCAPE)Moderator Note: When posting code, please use the [code ] or [codebox ] tags. See the following FAQ article for more information: What are the forum codes?