Community

AGI Programming => AGI Development Tools => Topic started by: AGKorson on September 29, 2021, 02:44:21 PM

Title: Mouse move target question
Post by: AGKorson 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:


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?
Title: Re: Mouse move target question
Post by: Kawa 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.
Title: Re: Mouse move target question
Post by: AGKorson on September 30, 2021, 10:34:11 AM
Oh yes, of course. That does make the most sense.   thx Kawa!
Title: Re: Mouse move target question
Post by: MusicallyInspired 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.
Title: Re: Mouse move target question
Post by: Kawa on September 30, 2021, 05:16:14 PM
Or to put it shorter: AGI Mouse and NAGI didn't use the Bresenham algorithm.
Title: Re: Mouse move target question
Post by: MusicallyInspired on September 30, 2021, 08:42:43 PM
There's my missing terminology.
Title: Re: Mouse move target question
Post by: AGKorson 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.
Title: Re: Mouse move target question
Post by: klownstein 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
Title: Re: Mouse move target question
Post by: AGKorson 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.