[Cuis-dev] [ANN] Cuis-Smalltalk-RoadTrip idle game + a question on implementing a ZoomPanMorph

Ian Jeffries mail at ianjeffries.net
Thu Feb 29 10:02:56 PST 2024


Hi all,

I'm working on an idle game for learning geography. The first version of
it's up here: https://github.com/seagreen/Cuis-Smalltalk-RoadTrip

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.

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.

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.

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.

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.

Thanks for the help,
Ian Jeffries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240229/d7ca9dd3/attachment.htm>


More information about the Cuis-dev mailing list