Author Topic: Mouse move target question  (Read 256 times)

0 Members and 1 Guest are viewing this topic.

Offline AGKorson

Mouse move target question
« on: September 29, 2021, 02:44:21 PM »
This is really a more generic question, but I'll ask here because it relates to a current AGI project.

When a mouse is used to move ego, you click a spot on the screen, and ego moves to that spot. However, since ego has a non-zero width, what is the best way to position ego horizontally (in the X plane)? I can think of three options:

  • Easiest option is to just set ego's position to the targetX, regardless of where target is. But this means if you click to the RIGHT of ego, ego's left edge will move to the clicked location. This feels weird though - I expect ego's right edge to go where I click in that case.
  • Another option is to set ego's position to the targetX if clicking to LEFT of ego, but set it to targetX-width if clicking to RIGHT. If clicking in between left /right edges, ego's center is moved to target location. This feels a lot better to me than option 1.
  • A third option, similar to second, but instead of moving the center of ego to the targetX when clicking in between left/right edges of ego, just move ego vertically (ignore targetX in that case).

Any opinions on which option is best? I am leaning toward option 2, but I wonder if option 3 feels more natural to a player. Any other suggestions on positioning ego in the X-plane?



Offline Kawa

Re: Mouse move target question
« Reply #1 on: September 29, 2021, 03:53:04 PM »
4. Very roughly approximate what SCI does and aim at targetX-(width/2). This also matches what ScummVM does, which I'd dare guess is what for example the Atari and Mac ports did.

Offline AGKorson

Re: Mouse move target question
« Reply #2 on: September 30, 2021, 10:34:11 AM »
Oh yes, of course. That does make the most sense.   thx Kawa!

Offline MusicallyInspired

Re: Mouse move target question
« Reply #3 on: September 30, 2021, 02:13:21 PM »
I recall AGI Mouse and NAGI weren't quite as elegant and would cause Ego to move in such a way that it would traverse the x and y distances at the same time at the same intervals instead of dividing the smallest distance evenly between the longest distance. So if ego was moving 4 pixels up and 10 pixels right he would move in a perfect diagonal line by 4 pixels to the upper right and walk the rest of the 6 pixels straight across horizontally. SCI/ScummVM's method is much better.
Brass Lantern Prop Competition

Offline Kawa

Re: Mouse move target question
« Reply #4 on: September 30, 2021, 05:16:14 PM »
Or to put it shorter: AGI Mouse and NAGI didn't use the Bresenham algorithm.

Offline MusicallyInspired

Re: Mouse move target question
« Reply #5 on: September 30, 2021, 08:42:43 PM »
There's my missing terminology.
Brass Lantern Prop Competition

Offline AGKorson

Re: Mouse move target question
« Reply #6 on: October 01, 2021, 10:42:52 AM »
I recall AGI Mouse and NAGI weren't quite as elegant and would cause Ego to move in such a way that it would traverse the x and y distances at the same time at the same intervals instead of dividing the smallest distance evenly between the longest distance. So if ego was moving 4 pixels up and 10 pixels right he would move in a perfect diagonal line by 4 pixels to the upper right and walk the rest of the 6 pixels straight across horizontally. SCI/ScummVM's method is much better.

It's not just mouse movement - that's how all movement is handled in AGI - move.obj, follow.ego, etc. all move that way. It's because in each cycle, the interpreter 'forgets' where the original starting point was. I created my own algorithm to calculate the straightest path between two points, that is similar to the AGI line drawing algorithm- it uses only integer arithmetic, is extremely compact and works for any dx/dy, also handling different step sizes.

I've never heard of the Bresenham algorithm. I'll have to go check that out.


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.145 seconds with 23 queries.