View Single Post
  #1  
Old 04-19-2004, 07:05 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Corners of a rectangle

I spent half of my afternoon trying to get the blocking of Era cars right, by calculating each corner based on the center, angle, and a fixed size of 2x4 tiles of a car.
I wonder whether this is of use to anybody, or whether someone wants to make it nicer.

NPC Code:
  a = this.carAng;

l = 4; // length
w = 2; // width

centerx = playerx + 1.5 - 1/16;
centery = playery + 2 - 1/16;

frontx = sin(a) * l;
fronty = cos(a) * l;

sidex = sin(a + pi/2) * w;
sidey = cos(a + pi/2) * w;

rectx = { centerx + frontx + sidex, // front right
centerx + frontx - sidex, // front left
centerx - frontx + sidex, // back right
centerx - frontx - sidex}; // back left

recty = { centery - fronty - sidey, // front right
centery - fronty + sidey, // front left
centery + fronty - sidey, // back right
centery + fronty + sidey}; // back left

for (i = 0; i < 4; i ++)
showpoly i+1, {rectx[i], recty[i]-0.25,
rectx[i]-0.5, recty[i]+0.25,
rectx[i]+0.5, recty[i]+0.25};

Reply With Quote