How to Simulate distance travelled?
EireStudios
Member Posts: 451
Hi Guys and Gals, I'm trying to simulate distance travelled in my game but I can't seem to get it to work.
I'm trying to just simply do,
when any
self.positionX = self.positionX+50
when self.positionY = self.positionY+50
when self.positionX = self.positionX-50
when self.positionY = self.positionY-50
change miles to miles+1
But this doesn't seem to work, I'm not looking for anything super advanced just something simple that works.
Any ideas guys? Thanks in advance
I'm trying to just simply do,
when any
self.positionX = self.positionX+50
when self.positionY = self.positionY+50
when self.positionX = self.positionX-50
when self.positionY = self.positionY-50
change miles to miles+1
But this doesn't seem to work, I'm not looking for anything super advanced just something simple that works.
Any ideas guys? Thanks in advance
Comments
If the character isn't always moving but you're using some sort of movement controls, like the keyboard. You could add to Miles whenever a movement key is pressed.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Constrain Self.DistanceFrom to magnitude(SelfX-LastX, SelfY-LastY)
At the start
Change Last X to Self X.
Change Last Y to Self Y.
When attribute self.distancefrom is greater than 50
Change Miles to Miles +1
Change Last X to Self X.
Change Last Y to Self Y.
Think that should do it so it tracks in all directions, cant test right now though.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page