1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-23 20:59:58 +01:00

Add collisions to city

This commit is contained in:
Miloslav Číž 2019-06-19 19:05:18 +02:00
parent e91467a869
commit d7f0804248

View file

@ -258,7 +258,19 @@ int main()
{ {
if (coll == 1) if (coll == 1)
{ {
models[1].transform.translation = previousPos; S3L_Vec4 newPos = models[1].transform.translation;
newPos.x = previousPos.x;
if (collision(newPos))
{
newPos = models[1].transform.translation;
newPos.z = previousPos.z;
if (collision(newPos))
newPos = previousPos;
}
models[1].transform.translation = newPos;
} }
else if (coll == 2) else if (coll == 2)
{ {
@ -272,6 +284,7 @@ int main()
} }
} }
scene.camera.transform.translation.x = scene.models[1].transform.translation.x - carDirection.x; scene.camera.transform.translation.x = scene.models[1].transform.translation.x - carDirection.x;
scene.camera.transform.translation.y = S3L_FRACTIONS_PER_UNIT / 2; scene.camera.transform.translation.y = S3L_FRACTIONS_PER_UNIT / 2;
scene.camera.transform.translation.z = scene.models[1].transform.translation.z - carDirection.z; scene.camera.transform.translation.z = scene.models[1].transform.translation.z - carDirection.z;