The Dink Network

Reply to Re: dink rts dev thread

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
April 5th 2020, 05:37 PM
duck.gif
toof
Peasant He/Him
I disagree. 
Say, anyone out there who knows how to use "inside_box"?

I'm not sure I understand the question. inside_box checks whether certain coords are within range. But you must supply that info yourself.

Category: Math
Version: 1.00+
Prototype: bool inside_box(int x, int y, int left, int top, int right, int bottom);

inside_box returns 1 if the x and y coordinates are inside the box defined by left, top, right, and bottom.

// excerpt from item-pig.c to check if Dink is in the pig pen
&junk = inside_box(&mholdx,&mholdy, 200, 180, 400, 306);
if (&junk == 1)
{
      freeze(1);
      wait(200);
      say_stop("Come on pigs, eat!", 1);
      //... continued
}

Put another way, this function ensures the x coordinate is within the left and right boundaries, and the y coordinate is within the top and bottom boundaries, like so:

if (&x >= &left)
{
      if (&x <= &right)
      {
            if (&y <= &bottom)
            {
                  if (&y >= &top)
                  {
                        say("I'm inside the box!", 1);
                  }
            }
      }

}