How do I measure the distance an object has moved?

Get help using Construct 2

Post » Sun Mar 24, 2013 7:56 pm

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!
B
4
S
1
Posts: 5
Reputation: 485

Post » Sun Mar 24, 2013 9:11 pm

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.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Sun Mar 24, 2013 9:52 pm

Thanks for the reply! Your second idea was exactly what I was looking for!

Here is how I did it:



PS: Yeah, we actually say round-based over here in Germany...
B
4
S
1
Posts: 5
Reputation: 485


Return to How do I....?

Who is online

Users browsing this forum: Muini and 17 guests