Measuring distance traveled
yna205@nyu.edu
Member Posts: 49
Hi,
I've made a game but I want to calculate the distance traveled. Basically I swipe and the screen moves downward. And after that the image repeatedly repeats itself. But I want to post the distance the person traveled at the end of the game. how would I do that? Is there a way of measuring the number of pixels that passed down the screen or something of that matter? It's basically a very simple game. I'm swiping downwards and making the screen repeat itself. The game/race finishes 30 seconds after you hit start. Sorry it's hard to explain but I hope you guys get the broad idea.
Comments
If I understand correctly this is a racing game where you swipe down to move forward?
If there are no obstacles or actors you could track, you could always just code in a counter for each successful swipe. Alternatively you could count each time the image is repeated, a "lap" so to speak. And then just calculate an arbitrary distance based on the number of laps.
How exactly would I measure the number of repeated actors (laps)?
Bump
You'll need to do some math. So store the start position of the swipe then store the end position and subtract the end from the start and you have the distance. Then store that value in an attribute. Each swipe calculation will need to be added to the stored value.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
you can also use magnitude to calculate the distance between two objects, like the start line and the actor by having this on the actor
magnitude(startX-playerX, startY-playerY)
that will return the distance in pixels.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left