Showing Maximum Move Distance...

So here is my question... I'm trying to duplicate the movement of some strategy games... Such as Advanced Wars or FF Tactics... So I have a grid set up and using keyboard for testing can move in the perfect squares of my grid and stuff... Someone help me move my brain along a bit and let me pick your brains... How would I set up the movement to like show the maximum movement...
http://thegia.psy-q.ch/sites/www.thegia.com/gba/wars/media4/wars_ss19.jpg
Such as in that picture? Say I set the maximum movement to 5... Then it would show 5 squares to left/right/up/bottom and the possible with combinations of those ya no?

Comments

  • SAP_AppsSAP_Apps Member Posts: 77
    Bumpity bump bump.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Measure the distance from each grid square actor to the player actor. If it's within the movement range, change it's color/image to indicate it.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I'll have a demo in a minute...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SAP_AppsSAP_Apps Member Posts: 77
    I was thinking along these lines... But say you had movement of 5... (5 times 20x20 grids... So movement of. 100 pixels... Would this still work to give you the diagonals tho? Like I'm gonna move 3 right. Then 2 up... Understand what I'm saying? Not at the computer to try this stuff. But I always like to get some steady ideas in my head
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yeah, magnitude didn't work because the player wouldn't move "as the crow flies." So here's a demo that counts "row" and "column" distance on the grid.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Here's what the demo looks like:

    image

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SAP_AppsSAP_Apps Member Posts: 77
    Oh wow! Can't play with it yet but looks awesome from the screen shot man! Thanks!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    And here's a version that includes movement with arrow keys.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SAP_AppsSAP_Apps Member Posts: 77
    This all worked amazing! And I have done some pretty cool stuff today with it... But I did have another question... try to poke your brain a little more @tatiang
    ...
    Using the Grid... if I was to assign an AI actor for instance a maximum moveable distance of 3 or 4 grid movements... how could I make him move in the direction of another actor? or if he is a certain range... again 3 grid spaces... make him do something specific... ? this is my first game trying to manipulate an AI :) not 100% on some techniques to do so...
    any ideas? / suggestions
  • SAP_AppsSAP_Apps Member Posts: 77
    Bump bump :)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Well, to determine distance, you use the same set of behaviors that I used for the squares (the "grid" actor). Just copy that actor and name it Enemy and then see if you can adjust the rules to make it do a certain action when it's within a certain range.

    To make an enemy move towards the player (or another actor), you'd just need to know which direction that player was. So you'd be keeping track of its "row" and "column" (self.position.X/game.gridSize) and comparing them with the "row" and "column" of the enemy.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SAP_AppsSAP_Apps Member Posts: 77
    The action part at a certain range I think I got. But moving an enemy towards a character is tricking me up. :( I can get something to identify the direction a player is that the AI needs to me towards but idk...
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    So once you identify the direction, then you just add/subtract the x/y value. For example, if the player is below the enemy, the enemy needs to move up by changing self.position.Y to self.position.Y+game.gridSize. To make it look better, you can have the enemy interpolate to the new position. Just make sure to interpolate to a _different_ attribute (Interpolate self.position.Y to self.currentY+game.gridSize).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SAP_AppsSAP_Apps Member Posts: 77
    edited March 2013
    Ok I got an idea to try with that... Also... However, say on a 5x5 grid. The guy are diagonal from each other. You can't move diagonal. Only up and down and left and right. What would be the proper action to make the actor go like left down left down left down for like 5 moves. Understand?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You need to decide how you want the enemy to proceed if it is diagonal and therefore its "row" and "column" are greater than (or less than) the player's. You'd have a rule that chooses one of the directions and then the other.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SAP_AppsSAP_Apps Member Posts: 77
    So this could work... like this if you will...
    i can give the AI a max movement of 5.... if the column and row are greater.... you use two movements and move left and down one.... or whatever... then check again... and if its still the same... use two more... then check again... if its still then just auto go down... or if its only one or the other head in that direction.
    ....
    in a nutshell ?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I think that's the general idea, yes.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.