cMapDecorator: Implemented random rotations
This commit is contained in:
parent
4a1ac57408
commit
58a708825f
25
src/Map.cpp
25
src/Map.cpp
@ -9,6 +9,7 @@
|
|||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "Chunk.h"
|
#include "Chunk.h"
|
||||||
#include "Entities/Player.h"
|
#include "Entities/Player.h"
|
||||||
|
#include "FastRandom.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -52,14 +53,14 @@ T Clamp(T a_X, T a_Min, T a_Max)
|
|||||||
|
|
||||||
void cMapDecorator::Update(void)
|
void cMapDecorator::Update(void)
|
||||||
{
|
{
|
||||||
ASSERT(m_Map != NULL);
|
|
||||||
unsigned int PixelWidth = m_Map->GetPixelWidth();
|
|
||||||
|
|
||||||
int InsideWidth = (m_Map->GetWidth() / 2) - 1;
|
|
||||||
int InsideHeight = (m_Map->GetHeight() / 2) - 1;
|
|
||||||
|
|
||||||
if (m_Player != NULL)
|
if (m_Player != NULL)
|
||||||
{
|
{
|
||||||
|
ASSERT(m_Map != NULL);
|
||||||
|
unsigned int PixelWidth = m_Map->GetPixelWidth();
|
||||||
|
|
||||||
|
int InsideWidth = (m_Map->GetWidth() / 2) - 1;
|
||||||
|
int InsideHeight = (m_Map->GetHeight() / 2) - 1;
|
||||||
|
|
||||||
int PixelX = (m_Player->GetPosX() - m_Map->GetCenterX()) / PixelWidth;
|
int PixelX = (m_Player->GetPosX() - m_Map->GetCenterX()) / PixelWidth;
|
||||||
int PixelZ = (m_Player->GetPosZ() - m_Map->GetCenterZ()) / PixelWidth;
|
int PixelZ = (m_Player->GetPosZ() - m_Map->GetCenterZ()) / PixelWidth;
|
||||||
|
|
||||||
@ -67,18 +68,22 @@ void cMapDecorator::Update(void)
|
|||||||
m_PixelX = (2 * PixelX) + 1;
|
m_PixelX = (2 * PixelX) + 1;
|
||||||
m_PixelZ = (2 * PixelZ) + 1;
|
m_PixelZ = (2 * PixelZ) + 1;
|
||||||
|
|
||||||
// 1px border
|
|
||||||
if ((PixelX > -InsideWidth) && (PixelX <= InsideWidth) && (PixelZ > -InsideHeight) && (PixelZ <= InsideHeight))
|
if ((PixelX > -InsideWidth) && (PixelX <= InsideWidth) && (PixelZ > -InsideHeight) && (PixelZ <= InsideHeight))
|
||||||
{
|
{
|
||||||
double Yaw = m_Player->GetYaw();
|
double Yaw = m_Player->GetYaw();
|
||||||
|
|
||||||
m_Rot = (Yaw * 16) / 360;
|
|
||||||
|
|
||||||
if (m_Map->GetDimension() == dimNether)
|
if (m_Map->GetDimension() == dimNether)
|
||||||
{
|
{
|
||||||
|
cFastRandom Random;
|
||||||
|
|
||||||
Int64 WorldAge = m_Player->GetWorld()->GetWorldAge();
|
Int64 WorldAge = m_Player->GetWorld()->GetWorldAge();
|
||||||
|
|
||||||
// TODO 2014-02-18 xdot: Random rotations
|
// TODO 2014-02-19 xdot: Refine
|
||||||
|
m_Rot = Random.NextInt(16, WorldAge);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Rot = (Yaw * 16) / 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Type = E_TYPE_PLAYER;
|
m_Type = E_TYPE_PLAYER;
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
/** Constructs a map decorator that tracks a player. */
|
/** Constructs a map decorator that tracks a player. */
|
||||||
cMapDecorator(cMap * a_Map, cPlayer * a_Player);
|
cMapDecorator(cMap * a_Map, cPlayer * a_Player);
|
||||||
|
|
||||||
/** Updates the pixel coordinates of the decorator. */
|
/** Updates the decorator. */
|
||||||
void Update(void);
|
void Update(void);
|
||||||
|
|
||||||
unsigned int GetPixelX(void) const { return m_PixelX; }
|
unsigned int GetPixelX(void) const { return m_PixelX; }
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
/** Construct an empty map. */
|
/** Construct an empty map. */
|
||||||
cMap(unsigned int a_ID, cWorld * a_World);
|
cMap(unsigned int a_ID, cWorld * a_World);
|
||||||
|
|
||||||
/** Constructs an empty map at the specified coordinates. */
|
/** Construct an empty map at the specified coordinates. */
|
||||||
cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, unsigned int a_Scale = 3);
|
cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, unsigned int a_Scale = 3);
|
||||||
|
|
||||||
/** Send this map to the specified client. WARNING: Slow */
|
/** Send this map to the specified client. WARNING: Slow */
|
||||||
@ -135,7 +135,7 @@ public:
|
|||||||
/** Update a circular region around the specified player. */
|
/** Update a circular region around the specified player. */
|
||||||
void UpdateRadius(cPlayer & a_Player, unsigned int a_Radius);
|
void UpdateRadius(cPlayer & a_Player, unsigned int a_Radius);
|
||||||
|
|
||||||
/** Send next update packet and remove invalid decorators */
|
/** Send next update packet to the specified player and remove invalid decorators/clients. */
|
||||||
void UpdateClient(cPlayer * a_Player);
|
void UpdateClient(cPlayer * a_Player);
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
Loading…
Reference in New Issue
Block a user