Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Isometric Movement

Author
Message
sprcoll
12
Years of Service
User Offline
Joined: 26th Aug 2012
Location:
Posted: 6th May 2016 20:12
Hello all together,
i would be happy, if someone will help by the following thing. I want to make a game with isometric view. For the movement i press a button and then the sprite goes to this position. I know, there are many ways to do that.
I think that a good method for the movement is to move the sprites with vectors, but then, there are to many directions in which the sprite can move. If i move with fix pixels on each frame the movement (the stop) isn´t exactly.
Is there maybe another method? How would the experienced users of you, do that? Which way is better?
Thank you for your postings.
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 8th May 2016 14:24
I generally use physics when moving sprites.

Just use
and change X and Y using trigonometry (cos/sin).

For example, this is how I move the player in my isometric project:


Hope this helps
cheers
sprcoll
12
Years of Service
User Offline
Joined: 26th Aug 2012
Location:
Posted: 9th May 2016 19:30
Thank you for your reply,
i have to learn some more things. In the past i have learned many things about vectors, so an example with vectors would be better for me. I would work with the gradient between two vectors and then either bigger or smaler.
But as described above i always have too many directions in which the sprite can move. i move the sprites similar to the example in the agk manual.
Is there a way to do that with vectors?
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 9th May 2016 22:45 Edited at: 9th May 2016 22:48
I'm not really sure what you mean. The code I supplied uses 2D vectors - though maybe not so explicitly.

Generally you have 8 different directions in which you can move in isometric games.


The following calculation:
will return values in 45° intervals for
returns either 1 or 0 (Input.Down,Up,Left and Right are set using this command).

This leaves you with 8 different cases:


The next step is to convert these angles to fit your isometric grid. Trigonometry will tell you what angle the grid is offset by. In my case the diagonal movements had to be altered by ATan ( 0.5 ).

If you want to limit the directions, check the input.

The last step is to find the X and Y component of the 2D direction vector.

This is done using simple trigonometry again, and the resulting X and Y components are passed into the physics function to move the sprite.

Hope this is a little clearer.
cheers
MASTER OF PUPPETS
20
Years of Service
User Offline
Joined: 9th Jun 2004
Location: Trapped Under Ice
Posted: 10th May 2016 00:21
You mentioned that the stop isn't exact in your first post... Are you trying to move the sprite by varying distances (like Diablo),
or on a fixed tile grid where the Start / Stop positions (XY move distance) can be seen in advance (like moving a pawn in chess)?



|,,|, ,|,,|
sprcoll
12
Years of Service
User Offline
Joined: 26th Aug 2012
Location:
Posted: 10th May 2016 20:41
Ok, i see i have to learn trigonometry. To the movement, i need a simple movement with 8 directions, like command and conquer.
I started to do this by calculate a gradient (m=vector_y / vector_x) and then move with fix pixel on x and y.
But with my method, when i press a button on the target position, i have to choose the nearest direction and then load the sprite and then move the sprite.
So, it isn´t exactly.
I will try to use the code from Paronamixxe or something similar.

Login to post a reply

Server time is: 2024-11-25 08:56:52
Your offset time is: 2024-11-25 08:56:52