<div dir="ltr">Thank you for the reply! I think that's how panning and zooming is done almost all the time, but here I'm trying to keep the game and screen coordinates the same. Or rather I'm trying to keep the game coordinates in long/lat and also the local morph coordinates in long/lat, moving and scaling the morph on pan and zoom.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 29, 2024 at 4:27 PM Jon Hylands <<a href="mailto:jhylands@gmail.com">jhylands@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Ian,<br><div><br></div><div>I did something similar a few years ago, writing a python map editor for doing floor layout maps (it was for work - thus python).</div><div><br></div><div>I ran into the same issue. I ended up implementing a pair of transform functions, that take into account pan and zoom, and create a pair of lambda functions for points. One to transform from screen coordinates to map coordinates, and the other to do the opposite. Any time you need to switch coordinate systems, you use the transform functions.</div><div><br></div><div>I can show you the code if you really need to see it, but it's a lot of python 2.6 code running in tkinter, so it isn't as nice as Smalltalk.</div><div><br></div><div>- Jon</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 29 Feb 2024 at 13:03, Ian Jeffries via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I'm working on an idle game for learning geography. The first version of it's up here: <a href="https://github.com/seagreen/Cuis-Smalltalk-RoadTrip" target="_blank">https://github.com/seagreen/Cuis-Smalltalk-RoadTrip</a></div><div><br></div><div>It doesn't do much at the moment, there's just a car that noodles around between US cities. However I wanted to go ahead and publish it so I could get advice on the zooming and panning mechanism.</div><div><br></div><div>Previously when I've implemented zoom-and-pan everything was based on screen coordinates. On zoom-in I stored a new scaling factor, and then when drawing the game applied this scaling factor to the game coordinates to get screen coordinates. Easy enough.</div><div><br></div><div>For RoadTrip though I'm taking advantage of Cuis' local coordinate system to keep my coordinates in longitude and latitude all the way to the user's display. It's extremely neat the users can pull up the morph halo and see a grid in long/lat.</div><div><br></div><div>But this makes scaling "interesting". On zoom-in when I apply `scaleBy:` to the morph the US map wants to shoot up and to the left off the screen. I'm currently handling this by moving the `morphPosition` after each zoom to offset this, so that while scaleBy makes the map jump up and to the left, the morph itself moves within its parent down and to the right to make up for it, hopefully keeping the map at the same place.</div><div><br></div><div>Unfortunately I can't figure out how to make it exactly accurate and it jerks around a lot when zoomed in. Before putting more debugging work into this I wanted to ask if it seems like I'm on the right track or if I've missed something obvious.</div><div><br></div><div>Thanks for the help,</div><div>Ian Jeffries</div><div><br></div></div>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div>
</blockquote></div>