Moving sprite w/ animation in isometric tilemap

  • Hello everyone,

    I have an isometric map w/ an animated sprite, in which I intend to walk from one square to another, but after 2 days, I could not find the right way of doing it.

    This is what I have so far: https://db.tt/rngHGcfl

    Could somebody please point me the right direction or a tutorial on how to achieve it? The walking should be grid based.

    Thanks in advance.

  • I am building something like that too.

    board game development

    Pin hidden movertiles around the player, which should exactly overlap your background tile. (same size etc) These are indicators as to where or how many steps a player can make/move.

    Then, on click movertile, have the player move to the movertile.imagepointX(0) and movertile.imagepointY(0) (the exact center of the tile)

    I put the x,y coordinate in some temp variables, cos as soon as the player moves the movertile location changes too.

  • Great!

    I just need, now, to digest some of the concepts, since they are still a bit abstract, but the effect is very nice.

  • btw, here is a little tip to make isometric tiles easy to place.

    Simply set a grid size half of your tiles size. (half width, half height)

    Activate snap to grid.

    Now when you move tiles around on your laout, they easily snap right next to another tile, pixel precise ;)

  • Which event did you use for movement? The snap to grid tip is awesome, I configured it all, but movement has been a pain!

  • I use the center of the tiles and mover objects, their image origin points to be precise (object.imagepointX(0) and object.imagepointY(0))

    When i click a tile which is eligible to have my object move to, I fetch the X,Y of the image points (from click on tile) and set that in 2 instance variable of the object needing to move (lets call them targetx and targety).

    on click tile

    set object.targetx = int(tile.imagepointX(0))

    set object.targety = int(tile.imagepointY(0))

    Then, I have my object.X and object.Y to compare to the object.targetx and object.targety

    Either during a loop or with every tick, you can now determine if the target locations are different from the object x,y location, and if so move.

    crude example:

    every tick

    compare 2 variables

    int(object.x) not equal to object.targetx

    compare 2 variables

    int(object.y) not equal to object.targety

    action:

    object move at angle

    angle: angle(object.x,object.y,object.targetx,object.tagety)

    pixels to move: 50 * dt

    This simply checks if the object x,y is differrent form the target x,y and moves towards the propper position.

  • Thank you very much for the help/patience.

    Would you think a performance hit could happen if I spawn multiple instances of the main sprite that should move to random directions?

  • It depends on how it is used/applied.

    generally you should be able to add 100s of those kind of objects, but you would just need to process everything more efficient.

    I would loop through their instances instead of every tick wise, that sorta thing.

    But, you won't know it till you tried

    Good luck

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks a lot. I've managed to make it work except for the diagonals, which get a bit misaligned. Anyway, your guidance was nothing but great.

  • edit: oh, a doubble post by accident^^

    edit 2: seems the second post updates the first,...so it's weird^^

    Anyways, here an example, did you tried to achieve this isometric movement?

    https://dl.dropboxusercontent.com/u/26932498/howto/iso_walk/iso_walk.capx

  • Anyways, here an example, did you tried to achieve this isometric movement?

    https://dl.dropboxusercontent.com/u/26932498/howto/iso_walk/iso_walk.capx

    oohh, thats pretty smooth, simple, yet efffective.

    I like that switching method with groups, I use lots of simlair approaches

  • Thank you!

    If there are any questions, related isometric movement or so, feel free to ask.

    I tryin' to setup an isometric game by myself and getting the sorting work properly, is just horrible^^

  • zyblade, thanks a lot. Awesome sample, as lennaert pointed, very effective. Will give it a try.

    I managed to make the movement, the result can be seen http://www.eyepatch.com.br/wanderer/ (use numeric keyboard 1, 2, 3, 4, 6, 7, 8, 9) for movement. Will post the capx later. It may be not the best solution, but it's some kind of one.

  • Didn't check your CAPX but if you have fairly complicated game, this method could help.

    http://clintbellanger.net/articles/isometric_math/

  • Thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)