Skip to content

Commit

Permalink
Bump up rotation to quick accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
Swizpig committed Feb 12, 2020
1 parent e426985 commit 68e72eb
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 55 deletions.
22 changes: 12 additions & 10 deletions gamelogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void GameLogic::ResetPlayer(MapObject& o)
o.data.ms.collwith = 4;
o.x = origx;
o.z = origz;
o.data.ms.rot = origrot;
o.data.ms.rotquick.SetInt(origrot);
}

void GameLogic::InitLevel(GloomMap* gmapin, Camera* cam, ObjectGraphics* ograph)
Expand All @@ -81,11 +81,11 @@ void GameLogic::InitLevel(GloomMap* gmapin, Camera* cam, ObjectGraphics* ograph)
cam->x = o.x;
cam->y = 120; //TODO, and rotation
cam->z = o.z;
cam->rot = o.data.ms.rot;
cam->rotquick = o.data.ms.rotquick;

origx = o.x;
origz = o.z;
origrot = o.data.ms.rot;
origrot = o.data.ms.rotquick.GetInt();

o.data.ms.hitpoints = p1health;
//o.data.ms.lives = p1lives; TODO
Expand Down Expand Up @@ -687,8 +687,8 @@ bool GameLogic::Update(Camera* cam)

Quick camrots[4], camrotstrafe[4];

GloomMaths::GetCamRot(cam->rot, camrots);
GloomMaths::GetCamRot((cam->rot)+64&0xFF, camrotstrafe);
GloomMaths::GetCamRot(cam->rotquick.GetInt()&0xFF, camrots);
GloomMaths::GetCamRot((cam->rotquick.GetInt())+64&0xFF, camrotstrafe);
const Uint8 *keystate = SDL_GetKeyboardState(NULL);

Quick newx = cam->x;
Expand All @@ -702,7 +702,7 @@ bool GameLogic::Update(Camera* cam)
playerobj.x = cam->x;
playerobj.y.SetInt(0);
playerobj.z = cam->z;
playerobj.data.ms.rot = cam->rot;
playerobj.data.ms.rotquick = cam->rotquick;

inc.SetVal(playerobj.data.ms.movspeed);

Expand Down Expand Up @@ -733,7 +733,7 @@ bool GameLogic::Update(Camera* cam)
}
else
{
cam->rot -= 4;
cam->rotquick.SetInt(cam->rotquick.GetInt() - 4);
}
}
if (keystate[SDL_SCANCODE_RIGHT])
Expand All @@ -748,7 +748,7 @@ bool GameLogic::Update(Camera* cam)
}
else
{
cam->rot += 4;
cam->rotquick.SetInt(cam->rotquick.GetInt() + 4);
}
}

Expand Down Expand Up @@ -905,7 +905,7 @@ bool GameLogic::Update(Camera* cam)
{
cam->x.SetInt(activetele.x);
cam->z.SetInt(activetele.z);
cam->rot = (uint8_t)activetele.rot;
cam->rotquick.SetInt((uint8_t)activetele.rot);
playerobj.data.ms.pixsizeadd = -playerobj.data.ms.pixsizeadd;
if (levelfinished) done = true;
}
Expand Down Expand Up @@ -976,7 +976,9 @@ bool GameLogic::Update(Camera* cam)
playerobj.y = playerobjupdated.y;
cam->y = -(playerobj.y.GetInt() + playerobj.data.ms.eyey);
cam->z = playerobj.z = playerobjupdated.z;
cam->rot = playerobj.data.ms.rot = playerobjupdated.data.ms.rot;

playerobj.data.ms.rotquick = playerobjupdated.data.ms.rotquick;
cam->rotquick = playerobj.data.ms.rotquick;
playerhit = true;
}

Expand Down
10 changes: 9 additions & 1 deletion gloommap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,13 @@ MapObject::MapObject(Object m)
z.SetInt(m.z);
t = m.t;

data.ms.rotspeed = 0;

data.ms.frame = m.frame;
data.ms.framespeed = m.framespeed;

data.ms.render = m.render;
data.ms.rot = m.rot;
data.ms.rotquick.SetInt(m.rot);
data.ms.movspeed = m.movspeed;
data.ms.shape = m.shape;
data.ms.chunks = m.chunk;
Expand Down Expand Up @@ -871,6 +873,11 @@ MapObject::MapObject(Object m)
data.ms.hit = HurtDeath;
data.ms.die = BlowDeath;
break;
case ObjectGraphics::OLT_DRAGON:
data.ms.logic = NullLogic;
data.ms.hit = NullLogicComp;
data.ms.die = BlowDragon;
break;
case ObjectGraphics::OLT_WEAPON1:
case ObjectGraphics::OLT_WEAPON2:
case ObjectGraphics::OLT_WEAPON3:
Expand Down Expand Up @@ -918,6 +925,7 @@ MapObject::MapObject()
data.ms.hurtpause = 0;
data.ms.punchrate = 0;
data.ms.scale = 0x200;
data.ms.rotspeed = 0;

// avoid zero as I need to flag nothing
identifier = counter + 1;
Expand Down
3 changes: 2 additions & 1 deletion gloommap.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class MapObjectSideBand

uint32_t render;

uint32_t rot;
Quick rotquick;
int32_t rotspeed;
uint32_t oldrot;
int32_t movspeed;
int32_t xvec;
Expand Down
Loading

0 comments on commit 68e72eb

Please sign in to comment.