Author Topic: Mouse move target question  (Read 4233 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.

Offline klownstein

Re: Mouse move target question
« Reply #7 on: January 04, 2022, 12:28:16 AM »
AGKorson,
Would you be willing to share your algorithm and/or code to move AGI objects in the straightest path (as opposed to what move.obj does)? I have been using the move.obj command recently for objects that the ego is supposed to be throwing and am almost always disappointed with the results. Depending on where ego is, it sometimes doesn't look too bad. But, when ego is too close to where the end target is, the objects look like they get hit by an anti-gravity beam and levitate up at what should be the end of their trajectory.

As to your original question, I think that option 2 (moves to left if clicked left of ego, right if clicked right of ego, and center of ego moves to where the player clicks if in between) would be the most intuitive to me as a player. Thanks!
-klownstein

Offline AGKorson

Re: Mouse move target question
« Reply #8 on: January 04, 2022, 10:54:36 AM »
AGKorson,
Would you be willing to share your algorithm and/or code to move AGI objects in the straightest path (as opposed to what move.obj does)? I have been using the move.obj command recently for objects that the ego is supposed to be throwing and am almost always disappointed with the results. Depending on where ego is, it sometimes doesn't look too bad. But, when ego is too close to where the end target is, the objects look like they get hit by an anti-gravity beam and levitate up at what should be the end of their trajectory.

As to your original question, I think that option 2 (moves to left if clicked left of ego, right if clicked right of ego, and center of ego moves to where the player clicks if in between) would be the most intuitive to me as a player. Thanks!
-klownstein

I can. But it is currently written in assembly language. Before you ask 'WTF?? Assembly???', let me just say that it's part of a larger project I'm working on, and I'm not yet ready for the 'big reveal'. I hope to have something within the next month.

In the meantime, I can provide you with the assembly code, along with an explanation of the algorithm to see if it's helpful to you. I'll PM you later today when I have more time after work.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.027 seconds with 23 queries.