diff --git a/data/levels/Compositions.xml b/data/levels/Compositions.xml index 7513f12..c7fb5b2 100644 --- a/data/levels/Compositions.xml +++ b/data/levels/Compositions.xml @@ -482,7 +482,7 @@ brazier.obj 0.0 - 0.5 + 0.35 0.0 0.0 0.0 diff --git a/data/levels/Level1.png b/data/levels/Level1.png index e4ec2da..a773401 100644 Binary files a/data/levels/Level1.png and b/data/levels/Level1.png differ diff --git a/data/levels/Level1.xcf b/data/levels/Level1.xcf index ba766a6..a9b48b7 100644 Binary files a/data/levels/Level1.xcf and b/data/levels/Level1.xcf differ diff --git a/data/levels/Level1.xml b/data/levels/Level1.xml index 52e2ac3..882e0f1 100644 --- a/data/levels/Level1.xml +++ b/data/levels/Level1.xml @@ -1,3 +1,123 @@ + + 1.0 + 0.0 + 0.0 + 0.0 + false + -6.500000 + 0.0 + 54.500000 + 0 + 231 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + + + 1.0 + 0.0 + 0.0 + 0.0 + false + -6.500000 + 0.0 + 26.500000 + 0 + 226 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + + + 1.0 + 0.0 + 0.0 + 0.0 + false + -53.500000 + 0.0 + 54.500000 + 0 + 225 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + + + 1.0 + 0.0 + 0.0 + 0.0 + false + -53.500000 + 0.0 + 26.500000 + 0 + 141 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + 1.0 0.0 @@ -27,122 +147,6 @@ - - 1.0 - 0.0 - 0.0 - 0.0 - false - -6.500000 - 0.0 - 54.500000 - 0 - 140 - 81 - - - - 0 - 0 - 0 - - - - - 1.0 - false - 0 - - - 0 - 0 - 0 - - - - - 1.0 - 0.0 - 0.0 - 0.0 - false - -6.500000 - 0.0 - 26.500000 - 0 - 139 - 81 - - - - 0 - 0 - 0 - - - - - 1.0 - false - 0 - - - 0 - 0 - 0 - - - - - 1.0 - 0.0 - 0.0 - 0.0 - false - -53.500000 - 0.0 - 54.500000 - 0 - 138 - 81 - - - - 0 - 0 - 0 - - - - - 1.0 - false - 0 - - - 0 - 0 - 0 - - - - - 1.0 - 0.0 - 0.0 - 0.0 - false - -53.500000 - 0.0 - 26.500000 - 0 - 137 - 81 - - - - 0 - 0 - 0 - - - - - 1.0 - false - 0 - - - 0 - 0 - 0 - - - 1.0 0.0 diff --git a/data/levels/Level1Backup.xml b/data/levels/Level1Backup.xml index 0b55d71..8567b8b 100644 --- a/data/levels/Level1Backup.xml +++ b/data/levels/Level1Backup.xml @@ -1,3 +1,153 @@ + + 1.0 + 0.0 + 0.0 + 0.0 + false + -217.500000 + 0.0 + 210.500000 + 0 + 137 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + + + 1.0 + 0.0 + 0.0 + 0.0 + false + -6.500000 + 0.0 + 54.500000 + 0 + 231 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + + + 1.0 + 0.0 + 0.0 + 0.0 + false + -6.500000 + 0.0 + 26.500000 + 0 + 226 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + + + 1.0 + 0.0 + 0.0 + 0.0 + false + -53.500000 + 0.0 + 54.500000 + 0 + 225 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + + + 1.0 + 0.0 + 0.0 + 0.0 + false + -53.500000 + 0.0 + 26.500000 + 0 + 141 + 245 + + - + false + 0 + 0 + 0 + - + - + 1.0 + false + 0 + - + 0 + 0 + 0 + + + 1.0 0.0 @@ -8,124 +158,8 @@ 0.0 216.500000 0 - 141 - 150 - - - - 0 - 0 - 0 - - - - - 1.0 - false - 0 - - - 0 - 0 - 0 - - - - - 1.0 - 0.0 - 0.0 - 0.0 - false - -6.500000 - 0.0 - 54.500000 - 0 - 140 - 81 - - - - 0 - 0 - 0 - - - - - 1.0 - false - 0 - - - 0 - 0 - 0 - - - - - 1.0 - 0.0 - 0.0 - 0.0 - false - -6.500000 - 0.0 - 26.500000 - 0 - 139 - 81 - - - - 0 - 0 - 0 - - - - - 1.0 - false - 0 - - - 0 - 0 - 0 - - - - - 1.0 - 0.0 - 0.0 - 0.0 - false - -53.500000 - 0.0 - 54.500000 - 0 - 138 - 81 - - - - 0 - 0 - 0 - - - - - 1.0 - false - 0 - - - 0 - 0 - 0 - - - - - 1.0 - 0.0 - 0.0 - 0.0 - false - -53.500000 - 0.0 - 26.500000 - 0 - 137 - 81 + 142 + 250 - 0 @@ -866,7 +900,7 @@ 51.5 - - - 0.2 + 0.1 true 0 openSecondDoor1.lua @@ -882,7 +916,7 @@ 51.5 - - - 0.2 + 0.1 false 0 openSecondDoor1.lua @@ -919,7 +953,7 @@ 29.5 - - - 0.2 + 0.1 true 0 openSecondDoor3.lua @@ -935,7 +969,7 @@ 29.5 - - - 0.2 + 0.1 false 0 openSecondDoor3.lua @@ -2596,7 +2630,7 @@ 51.5 - - - 0.2 + 0.1 true 0 openSecondDoor4.lua @@ -2612,7 +2646,7 @@ 51.5 - - - 0.2 + 0.1 false 0 openSecondDoor4.lua @@ -2678,7 +2712,7 @@ 29.5 - - - 0.2 + 0.1 true 0 openSecondDoor2.lua @@ -2694,7 +2728,7 @@ 29.5 - - - 0.2 + 0.1 false 0 openSecondDoor2.lua @@ -3891,7 +3925,7 @@ 67.5 - - - 0.2 + 0.1 true 0 openThirdDoor.lua @@ -3907,7 +3941,7 @@ 67.5 - - - 0.2 + 0.1 false 0 openThirdDoor.lua @@ -6380,7 +6414,7 @@ 159.5 - - - 0.2 + 0.1 true 0 openFirstDoor.lua @@ -6396,7 +6430,7 @@ 159.5 - - - 0.2 + 0.1 false 0 openFirstDoor.lua @@ -6413,7 +6447,7 @@ 0.0 false 17.500000 - 0.0 + 5.0 81.500000 1 94 @@ -8798,7 +8832,7 @@ 0.0 false -81.500000 - 0.0 + 5.0 4.500000 1 8 @@ -10748,7 +10782,7 @@ 0.0 false -172.500000 - 0.0 + 5.0 58.500000 0 178 @@ -11921,18 +11955,51 @@ 105 20 - - + resetPlayer + false 0 - 0 + -100000 0 - - - 1.0 + 100015 false 0 - - + resetPlayer.lua 0 - 0 + 105 + 0 + + + sunStart + false + -216 + 20 + 34 + - + - + 10 + false + 0 + sunStart.lua + 0 + 105 + 0 + + + sunUpdate + false + -216 + 20 + 34 + - + - + 10 + false + 0 + sunUpdate.lua + 0 + 105 0 @@ -12114,12 +12181,14 @@ - skydome.png + skydome.obj + skydomeNew.png + nightskydome.png 0.9 - 100.0 + 200.0 diff --git a/data/levels/heightmapLvl1.xcf b/data/levels/heightmapLvl1.xcf index babe3a1..5cd76d0 100644 Binary files a/data/levels/heightmapLvl1.xcf and b/data/levels/heightmapLvl1.xcf differ diff --git a/data/loadingscreen/computer_key_A.png b/data/loadingscreen/computer_key_A.png new file mode 100644 index 0000000..c489d1c Binary files /dev/null and b/data/loadingscreen/computer_key_A.png differ diff --git a/data/loadingscreen/computer_key_D.png b/data/loadingscreen/computer_key_D.png new file mode 100644 index 0000000..dcf9b43 Binary files /dev/null and b/data/loadingscreen/computer_key_D.png differ diff --git a/data/loadingscreen/computer_key_Esc.png b/data/loadingscreen/computer_key_Esc.png new file mode 100644 index 0000000..06b9584 Binary files /dev/null and b/data/loadingscreen/computer_key_Esc.png differ diff --git a/data/loadingscreen/computer_key_S.png b/data/loadingscreen/computer_key_S.png new file mode 100644 index 0000000..ca8b1e8 Binary files /dev/null and b/data/loadingscreen/computer_key_S.png differ diff --git a/data/loadingscreen/computer_key_W.png b/data/loadingscreen/computer_key_W.png new file mode 100644 index 0000000..68c3b22 Binary files /dev/null and b/data/loadingscreen/computer_key_W.png differ diff --git a/data/loadingscreen/computer_mouse_rounded.png b/data/loadingscreen/computer_mouse_rounded.png new file mode 100644 index 0000000..1ccb841 Binary files /dev/null and b/data/loadingscreen/computer_mouse_rounded.png differ diff --git a/data/loadingscreen/loadingscreen.png b/data/loadingscreen/loadingscreen.png new file mode 100644 index 0000000..4162d66 Binary files /dev/null and b/data/loadingscreen/loadingscreen.png differ diff --git a/data/loadingscreen/loadingscreen.xcf b/data/loadingscreen/loadingscreen.xcf new file mode 100644 index 0000000..7aecf36 Binary files /dev/null and b/data/loadingscreen/loadingscreen.xcf differ diff --git a/data/loadingscreen/loadingscreenContinue.png b/data/loadingscreen/loadingscreenContinue.png new file mode 100644 index 0000000..e8d5e64 Binary files /dev/null and b/data/loadingscreen/loadingscreenContinue.png differ diff --git a/data/loadingscreen/loadingscreenContinue.xcf b/data/loadingscreen/loadingscreenContinue.xcf new file mode 100644 index 0000000..193ffef Binary files /dev/null and b/data/loadingscreen/loadingscreenContinue.xcf differ diff --git a/level.cc b/level.cc index 735a3d2..6ac2f8f 100644 --- a/level.cc +++ b/level.cc @@ -71,7 +71,7 @@ void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseD mouseDelta.x=mouseDelta.y=0; } - int runs = 2; + int runs = 4; if(i>=20) { diff --git a/physics.cc b/physics.cc index ed6c952..c3b5a86 100644 --- a/physics.cc +++ b/physics.cc @@ -24,47 +24,79 @@ void Physics::init(std::string geometryPath) //prepares bullet by creating all i void Physics::takeUpdateStep(float timeDiff) { - counter++; - if(counter<1) + if(simulationActive) { - world->stepSimulation(timeDiff); //allows the world to be simmulated correctly indipendant of the timedifferences between frames - return; - } - - for(unsigned i = 0; i < allPositionConstraints.size();i++) //this handles the spring constraints - { - if(allPositionConstraints[i].position != allPositionConstraints[i].body->getCenterOfMassPosition()) //if constraint != position of the body because otherwise dir = 0 + counter++; + if(counter<1) { - btVector3 dir = allPositionConstraints[i].position - allPositionConstraints[i].body->getCenterOfMassPosition(); - dir = dir*allPositionConstraints[i].strength - allPositionConstraints[i].body->getLinearVelocity() - *allPositionConstraints[i].body->getLinearVelocity().length(); - allPositionConstraints[i].body->applyCentralForce(dir*allPositionConstraints[i].strength); //apply a foce upon the object pushing it towards the constraint position + world->stepSimulation(timeDiff); //allows the world to be simmulated correctly indipendant of the timedifferences between frames + return; + } + + for(unsigned i = 0; i < allPositionConstraints.size();i++) //this handles the spring constraints + { + if(allPositionConstraints[i].position != allPositionConstraints[i].body->getCenterOfMassPosition()) //if constraint != position of the body because otherwise dir = 0 + { + btVector3 dir = allPositionConstraints[i].position - allPositionConstraints[i].body->getCenterOfMassPosition(); + dir = dir*allPositionConstraints[i].strength - allPositionConstraints[i].body->getLinearVelocity() + *allPositionConstraints[i].body->getLinearVelocity().length(); + allPositionConstraints[i].body->applyCentralForce(dir*allPositionConstraints[i].strength); //apply a foce upon the object pushing it towards the constraint position + } + } + + + btVector3 position = cameraBody->getCenterOfMassPosition() - playerBall->getCenterOfMassPosition(); //gets a vector from the player to the camera + position = currentDirection; + position.normalize(); + position *= cameraDistance; + position += playerBall->getCenterOfMassPosition(); //is the position cameraDistance away from the player in the direction of the camera + + //prevent the camera from being dragged along on the ground + + btVector3 dir = cameraBody->getCenterOfMassPosition() - position; + float str = 50 * dir.length() / cameraBody->getInvMass(); //getInvMass() returns the inverted mass + + cameraBody->setLinearVelocity(btVector3(0,0,0)); + cameraBody->applyCentralForce(-dir*str*10) ; //scale the force by camera mass + counter=0; + float speed = cameraBody->getLinearVelocity().length(); + if(speed>20.0f) + { + position = cameraBody->getLinearVelocity(); + position.normalize(); + cameraBody->setLinearVelocity(position*20); + } + world->stepSimulation(timeDiff); + } + else + { + if(sinking) + { + btVector3 currentPos = playerBall->getCenterOfMassPosition(); + currentPos -= btVector3(0,0.003f,0); + playerBall->setCenterOfMassTransform(btTransform(playerBall->getOrientation(),currentPos)); + if(playerBall->getCenterOfMassPosition().y() < resetHight - 3) + { + playerBall->setCenterOfMassTransform(btTransform(btQuaternion(0,0,0,1),btVector3(startPosition.x(),startPosition.y() - 3,startPosition.z()))); + playerBall->setLinearVelocity(btVector3(0,0,0)); + playerBall->setAngularVelocity(btVector3(0,0,0)); + forceMoveCamera(startPosition + btVector3(currentDirection.x()*cameraDistance,currentDirection.y()*cameraDistance,currentDirection.z()*cameraDistance)); + sinking = false; + } + } + else + { + btVector3 currentPos = playerBall->getCenterOfMassPosition(); + currentPos += btVector3(0,0.009f,0); + playerBall->setCenterOfMassTransform(btTransform(playerBall->getOrientation(),currentPos)); + + if(playerBall->getCenterOfMassPosition().y() >= startPosition.y() + 1) + { + sinking = true; + simulationActive = true; + } } } - - - btVector3 position = cameraBody->getCenterOfMassPosition() - playerBall->getCenterOfMassPosition(); //gets a vector from the player to the camera - position = currentDirection; - position.normalize(); - position *= cameraDistance; - position += playerBall->getCenterOfMassPosition(); //is the position cameraDistance away from the player in the direction of the camera - - //prevent the camera from being dragged along on the ground - - btVector3 dir = cameraBody->getCenterOfMassPosition() - position; - float str = 50 * dir.length() / cameraBody->getInvMass(); //getInvMass() returns the inverted mass - - cameraBody->setLinearVelocity(btVector3(0,0,0)); - cameraBody->applyCentralForce(-dir*str*10) ; //scale the force by camera mass - counter=0; - float speed = cameraBody->getLinearVelocity().length(); - if(speed>20.0f) - { - position = cameraBody->getLinearVelocity(); - position.normalize(); - cameraBody->setLinearVelocity(position*20); - } - world->stepSimulation(timeDiff); } void Physics::removePositionConstraint(int bodyIndice) //remover function for deleting all pos constraints on one body @@ -105,6 +137,8 @@ void Physics::addPlayer(float friction, float rad, Entity entity, float mass, fl btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(glmQuat.x,glmQuat.y,glmQuat.z,glmQuat.w),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z))); //next we define the motionstate, wich describes the innital position and rotation + startPosition =btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z); + btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia); //next we process all data for the rigid body into info info.m_friction = friction*2; //here we modify the friction and restitution (bounciness) of the object @@ -144,7 +178,7 @@ void Physics::addTerrain(int width, int length, float** heightData) //The terrai btHeightfieldTerrainShape* terrainShape = new btHeightfieldTerrainShape(length,width,heightfield,highest,1,true,false); btRigidBody::btRigidBodyConstructionInfo info(0,new btDefaultMotionState(),terrainShape,btVector3(0,0,0)); //next we process all data for the rigid body into info - info.m_friction = 1; + info.m_friction = 0.8f; info.m_restitution = 0; btRigidBody* tBody = new btRigidBody(info); @@ -436,7 +470,7 @@ bool Physics::playerWithObject() void Physics::addCamera() //Camera Creator automatically called when player is created { - btSphereShape* sphere = new btSphereShape(0.2f); //we use this to make a more interesting camera, that does not interpenetrate with the terrain/objects + btSphereShape* sphere = new btSphereShape(0.5f); //we use this to make a more interesting camera, that does not interpenetrate with the terrain/objects btVector3 inertia(0,0,0); //rotation handled elsewhere (as it always has to look at the player) @@ -578,18 +612,22 @@ void Physics::forceMove(glm::vec3 newPosition, unsigned indice)//ugly, but neede { bodies[indice]->setCenterOfMassTransform(btTransform(btQuaternion(0,0,0,1),btVector3(newPosition.x,newPosition.y,newPosition.z))); bodies[indice]->setLinearVelocity(btVector3(0,0,0)); + bodies[indice]->setAngularVelocity(btVector3(0,0,0)); } void Physics::forcePlayer(glm::vec3 newPosition)//ugly, but needed for reset { - playerBall->setCenterOfMassTransform(btTransform(btQuaternion(0,0,0,1),btVector3(newPosition.x,newPosition.y,newPosition.z))); - playerBall->setLinearVelocity(btVector3(0,0,0)); - forceMoveCamera(newPosition + glm::vec3(currentDirection.x()*cameraDistance,currentDirection.y()*cameraDistance,currentDirection.z()*cameraDistance)); + if(!simulationActive) + return; + simulationActive = false; + resetHight = playerBall->getCenterOfMassPosition().y(); + + startPosition = btVector3(newPosition.x,newPosition.y,newPosition.z); } -void Physics::forceMoveCamera(glm::vec3 newPosition) +void Physics::forceMoveCamera(btVector3 newPosition) { - cameraBody->setCenterOfMassTransform(btTransform(btQuaternion(0,0,0,1),btVector3(newPosition.x,newPosition.y,newPosition.z))); + cameraBody->setCenterOfMassTransform(btTransform(btQuaternion(0,0,0,1),newPosition)); } void Physics::kill() //delete dynamically allocated memory diff --git a/physics.hh b/physics.hh index de2be9c..49d9571 100644 --- a/physics.hh +++ b/physics.hh @@ -72,7 +72,7 @@ class Physics { void kill(); void addButtonFrame(Entity entity); void forceMove(glm::vec3 newPosition, unsigned indice); - void forceMoveCamera(glm::vec3 newPosition); + void forceMoveCamera(btVector3 newPosition); void addConvexBody(Entity entity, std::string path, float mass, float dampningL, float dampningA, unsigned indice, float scaling, bool rotate); void prepareCollisionDetection(); bool playerWithGround(); @@ -82,6 +82,10 @@ class Physics { struct positionConstraint{btRigidBody* body; float strength; btVector3 position;}; private: + btVector3 startPosition = btVector3(0,0,0); + float resetHight = 0; + bool simulationActive = true; + bool sinking = true; btVector3 currentDirection = btVector3(1,1,1); btRigidBody* playerBall; //allows for easier access to the ball btRigidBody* terrainBody; //duh