Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: *SOLVED (well kinda :)* Four-directional movement  (Read 6629 times)

0 Members and 1 Guest are viewing this topic.

scutheotaku

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 15
    • View Profile
*SOLVED (well kinda :)* Four-directional movement
« on: July 31, 2009, 02:21:03 PM »

Hey guys,

First of all, I just wanted to say that this is a great engine and I'm really enjoying working with it. I still a newbie to it, but I've managed to make a few rooms and connect them all together, and it all seems pretty easy to work with.

Now, here's my question - Is there any way to make it so my actor only does movement in four directions? I know the whole thing on how you can define just four direction sprites and it will choose which one depending on the direction, but that's not quite what I mean. Here is an example to explain what I mean - Say I'm at coordinates (8,8) and I click to move my actor to coordinates (6,6). My actor would then (assuming there was nothing to block him anywhere) move to (8,6) then to (6,6), as opposed to go diagonally straight to (6,6).

Thanks!

-scutheotaku

[PS : The main reason I want to do this is because I'm not really the best artist in the world (well, I'm pretty good at things, but not at people and especially not at animation), and I can only manage to draw my actor going in four directions.]
« Last Edit: August 02, 2009, 03:22:22 AM by scutheotaku »
Logged
He who wonders discovers that this in itself is wonder.
    M. C. Escher

MMR

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 349
  • http://mmrdeveloper.wordpress.com/
    • View Profile
    • TinyWME
Re: Four-directional movement
« Reply #1 on: July 31, 2009, 06:27:06 PM »

If I've understood well you want your actor to go up first and later go left instead of going diagonally?
Logged

scutheotaku

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 15
    • View Profile
Re: Four-directional movement
« Reply #2 on: July 31, 2009, 06:28:33 PM »

Yep, exactly.

EDIT:
Is this even possible without changing the source code? The more I look through the manual, the more I think 8-directional is hard-coded into the source code.
« Last Edit: July 31, 2009, 06:38:34 PM by scutheotaku »
Logged
He who wonders discovers that this in itself is wonder.
    M. C. Escher

MMR

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 349
  • http://mmrdeveloper.wordpress.com/
    • View Profile
    • TinyWME
Re: Four-directional movement
« Reply #3 on: July 31, 2009, 08:19:19 PM »

Hummm, I guess this is hardcode so there's no possibility to do it without tricking a little bit with scripting. Even I think you should have to implement your own pathfinding algorithm in WME...

As far as I know WME implements some kind of A* algorithm for pathfinding because in 2D adventures the goal is to reach certain point following the optimal path and going up and then left as you've suggested is not a very optimal aproach for this.

If you want to look further on this topic there's an example of Dijkstra algorithm implementation in WME by "metamorphium" --> http://forum.dead-code.org/index.php?topic=723.0   :o
Logged

scutheotaku

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 15
    • View Profile
Re: Four-directional movement
« Reply #4 on: July 31, 2009, 08:46:07 PM »

Thanks. I think I'm just going to have to try and figure out how to draw my actors in 3/4.
Logged
He who wonders discovers that this in itself is wonder.
    M. C. Escher

Juan Bonair

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 33
    • View Profile
Re: Four-directional movement
« Reply #5 on: July 31, 2009, 09:13:43 PM »

There's a much more simpler solution to this, it's in the WME documentation.

Quote
Also, remember the actor is able to walk into eight directions, therefore you may need up to eight versions of each animation type for different directions. You don't necessarily need to define all eight directions if you don't want to, though. For example if your actor can only walk to four directions (common for smaller games), you can only define the four directions necessary. The engine will automatically choose the nearest defined direction. You should define at least one direction for each sprite set, though.
Logged

scutheotaku

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 15
    • View Profile
Re: Four-directional movement
« Reply #6 on: July 31, 2009, 09:27:32 PM »

Isn't this just talking about the animations? Because I have done that (only defined four), and my actor still walks diagonally but it triggers whichever sprite is closest to the direction (i.e. 160 degrees is the Left facing sprite, 20 degrees is the Right facing sprite, 135 degrees is the Up facing sprite, etc...). If I'm wrong, please correct me ;D
Logged
He who wonders discovers that this in itself is wonder.
    M. C. Escher

MMR

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 349
  • http://mmrdeveloper.wordpress.com/
    • View Profile
    • TinyWME
Re: Four-directional movement
« Reply #7 on: July 31, 2009, 10:14:01 PM »

@Juan Bonair: We were talking about another stuff, not using the 4 directions that WME implements but using another aproach that only use Up, Down, Left and Right directions with no diagonals.

 ::rock
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Four-directional movement
« Reply #8 on: August 01, 2009, 10:06:19 PM »

You could fake the straight movement by overriding the GoTo method and converting it to two straight-line GoTos. But I think you will find the result looks much less natural than what Juan Bonair suggests.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

MrMyro

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
Re: *SOLVED (well kinda :)* Four-directional movement
« Reply #9 on: September 03, 2009, 07:27:15 PM »

If I understand correctly, you mean you're wanting your character to move like on a chess board, only moving up/down or left/right, but never together?

Is there any way of saying move your character only on the x-axis or only on the y-axis until it equals the x or y value of the point they're moving to?

I'm not sure if this would be possible in the coding, but you'd need it to say something along the lines of:

if actor's X coordinate is less or more than that of the point clicked, increase or decrease the actor's X position until equal.

Then do the same for the Y coordinate (but make sure it does one THEN the other, otherwise you'll just end up with the standard movement).

This sounds like it would be far too much effort for the required effect, but if you manage to get it figured out, please post it and let us all know!
Logged
 

Page created in 0.043 seconds with 21 queries.