Which way is the Player facing?

Discussion in 'Learning Javascript' started by Ghost of Christmas Kloe, Mar 14, 2016.

Thread Status:
Not open for further replies.
  1. Ghost of Christmas Kloe

    Ghost of Christmas Kloe Ghost of a Princess Seagull Veteran

    Messages:
    1,504
    Likes Received:
    913
    Location:
    Somewhere...
    First Language:
    English
    Primarily Uses:
    N/A
    Hiya, it's my first time posting in the learning JavaScript section so yay!


    I wanted to know to find out what direction the player is facing, and be able to set a variable to that direction so I can use it in commands like 

    $gameMap.startScroll(direction, distance, speed);

    which I am using to try make a "Telescope" script!


    I have most of it done but I want to know how to find out the direction, so I can scroll in the direction the player is facing!


    Thank you for reading and/or helping and hopefully I gave enough detail in my question that it can be answered!
     
    #1
  2. deilin

    deilin Ranger/Elementalist Veteran

    Messages:
    1,189
    Likes Received:
    173
    First Language:
    English
    I think the lines you're looking for is in this:

    Spoiler





    Code:
    
    Game_CharacterBase.prototype.setPosition = function(x, y) {    this._x = Math.round(x);    this._y = Math.round(y);    this._realX = x;    this._realY = y;};Game_CharacterBase.prototype.copyPosition = function(character) {    this._x = character._x;    this._y = character._y;    this._realX = character._realX;    this._realY = character._realY;    this._direction = character._direction;};Game_CharacterBase.prototype.locate = function(x, y) {    this.setPosition(x, y);    this.straighten();    this.refreshBushDepth();};Game_CharacterBase.prototype.direction = function() {    return this._direction;};Game_CharacterBase.prototype.setDirection = function(d) {    if (!this.isDirectionFixed() && d) {        this._direction = d;    }    this.resetStopCount();}

     


     


    I may be wrong. I do know directions are even numbers 2, 4, 6, 8.
     
    Last edited by a moderator: Mar 14, 2016
    #2
  3. Ghost of Christmas Kloe

    Ghost of Christmas Kloe Ghost of a Princess Seagull Veteran

    Messages:
    1,504
    Likes Received:
    913
    Location:
    Somewhere...
    First Language:
    English
    Primarily Uses:
    N/A
    Thank you! I think this._direction might contain the values  2, 4, 6, 8. as you said, and if so that's perfect! I will go do some testing quickly, thank you!!
     
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,800
    Likes Received:
    11,507
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    That will work if what you're writing is in the Game_Player class.  If it's not (if it's part of the Game_Map class, for example), use $gamePlayer.direction()
     
    #4
  5. Ghost of Christmas Kloe

    Ghost of Christmas Kloe Ghost of a Princess Seagull Veteran

    Messages:
    1,504
    Likes Received:
    913
    Location:
    Somewhere...
    First Language:
    English
    Primarily Uses:
    N/A
    Oh! Ok, thanks Shaz!


    I guess this can be closed then, since it's solved?
     
    #5
Thread Status:
Not open for further replies.

Share This Page