single sprite, piece of cake! Zooming to a specific point, no problem. Doing all this on a tilemap of multiple images, TRICKY!
I think the hardest part for me was figuring out how to translate the scaled coordinates so the tiles still fit together properly. There's a small gap between tiles with a scale less than 1, might be a DBP float precision issue.
This demo will zoom in on a tilemap. The mouse coordinates represent the position of the map. The zoom always focuses on the center of the map.
Swap the image for whatever tile image you want to use for the demo, just make sure you input the dimensions for the tile size.
type ImageScaleProperties
sprt as integer
originalWidth as integer
originalHeight as integer
originalX as integer
originalY as integer
scale as float
img as integer
endtype
load image "c:\clouds.jpg", 1
rem setup a tile map
global mapWidth = 2
global mapHeight = 2
global mapOffsetX = 0
global mapOffsetY = 0
dim map(mapWidth, mapHeight) as ImageScaleProperties
tileWidth = 128
tileHeight = 128
rem set default map properties for each scalable tile
s = 0
for y = 0 to mapHeight-1
for x = 0 to mapWidth-1
inc s,1
map(x,y).sprt = s
map(x,y).scale = 1.0
map(x,y).originalWidth = tileWidth
map(x,y).originalHeight = tileHeight
map(x,y).originalX = x*tileWidth
map(x,y).originalY = y*tileHeight
map(x,y).img = 1
sprite s, mapOffsetX+map(x,y).originalX, mapOffsetY+map(x,y).originalY, map(x,y).img
next x
next y
sync on
sync rate 60
DO
if mousemovex() or mousemovey()
mapOffsetX = mousex()
mapOffsetY = mousey()
for y = 0 to mapHeight-1
for x = 0 to mapWidth-1
gosub _resizeSprite
next x
next y
endif
if upkey()
for y = 0 to mapHeight-1
for x = 0 to mapWidth-1
map(x,y).scale = map(x,y).scale + 0.01
gosub _resizeSprite
next x
next y
endif
if downkey()
for y = 0 to mapHeight-1
for x = 0 to mapWidth-1
map(x,y).scale = map(x,y).scale - 0.01
gosub _resizeSprite
next x
next y
endif
sync
LOOP
_resizeSprite:
w# = map(x,y).originalWidth
w# = w# * map(x,y).scale
h# = map(x,y).originalHeight
h# = h# * map(x,y).scale
size sprite map(x,y).sprt, w#, h#
wx# = (w#*mapWidth - map(x,y).originalWidth*mapWidth)/2
hy# = (h#*mapHeight - map(x,y).originalHeight*mapHeight)/2
offX = x*map(x,y).originalWidth * map(x,y).scale - wx#
offY = y*map(x,y).originalHeight * map(x,y).scale - hy#
sprite map(x,y).sprt, mapOffsetX+offX, mapOffsetY+offY, map(x,y).img
RETURN