? Issue with zooming in on a specific area (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Contest results!

Issue with zooming in on a specific area

  • #1 ✎ 226 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength ACLS OPTION STRICT 'Vars... SPSET 0,0 SPHOME 0,8,8 SPSCALE 0,100,100 WHILE 1 STICK OUT CX,CY INC X%,CX*5 DEC Y%,CY*5 SPOFS 0,-X%,-Y% SPSCALE 0,SCALE%,SCALE% IF #R AND BUTTON(0) THEN INC SCALE% IF SCALE%>100 THEN SCALE%=100 ENDIF IF #L AND BUTTON(0) THEN DEC SCALE% IF SCALE%<1 THEN SCALE%=1 ENDIF VSYNC WEND Key: BRV3S3H4 When I zoom out of the galaxy map in my game, pan over to another location, and zoom back in, it always zooms back to the center. How can I get it to zoom in on a different area and zoom back out from it properly and what code can I add? If you zoom out with the L button, move the sprite (bg/map) elsewhere, and zoom back in the sprite scales as it should. How do I make the sprite move so that the area in the middle of the screen (200, 120) stays there when scaling the sprite up? Posted Edited by spaceturtles
  • #2 ✎ 477 SquareFingers Broadly: Keep track of the 'focus' location, that is, the part of the sprite that is at the center of the screen, in a pair of variables. Keep track of the zoom level in another variable. When dealing with the user inputs, don't use the sprite commands directly. Modify these variables instead. Once all the variables reflect the new position/zoom, then SPOFS by -FOCUSX*ZOOM/100, -FOCUSY*ZOOM/100, and SPSCALE by ZOOM. You may wish to add offsets to the focus location, or other modifications, but I hope this helps. Posted
  • #3 ✎ 226 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Ran into another problem. I applied this to my "galaxy" game and the zooming works but zoomed out it applies the scaling to the movement speed. Game:ZDB3VKHV How do I fix this? Posted Edited by spaceturtles
  • #4 ✎ 226 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength I think I'll solve the issue by using different display mechanics Posted