aboutsummaryrefslogtreecommitdiff
path: root/src/GameTick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GameTick.cpp')
-rw-r--r--src/GameTick.cpp103
1 files changed, 51 insertions, 52 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index 3f42796..fa64e6a 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -70,7 +70,7 @@ void Splat(Game* game, int k)
person.bjoint2 = joints + neck;
for (auto& joint : joints) {
- joint.position = DoRotation(joint.position + joint.offset, 0,
+ joint.position = rotate(joint.position + joint.offset, 0,
person.playerrotation, 0) + person.playercoords;
joint.realoldposition = joint.position;
joint.velocity = {0, person.velocity.y, 0};
@@ -181,8 +181,8 @@ void click(Game* game, int button, int action, int mods)
}
XYZ facing {0, 0, -1};
- facing = DoRotation(facing, -camera.rotation2, 0, 0);
- facing = DoRotation(facing, 0, -camera.rotation, 0);
+ facing = rotate(facing, -camera.rotation2, 0, 0);
+ facing = rotate(facing, 0, -camera.rotation, 0);
XYZ flatfacing = facing;
flatfacing.y = 0;
@@ -281,7 +281,7 @@ void click(Game* game, int button, int action, int mods)
&& player.reloading <= 0 && player.attackframe < 0) {
auto& skeleton = player.skeleton;
auto& hand = skeleton.joints[righthand];
- auto soundsrc = DoRotation(hand.position, 0, player.playerrotation, 0)
+ auto soundsrc = rotate(hand.position, 0, player.playerrotation, 0)
+ player.playercoords - camera.position;
if (player.grenphase) {
if (button == GLFW_MOUSE_BUTTON_LEFT
@@ -354,8 +354,8 @@ void look(Game* game, double xpos, double ypos)
void setListener(Game* game, XYZ facing)
{
XYZ upvector {0, 0, -1};
- upvector = DoRotation(upvector, -camera.rotation2 + 90, 0, 0);
- upvector = DoRotation(upvector, 0, -camera.rotation, 0);
+ upvector = rotate(upvector, -camera.rotation2 + 90, 0, 0);
+ upvector = rotate(upvector, 0, -camera.rotation, 0);
ALfloat ori[] {
facing.x, facing.y, facing.z,
@@ -391,7 +391,7 @@ XYZ aimPlayer(Game* game)
break;
}
- return DoRotation(point, aimrot2,
+ return rotate(point, aimrot2,
game->person[0].playerrotation + aimrot, 0);
}
@@ -422,14 +422,14 @@ XYZ aimBot(Game* game, int j)
if (target.skeleton.free)
inaccuracy *= 3;
else
- aim = DoRotation(aim, 0, target.playerrotation, 0)
+ aim = rotate(aim, 0, target.playerrotation, 0)
+ target.playercoords;
auto& lefthandpos = joints[lefthand].position;
aim -= bot.playercoords
- + DoRotation(lefthandpos, 0, bot.playerrotation, 0);
- return DoRotation(
- DoRotation(DoRotation(aim, 0, -bot.playerrotation, 0),
+ + rotate(lefthandpos, 0, bot.playerrotation, 0);
+ return rotate(
+ rotate(rotate(aim, 0, -bot.playerrotation, 0),
randFloat() * inaccuracy, randFloat() * inaccuracy, 0),
0, bot.playerrotation, 0);
}
@@ -515,12 +515,11 @@ void checkPersonCollisions(Game* game, int k)
game->onblocky = j;
// Wall collision
- float depth;
const auto city_type = game->citytype[i][j];
for (auto& bound : game->boundingpoints) {
- const auto whichtri = game->blockwalls[city_type].LineCheck3(person.playercoords + bound,
+ const auto whichtri = game->blockwalls[city_type].LineCheck2(person.playercoords + bound,
person.playercoords + bound,
- &collpoint, move, city_rot, &depth);
+ &collpoint, move, city_rot);
if (whichtri == -1)
continue;
}
@@ -528,12 +527,12 @@ void checkPersonCollisions(Game* game, int k)
auto pointnum = k + 1;
if (pointnum > 3)
pointnum = 0;
- const auto whichtri = game->blockwalls[city_type].LineCheck3(person.playercoords + bound,
+ const auto whichtri = game->blockwalls[city_type].LineCheck2(person.playercoords + bound,
person.playercoords + game->boundingpoints[pointnum],
- &collpoint, move, city_rot, &depth);
+ &collpoint, move, city_rot);
if (whichtri == -1)
continue;
- person.playercoords += DoRotation(game->blockwalls[city_type].normals[whichtri], 0, city_rot, 0);
+ person.playercoords += rotate(game->blockwalls[city_type].normals[whichtri], 0, city_rot, 0);
}
}
@@ -662,7 +661,7 @@ void attackCloseRange(Game* game, XYZ flatfacing)
}
for (auto& joint : target.skeleton.joints) {
- joint.position = DoRotation(joint.position,
+ joint.position = rotate(joint.position,
0, target.playerrotation, 0);
joint.position += target.playercoords;
joint.realoldposition = joint.position;
@@ -687,11 +686,11 @@ void attackCloseRange(Game* game, XYZ flatfacing)
player.bleeding=1;
player.bleeddelay=1;
- auto velocity = DoRotation(flatfacing, 0, 70, 0) * 50
+ auto velocity = rotate(flatfacing, 0, 70, 0) * 50
+ player.velocity * 2;
velocity.y += 30;
auto sprite_pos = target.playercoords
- + DoRotation(target.skeleton.joints[neck].position,
+ + rotate(target.skeleton.joints[neck].position,
0, target.playerrotation, 0);
for (auto i = 2; i < 5; ++i)
sprites.MakeSprite(bloodspritedown,
@@ -701,7 +700,7 @@ void attackCloseRange(Game* game, XYZ flatfacing)
playSound(gSourceID[headwhacksound],
soundpos.x, soundpos.y, soundpos.z);
target.skeleton.joints[head].velocity
- += DoRotation(flatfacing, 0, 40, 0) * 50
+ += rotate(flatfacing, 0, 40, 0) * 50
+ player.velocity * 2;
}
}
@@ -728,7 +727,7 @@ void tackle(Game* game, XYZ flatfacing)
for (auto& joint : person.skeleton.joints) {
joint.position = person.playercoords
- + DoRotation(joint.position,
+ + rotate(joint.position,
0, person.playerrotation, 0);
joint.realoldposition = joint.position;
joint.velocity = player.velocity;
@@ -781,7 +780,7 @@ void bleed(Game* game, size_t i)
person.bleeddelay = 1.0f;
XYZ loc = (person.bjoint1->position + person.bjoint2->position) / 2.0f;
sprites.MakeSprite(bloodspritedown, 0.6f, 1.0f, 0.2f, 0.2f,
- person.skeleton.free ? loc : DoRotation(loc,
+ person.skeleton.free ? loc : rotate(loc,
0.0f, person.playerrotation, 0.0f) + person.playercoords,
{}, person.bleeding * 3.0f);
}
@@ -875,11 +874,11 @@ void controlZombie(Game* game, size_t i)
auto& zombie_joints = zombie.skeleton.joints;
target_joints[head].position = zombie.playercoords
- + DoRotation(zombie_joints[righthand].position,
+ + rotate(zombie_joints[righthand].position,
0.0f, zombie.playerrotation, 0.0f);
target_joints[head].velocity = {};
target_joints[rightshoulder].position = zombie.playercoords
- + DoRotation(zombie_joints[lefthand].position,
+ + rotate(zombie_joints[lefthand].position,
0.0f, zombie.playerrotation, 0.0f);
target_joints[rightshoulder].velocity = {};
target.skeleton.DoConstraints();
@@ -915,14 +914,14 @@ void renderLaser(Game* game)
switch (player.whichgun) {
case assaultrifle:
case shotgun:
- aim = DoRotation(joints[lefthand].position
+ aim = rotate(joints[lefthand].position
- joints[righthand].position,
0.0f, rotation - 2.5f, 0.0f);
coeff = 0.15f;
break;
case handgun1:
case handgun2:
- aim = DoRotation(joints[righthand].position
+ aim = rotate(joints[righthand].position
- joints[head].position * 0.35f
- joints[neck].position * 0.65f,
0.0f, player.playerrotation - 0.9f, 0.0f);
@@ -935,8 +934,8 @@ void renderLaser(Game* game)
aim = normalize(aim);
auto& coords = player.playercoords;
auto start = coords
- + DoRotation(joints[lefthand].position, 0.0f, rotation, 0.0f)
- + DoRotation(DoRotation(DoRotation(aim, 0.0f, -rotation, 0.0f),
+ + rotate(joints[lefthand].position, 0.0f, rotation, 0.0f)
+ + rotate(rotate(rotate(aim, 0.0f, -rotation, 0.0f),
90.0f, 0.0f, 0.0f),
0.0f, rotation, 0) * coeff;
auto end = start + aim * 1000.0f;
@@ -1010,8 +1009,8 @@ void Game::Tick()
// Facing
XYZ facing {0, 0, -1};
- facing = DoRotation(facing, -camera.rotation2, 0, 0);
- facing = DoRotation(facing, 0, -camera.rotation, 0);
+ facing = rotate(facing, -camera.rotation2, 0, 0);
+ facing = rotate(facing, 0, -camera.rotation, 0);
XYZ flatfacing = facing;
flatfacing.y = 0;
@@ -1485,10 +1484,10 @@ void Game::Tick()
for (auto& joint : person[i].skeleton.joints) {
joint.position += joint.offset;
- joint.position = DoRotation(joint.position, 0, person[i].playerrotation, 0);
+ joint.position = rotate(joint.position, 0, person[i].playerrotation, 0);
joint.position += person[i].playercoords;
joint.realoldposition = joint.position;
- joint.velocity = DoRotation(joint.velocity, 0, person[i].playerrotation, 0);
+ joint.velocity = rotate(joint.velocity, 0, person[i].playerrotation, 0);
joint.velocity += person[i].velocity;
joint.velocity += person[i].facing * 4;
}
@@ -1554,7 +1553,7 @@ void Game::Tick()
for (int j = 0; j < max_joints; ++j) {
person[i].tempanimation.position[j][0]=person[i].skeleton.joints[j].position-person[i].playercoords;
- person[i].tempanimation.position[j][0]=DoRotation(person[i].tempanimation.position[j][0],0,-person[i].playerrotation,0);
+ person[i].tempanimation.position[j][0]=rotate(person[i].tempanimation.position[j][0],0,-person[i].playerrotation,0);
}
}
}
@@ -1654,7 +1653,7 @@ void Game::Tick()
aimjoint = lefthand;
}
start = person[j].playercoords
- + DoRotation(person[j].skeleton.joints[aimjoint].position,
+ + rotate(person[j].skeleton.joints[aimjoint].position,
0, person[j].playerrotation, 0);
if (j == 0 && person[j].grenphase) {
@@ -1663,10 +1662,10 @@ void Game::Tick()
start, aim * 200, 1.01);
}
- auto startsub = DoRotation(aim,
+ auto startsub = rotate(aim,
0, -person[j].playerrotation, 0);
- startsub = DoRotation(startsub, 90, 0, 0);
- startsub *= DoRotation(startsub,
+ startsub = rotate(startsub, 90, 0, 0);
+ startsub *= rotate(startsub,
0, person[j].playerrotation,0);
switch (person[j].whichgun) {
case sniperrifle:
@@ -1787,7 +1786,7 @@ void Game::Tick()
finalwallhit=wallhit;
- hitnorm=DoRotation(blocks[citytype[i][j]].normals[whichtri],0,cityrotation[i][j]*90,0);
+ hitnorm=rotate(blocks[citytype[i][j]].normals[whichtri],0,cityrotation[i][j]*90,0);
hitmove=move;
@@ -1952,7 +1951,7 @@ void Game::Tick()
totalarea=0;
for (auto& joint : person[whichhit].skeleton.joints) {
- joint.position = DoRotation(joint.position, 0, person[whichhit].playerrotation, 0);
+ joint.position = rotate(joint.position, 0, person[whichhit].playerrotation, 0);
joint.position += person[whichhit].playercoords;
joint.realoldposition = joint.position;
joint.velocity = person[whichhit].velocity;
@@ -2000,12 +1999,12 @@ void Game::Tick()
person[whichhit].skeleton.offset=1;
for (auto& joint : person[whichhit].skeleton.joints) {
- auto distance = sqrlen(DoRotation(joint.position, 0, person[whichhit].playerrotation, 0)
+ auto distance = sqrlen(rotate(joint.position, 0, person[whichhit].playerrotation, 0)
+ person[whichhit].playercoords
- hitstruct.hitlocation);
if(distance < 200) {
totalarea += 200 / distance;
- joint.offset += DoRotation(aim * 200 / distance / totalarea * 10,
+ joint.offset += rotate(aim * 200 / distance / totalarea * 10,
0, -person[whichhit].playerrotation, 0);
}
if (sqrlen(joint.offset) > 36)
@@ -2025,7 +2024,7 @@ void Game::Tick()
for (int tmp = 0; tmp < 4; ++tmp)
sprites.MakeSprite(bloodspritedown, 0.8f, 1, 0.2f, 0.2f,
person[whichhit].skeleton.joints[j].position,
- DoRotation(person[whichhit].skeleton.joints[j].velocity / 3,
+ rotate(person[whichhit].skeleton.joints[j].velocity / 3,
randUint(360), randUint(360), 0) / 5, 5);
person[whichhit].skeleton.DeleteJoint(j);
person[whichhit].skeleton.broken=1;
@@ -2234,7 +2233,7 @@ void Game::Tick()
if (whichtri != -1) {
impact = true;
- auto normalrotated = DoRotation(blocks[citytype[wherex][wherey]].normals[whichtri], 0, cityrotation[wherex][wherey] * 90, 0);
+ auto normalrotated = rotate(blocks[citytype[wherex][wherey]].normals[whichtri], 0, cityrotation[wherex][wherey] * 90, 0);
if (sprites.size[i] > 1)
decals.MakeDecal(crater, wallhit, 9, normalrotated, whichtri, &blocks[citytype[wherex][wherey]], move, cityrotation[wherex][wherey] * 90);
sprites.location[i] = wallhit + normalrotated * 0.02f;
@@ -2318,7 +2317,7 @@ void Game::Tick()
person[j].longdead=1;
for (auto& joint : person[j].skeleton.joints) {
joint.realoldposition = joint.position
- = DoRotation(joint.position,
+ = rotate(joint.position,
0, person[j].playerrotation, 0)
+ person[j].playercoords;
@@ -2342,12 +2341,12 @@ void Game::Tick()
person[j].skeleton.offset=1;
for (auto& joint : person[j].skeleton.joints) {
- auto distance = sqrlen(DoRotation(joint.position, 0, person[j].playerrotation, 0)
+ auto distance = sqrlen(rotate(joint.position, 0, person[j].playerrotation, 0)
+ person[j].playercoords
- hitstruct.hitlocation);
if (distance < 200) {
totalarea += 200 / distance;
- joint.offset += DoRotation(sprites.velocity[i] * 0.1 * 200 / distance / totalarea * 10, 0, -person[j].playerrotation, 0);
+ joint.offset += rotate(sprites.velocity[i] * 0.1 * 200 / distance / totalarea * 10, 0, -person[j].playerrotation, 0);
}
if (sqrlen(joint.offset) > 9) {
joint.offset = normalize(joint.offset) * 3;
@@ -2376,7 +2375,7 @@ void Game::Tick()
alSourcePlay(gSourceID[explosionsound]);
XYZ relation;
- camerashake=1-findDistance(person[0].playercoords,sprites.location[i])/200;
+ camerashake = 1 - len(person[0].playercoords - sprites.location[i]) / 200;
overpoint=sprites.location[i];
overpoint.y+=3000;
@@ -2434,10 +2433,10 @@ void Game::Tick()
person[k].bjoint2 = &person[k].skeleton.joints[neck];
for (auto& joint : person[k].skeleton.joints) {
- joint.position = DoRotation(joint.position, 0, person[k].playerrotation, 0);
+ joint.position = rotate(joint.position, 0, person[k].playerrotation, 0);
joint.position += person[k].playercoords;
joint.realoldposition = joint.position;
- joint.velocity = DoRotation(joint.velocity, 0, person[k].playerrotation, 0);
+ joint.velocity = rotate(joint.velocity, 0, person[k].playerrotation, 0);
joint.velocity += person[k].velocity;
joint.velocity.x += randInt(-9, 9);
joint.velocity.y += randInt(-9, 9);
@@ -2448,7 +2447,7 @@ void Game::Tick()
person[k].longdead=1;
for (auto& joint : person[k].skeleton.joints) {
relation = normalize(joint.position - sprites.location[i]);
- auto distance = findDistance(joint.position, sprites.location[i]);
+ auto distance = len(joint.position - sprites.location[i]);
if (distance > 1)
joint.velocity += relation / distance * 300;
else
@@ -2480,7 +2479,7 @@ void Game::Tick()
if(zoom)average=person[0].skeleton.joints[righthand].position;
- if(person[0].skeleton.free==0&&thirdperson!=2)camera.position=person[0].playercoords+DoRotation(average,0,person[0].playerrotation,0);
+ if(person[0].skeleton.free==0&&thirdperson!=2)camera.position=person[0].playercoords+rotate(average,0,person[0].playerrotation,0);
if(person[0].skeleton.free==1&&thirdperson!=2)camera.position=average;