Jump to content

Camera direction


SoulSplitz

Recommended Posts

I was looking to some snippets and found a camera system from @Lemons and there is that thing which confused me..

Here are the functions implementation of moving the current angel of the camera to a specific position/direction

public void moveNorth() {
int r = Script.random(0, 30);
if (r > 15)
   r = 375 - r;
   moveYaw(r);
}

public void moveWest() {
   moveYaw(75 + Script.random(0, 30));
}

public void moveSouth() {
   moveYaw(165 + Script.random(0, 30));
}

public void moveEast() {
   moveYaw(255 + Script.random(0, 30));
}

And I was trying to write functions to check where the camera direction is and came up with the following:

    public boolean isNorth() {
        return (getYawAngle() >= 0 && getYawAngle() < 75) || getYawAngle() == 360;
    }

    public boolean isWest() {
        return getYawAngle() >= 75 && getYawAngle() < 165;
    }

    public boolean isSouth() {
        return getYawAngle() >= 165 && getYawAngle() < 255;
    }

    public boolean isEast() {
        return getYawAngle() >= 255 && getYawAngle() < 360;
    }

It is a little bit strange to me because it should be north, east, south, and west and the angels should be 0-90, 90-180, 180-270, 270-360 However, it seems to be counterclockwise and 0-90 would include both east and north https://www.mathsisfun.com/geometry/images/degrees-360.gif

In this case, north should be -75-75 not 0-75 but someone seems to have defined it that way and it looks rather arbitrary. (Might be the absolute value of that range, as Zappster told me from chats).

My question is "why's this thing like that?" Is it because the developer made it that way? Another question is.. Why when checking west, the range is 75-165 but when moving to west, the range is 75 + 0,30 which could maximally reach 105?

In addition, could someone help me write a function to check the north-east or south-west direction then?

Edited by SoulSplitz
Typo
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...