How do I measure the distance an object has moved?

  • Good evening!

    Im currently trying to create a round based, top down shooter.

    Ive developed a prototype to experiment around with round based movement. Using the 8direction movement I can prevent an object from moving after a certain amount of moving time. The problem I now ran into is that this method measures the time an object is moving not the distance. So when I for example try to move a little bit more carefully by tapping the arrow keys the object stops after a small distance due to the acceleration/decaleration which Counts as movement. Messing around with the values of acceleration/decceleration has not prevented this from happening.

    my current Setup:

    condition 1 (Measuring the Movement): If 8direction is moving -> add 1 to "moved"

    condition 2 (Stopping the object after a certain amount of time): If "moved" is greater/equal than 120 -> set 8direction disabled + stop 8direction + set "nomoreactionpoints" to true

    condition 3 (Starting a new round): If "nomoreactionpoints" is true + On "spacebar" pressed -> set "moved" to 0 + enable 8direction movement + toggle "nomoreactionpoints"

    I hope that it is possible to understand what I am trying to say :)

    Thanks for any help!

  • Man, it took me a second to realise that you meant "turn"-based movement :P

    You can use the distance expression: distance(x1,y1,x2,y2). Obviously this depends on how your game is set up (most turn-based or action-point-based games used tile-based movement anyway), but you could simply record the object's initial position at the start of a turn as two variables (these become your x1/y1) and compare distance to its current position every time it moves.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply! Your second idea was exactly what I was looking for!

    Here is how I did it:

    <img src="http://s7.directupload.net/images/130324/dt7wznqi.jpg" border="0" />

    PS: Yeah, we actually say round-based over here in Germany... <img src="smileys/smiley36.gif" border="0" align="middle" />

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