ID:149525
 
How do I make a tanks-type control, where the speed is constant, and you go until you slow down to 0 speed, or hit a wall? Example: Press forward to always move forward slowly untill you move down. Or same with forward and down only twice.
In response to Nadrew
That helps a little, but, I asked for tanks-type controls, (Turn left, turn right, forward to move in the direction, back to move backwards, etc) combined with constant movement, that you can speed up, slow down, stop, or go in reverse.
In response to Hanns
I'd say do it with variables...

Actually...Nadrew's movement demo would work rather well as a base for this...

Just add a few variables..."lag" and "direction"
And then override the directional procs...

Kinda like this:

North()
usr.lag -= 1
walk(usr,usr.direction,usr.lag)
South()
usr.lag += 1
walk(usr,usr.direction,usr.lag)

East() and West() are a bit more complicated... They need to adjust the "direction" variable according to the current direction the player is facing...

Meaning if the player is facing East and they call West()...it shouldn't make them just switch to facing West...it should make them face North (or Northeast if you want to go in diagonals as well)... And then if they press it again...it should adjust their direction to West (or North if you're using all 8 directions)... See what I mean? It should adjust their direction in ordered increments around the directions...

I'm sure there's a VERY much simpler way of doing this than my following example...but this is the general idea:

East()
if(usr.direction == NORTH)
usr.direction = EAST
else
if(usr.direction == SOUTH)
usr.direction = WEST
else
if (usr.direction == WEST)
usr.direction = NORTH
else
usr.direction = EAST
walk(usr,usr.direction,usr.lag)


See what it does? It changes their direction in a clockwise manner around the 4 caridnal directions...

West() would work the opposite way...changing the direction in a counter-clockwise way...
In response to Hanns
Just override the original client macros for direction:

client.North()
client.Northeast(), etc...

replace client.East() and client.West() with procs that turn() the player, and replace client.North() and client.South() with procs that increase and decrease movement, however you decide to make that work. Make sure you override northeast, southeast, southwest and northwest, too, otherwise they'll still be able to move normally. If you don't have anything useful to override them with, just make them do nothing, like this:

client.Northeast()
return
In response to Foomer
Heh... Once again...Foomer gives roughly the same answer as mine...at roughly the same time... Yet his is slightly better...

I had forgotten all about turn()...lol There's the "much simpler way" I mentioned in my reply...lol
In response to SuperSaiyanGokuX
That doesn't work It just make them sit there. Anyone have the full code?
In response to Hanns
There is a BYONDscape article on this, made by ShadowDarke. You might want to check it out, although im not sure if its subscription content or not.

Alathon
In response to Alathon
Alathon wrote:
There is a BYONDscape article on this, made by ShadowDarke. You might want to check it out, although im not sure if its subscription content or not.

It's a freebie, and covers everything he wanted to know. ;)
http://www.byondscape.com/scape.dmb/content/000030/ index.html