Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 04-19-2004, 09:27 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Ahh, but the horizontal and vertical distances between the player's coordinates and the coordinates of the car change, though...? (depending on the angle of the car)

i.e. if the car is facing up, the center of the car will be to the right and down of the player, whereas if the car is facing down, the center of the car will be to the left and up of the player...

Some more trigonometry is required, no?
Reply With Quote
  #3  
Old 04-19-2004, 09:36 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Quote:
Originally posted by Lance
Ahh, but the horizontal and vertical distances between the player's coordinates and the coordinates of the car change, though...? (depending on the angle of the car)

i.e. if the car is facing up, the center of the car will be to the right and down of the player, whereas if the car is facing down, the center of the car will be to the left and up of the player...

Some more trigonometry is required, no?
Makes me think of GK ships, where you suddenly are floating above the sea
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.