UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 8

245

ActualWidth = (ActorBB.Max.X - ActorBB.Min.X) * 0.4f;
ActualHeight = (ActorBB.Max.Y - ActorBB.Min.Y) * 0.4f;

/** Draws colored brackets around anchor */
Canvas.SetDrawColor(100, 255, 255);

Math needs to be performed to determine the size of the box around the
pawn. We multiply by a float value to illustrate whether or not the box will
be completely closed, or open on the top, bottom, and sides. We add the color
of our bracket here too.


  1. Let's draw the rectangle around the pawn now. We'll break it up into corners
    so that it's easy to understand the code.
    /* Top Right /
    Canvas.SetPos(ActorBB.Max.X - ActualWidth,
    ActorBB.Min.Y);
    Canvas.DrawRect(ActualWidth, 10);
    Canvas.SetPos(ActorBB.Max.X , ActorBB.Min.Y);
    Canvas.DrawRect(2, ActualHeight);


/** Top Left */
Canvas.SetPos(ActorBB.Min.X, ActorBB.Min.Y);
Canvas.DrawRect(ActualWidth, 10);
Canvas.SetPos(ActorBB.Min.X, ActorBB.Min.Y);
Canvas.DrawRect(2, ActualHeight);

/** Bottom Right */
Canvas.SetPos
(ActorBB.Max.X - ActualWidth, ActorBB.Max.Y );
Canvas.DrawRect(ActualWidth, 10);
Canvas.SetPos
(ActorBB.Max.X, ActorBB.Max.Y - ActualHeight);
Canvas.DrawRect(2, ActualHeight );

/** Bottom Left */
Canvas.SetPos(ActorBB.Min.X, ActorBB.Max.Y);
Canvas.DrawRect(ActualWidth, 10);
Canvas.SetPos
(ActorBB.Min.X, ActorBB.Max.Y - ActualHeight );
Canvas.DrawRect(2, Actualheight);
}
Free download pdf