Author Topic: sprcoll and zoom functions  (Read 4178 times)

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
sprcoll and zoom functions
« 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?
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5116
  • O Rly?
    • View Profile
Re: sprcoll and zoom functions
« Reply #1 on: 2008-Jun-10 »
Use tilemaps, much simpler and very handy to use !
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1793
    • View Profile
    • Homepage
Re: sprcoll and zoom functions
« Reply #2 on: 2008-Jun-10 »
Have a look at this map editor: Mappy
It's realy easy to use and I wote a map-loader for it too so you can use them easily in GL-Basic.

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
Re: sprcoll and zoom functions
« Reply #3 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?
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10852
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: sprcoll and zoom functions
« Reply #4 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

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
Re: sprcoll and zoom functions
« Reply #5 on: 2008-Jun-10 »
Thanks for the advices.

Now I believe I´m in the right way to solve it.  =)
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!