Make actor move one direction at a time.

rickynikorickyniko Member Posts: 85
edited November -1 in Working with GS (Mac)
Hello, im in the process of making a game, and the actor is controlled by a virtual dpad.
i was wondering how to make it so the actor can only move 1 direction at a time

so Up, THEN down etc etc.

i dont want the player to have the abilty to press down up/left at the same time and have the actor traveling on an angle.
know what i mean?

Comments

  • POLYGAMePOLYGAMe Member Posts: 3,470
    Hehe, I wanted the diagonals... very hard to get them unless you make the d-pad buttons HUGE. You should be okay ;)
  • rickynikorickyniko Member Posts: 85
    thanks for the response POLYGAMe,
    so your the one that made PRANKSTAR, ahahaa, that one scared the heck out of my 10 year old sister ahahha :P good one
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Shouldn't be hard...

    I'm thinking the math will look something like this:

    `ceil(((VectorToAngle(joyCenter.x - joyTouch.x, joyCenter.y - joyTouch.y)-22.5)%360)/45)*45`

    The order of "joyCenter" and "joyTouch" may need to be reversed in the VectorToAngle function. I'll test it on my lunch break...
  • POLYGAMePOLYGAMe Member Posts: 3,470
    rickyniko said:
    thanks for the response POLYGAMe,
    so your the one that made PRANKSTAR, ahahaa, that one scared the heck out of my 10 year old sister ahahha :P good one

    Haha, hope she didn't drop your iPhone ;)
  • rickynikorickyniko Member Posts: 85
    POLYGAMe said:
    Haha, hope she didn't drop your iPhone ;)

    haha, nah she threw it on the couch hahah
  • rickynikorickyniko Member Posts: 85
    barkbark00 said:
    Shouldn't be hard...

    I'm thinking the math will look something like this:

    `ceil(((VectorToAngle(joyCenter.x - joyTouch.x, joyCenter.y - joyTouch.y)-22.5)%360)/45)*45`

    The order of "joyCenter" and "joyTouch" may need to be reversed in the VectorToAngle function. I'll test it on my lunch break...

    thanks for that, ill try it out soon!

    by the way, if you can, try help out with my other topic, its really recent so it should be up there)
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    I'll actually have to open GS to work that one out...maybe later.
Sign In or Register to comment.