User Tag List

Results 1 to 8 of 8

Thread: AngleDir8() and weapons

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Octorok
    Join Date
    Jan 2011
    Location
    Canada
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    817
    Level
    10
    vBActivity - Bars
    Lv. Percent
    1.43%

    AngleDir8() and weapons

    The AngleDir8() function is commonly used to set weapon->Dir, but it is inconsistent with unscripted eweapons when it comes to which directions Link can be facing in order to block them when the weapon's angle is close to a multiple of 90 degrees. A more consistent function would be something like this (-180 <= angle <= 180):
    Code:
    int AngleDir8W(float angle) {
       if(angle == 0) return DIR_RIGHT;
       else if(angle == 90) return DIR_DOWN;
       else if(angle == -90) return DIR_UP;
       else if(angle == 180 || angle == -180) return DIR_LEFT;
       else if(angle < -90) return DIR_LEFTUP;
       else if(angle < 0) return DIR_RIGHTUP;
       else if(angle < 90) return DIR_RIGHTDOWN;
       else return DIR_LEFTDOWN;
    }
    
    int RadianAngleDir8W(float angle) {
       return AngleDir8W(angle*57.2958);
    }
    I think it would make a good addition to std.zh, though other functions that use AngleDir8() with weapon->Dir would need to be updated to fix the inconsistency.

    EDIT: Maybe this could be improved. I'll do some testing with radian values.

    EDIT 2: There are going to be roundoff errors when using radians, so I think there should be some tolerance for that with the non-diagonal directions. I'm not sure how much though.
    Last edited by Colossal; 09-02-2011 at 05:38 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social