User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12

Thread: Direction comparisons

  1. #11
    No Products Registered

    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    1,141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Direction comparisons

    My code can easily be converted to use angles as well... Just change the +48 mod 32 to +540 mod 360.

  2. #12
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Direction comparisons

    Thanks for the replies, all

    Good news! I found my old engine, after much rummaging. It uses 'Immediate IF Object' to make sure it works on multiple objects:
    (it uses directions, purely for simplicity. Accuracy isn't needed)

    ALWAYS
    - Fish: Set "Angle of fish" to 'dir("FISH")'
    - Fish: Look in direction of Player
    - Fish: Set "Angle to player" to 'dir("FISH")'
    - Fish: Set direction to 'Angle of fish("FISH")'

    - Fish: Set alterable string "Is Player in Focus" to:

    'CompareIntegers$( "Immediate If Object", (pl angle( "FISH" )-(me angle( "FISH" )-16)) mod 32, ">=", 16-Round(range( "FISH" )/2.0), CompareIntegers$( "Immediate If Object", (pl angle( "FISH" )-(me angle( "FISH" )-16)) mod 32, "<=", 16+Round(range( "FISH" )/2.0), "YES", "NO"), "NO")'

    ...heh, lol. Then you just check if 'Is Player in Focus' reads YES or NO.

    The expression boils down to this, in pseudocode:
    Code:
    //What the vars mean:
     pl angle = angle to player;
     me angle = angle of fish;
     range = range of view;
    
    //The IF statement, which is bizarre but works somehow:
    
    if( (pl angle-(me angle-16)) mod 32 >= 16-Round(range/2.0))
    {
     if( (pl angle-(me angle-16)) mod 32 <= 16+Round(range/2.0))
     {
      "YES"
     }else{
      "NO"
     }
    }else{
    "NO"
    }

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. [Bug] Basic comparisons failing
    By Mokhtar in forum SWF/Flash Export Module Version 2.0
    Replies: 7
    Last Post: 21st May 2010, 04:06 PM
  2. String Comparisons In Lua Code?
    By Atom in forum Lua Scripting
    Replies: 6
    Last Post: 3rd May 2010, 10:19 PM
  3. Application Comparisons
    By artician in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 16th May 2008, 12:10 AM
  4. Replies: 0
    Last Post: 10th January 2008, 02:32 PM
  5. Object Instance Comparisons
    By Dines in forum Extension Development
    Replies: 5
    Last Post: 25th December 2007, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •