mirror of
https://github.com/1dot13/source.git
synced 2026-08-19 14:20:30 +02:00
Flashlight changes (#81)
* Flashlight changes: - Fixed the lighted area being way too large in the diagonal directions. - Added a minimum range to simulate a flashlight user not illuminating its feet. - Added angle based calculations instead of the hardcoded one. * Flashlight changes, MR feedback.
This commit is contained in:
@@ -91,6 +91,11 @@ UINT8 gOneCCDirection[ NUM_WORLD_DIRECTIONS ] =
|
||||
WEST
|
||||
};
|
||||
|
||||
UINT8 DirectionIfTurnedClockwise(UINT8 facing, UINT8 times)
|
||||
{
|
||||
return (facing + times) % NUM_WORLD_DIRECTIONS;
|
||||
}
|
||||
|
||||
// DIRECTION FACING DIRECTION WE WANT TO GOTO
|
||||
UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIONS ] =
|
||||
{
|
||||
@@ -912,6 +917,15 @@ INT16 sDeltaScreenX, sDeltaScreenY;
|
||||
|
||||
}
|
||||
|
||||
INT16 DirectionToVectorX[NUM_WORLD_DIRECTIONS] = {0, 1, 1, 1, 0, -1, -1, -1};
|
||||
INT16 DirectionToVectorY[NUM_WORLD_DIRECTIONS] = {-1, -1, 0, 1, 1, 1, 0, -1};
|
||||
void ConvertDirectionToVectorInXY( UINT8 ubDirection, INT16* sXDir, INT16* sYDir )
|
||||
{
|
||||
Assert(ubDirection >= 0 && ubDirection < NUM_WORLD_DIRECTIONS);
|
||||
*sXDir = DirectionToVectorX[ubDirection];
|
||||
*sYDir = DirectionToVectorY[ubDirection];
|
||||
}
|
||||
|
||||
void ConvertGridNoToXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos )
|
||||
{
|
||||
*sYPos = sGridNo / WORLD_COLS;
|
||||
|
||||
@@ -30,6 +30,8 @@ extern UINT8 gTwoCDirection[ NUM_WORLD_DIRECTIONS ];
|
||||
extern UINT8 gOneCDirection[ NUM_WORLD_DIRECTIONS ];
|
||||
extern UINT8 gOneCCDirection[ NUM_WORLD_DIRECTIONS ];
|
||||
|
||||
UINT8 DirectionIfTurnedClockwise(UINT8 facing, UINT8 times);
|
||||
|
||||
extern UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIONS ];
|
||||
|
||||
// Macros
|
||||
@@ -40,6 +42,7 @@ extern UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIO
|
||||
|
||||
#define GETWORLDINDEXFROMWORLDCOORDS( y, x ) ( (INT32) ( x / CELL_X_SIZE ) ) + WORLD_COLS * ( (INT32) ( y / CELL_Y_SIZE ) )
|
||||
|
||||
void ConvertDirectionToVectorInXY(UINT8 ubDirection, INT16* sXDir, INT16* sYDir);
|
||||
void ConvertGridNoToXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos );
|
||||
void ConvertGridNoToCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos );
|
||||
void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos );
|
||||
|
||||
Reference in New Issue
Block a user