GLBasic forum

Main forum => GLBasic - en => Topic started by: kaotiklabs on 2008-Jun-10

Title: sprcoll and zoom functions
Post by: kaotiklabs on 2008-Jun-10

Hi,

I´m coding a 2d top-down scrolling game. Kind of Gauntlet.
I´m using big sprites, 1024x768, same as in-game screen resolution. One for the background and one for colliding objects using transparency.

I want to zoom the backgrounds in order to save file space, but if I use strechsprite or zoomsprite collision borders aren´t updated to the new zoomed images.
I believe, sprcoll is only using the original image to do the calculations.

How could I solve it?
Title: Re: sprcoll and zoom functions
Post by: Schranz0r on 2008-Jun-10
Use tilemaps, much simpler and very handy to use !
Title: Re: sprcoll and zoom functions
Post by: Moru on 2008-Jun-10
Have a look at this map editor: Mappy (http://www.tilemap.co.uk/mappy.php)
It's realy easy to use and I wote a map-loader for it too so you can use them easily in GL-Basic.
Title: Re: sprcoll and zoom functions
Post by: kaotiklabs on 2008-Jun-10
Thanks for the advice, maybe your approach is better for my requirements.

Either way, will be useful if someone can through a bit of light on this.
Using zoomed or streched sprites is very common. So if sprcoll can only deal with the original sprite? How can we solve this?
Title: Re: sprcoll and zoom functions
Post by: Kitty Hello on 2008-Jun-10
Usually you don't do per pixel collisions. Especially not, when you have scaled images.
Then you try a circle-circle collision:

Code (glbasic) Select

FUNCTION CircCol: x1,y1,R1, x2,y2,R2
LOCAL dx, dy, dR
   dx=x2-x1
   dy=y2-y1
   dR=R2-R1
   IF dx*dx + dy*dy < dR*dR THEN RETURN TRUE
   RETURN FALSE
ENDFUNCTION

Title: Re: sprcoll and zoom functions
Post by: kaotiklabs on 2008-Jun-10
Thanks for the advices.

Now I believe I´m in the right way to solve it.  =)