Adjust all physics values to be modified by terrain types.

main
sigonasr2 3 months ago
parent 32f6165f7d
commit 13908da158
  1. 2
      assets/HamsterGame.tiled-session
  2. 132
      assets/TestLevel.tmx
  3. 60
      src/Hamster.cpp
  4. 15
      src/Hamster.h

@ -9,7 +9,7 @@
"fileStates": {
"TestLevel.tmx": {
"scale": 4,
"selectedLayer": 1,
"selectedLayer": 0,
"viewCenter": {
"x": 174.625,
"y": 138.625

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="1">
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="30" height="50" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="1">
<tileset firstgid="1" source="Terrain.tsx"/>
<layer id="1" name="Tile Layer 1" width="30" height="20">
<layer id="1" name="Tile Layer 1" width="30" height="50">
<data encoding="csv">
1206,494,494,1179,1181,1235,1151,1236,1154,1234,494,1238,1209,494,1079,1078,298,1082,1050,993,1054,1138,1022,1109,1079,1081,993,1082,1134,1137,
1262,1180,1181,1182,1209,494,494,494,1207,1206,1177,1235,1237,494,1079,1134,1135,1138,1134,1053,1107,1026,1078,1021,1054,1134,1135,1138,1022,1026,
@ -22,10 +22,40 @@
1178,494,494,494,1121,494,1121,1238,1209,1328,1380,1385,1385,1385,1385,1385,1385,1382,1328,1386,1386,1082,1413,1413,1413,1081,494,494,1179,1264,
1237,1149,1177,494,494,494,494,1238,1178,1328,1380,1385,1385,1385,1385,1385,1385,1382,1328,1386,1386,1110,1413,1413,1413,1081,494,1149,1235,1152,
494,1121,1149,1121,494,1149,1179,1266,1206,1328,1408,1381,1381,1381,1381,1381,1381,1410,1328,494,1238,1107,1108,1108,1108,1109,494,494,494,1149,
494,494,494,494,494,494,1235,1154,1234,1328,1328,1328,1328,1328,1328,1328,1328,1328,1328,494,1210,1209,494,1177,494,494,1149,1121,1121,494
494,494,494,494,494,494,1235,1154,1234,1328,1328,1328,1328,1328,1328,1328,1328,1328,1328,494,1210,1209,494,1177,494,494,1149,1121,1121,494,
1149,494,494,1177,1121,1177,494,1210,1178,1149,1121,494,494,1177,1210,1178,494,494,494,1121,1235,1237,494,1177,494,494,1149,1149,1179,1264,
494,1149,1121,1149,494,1121,494,1238,1178,494,494,494,494,494,1210,1206,494,1149,494,1121,1177,1177,494,494,494,494,494,1121,1238,1150,
494,494,1177,1121,494,494,1121,1210,1206,494,494,1121,494,1121,1235,1237,1177,494,494,494,494,494,494,494,494,1121,494,1149,1207,1262,
1149,494,1177,494,1177,494,494,1182,1234,494,494,494,1177,1121,1121,494,494,494,494,1149,494,494,1121,494,1177,494,1121,1121,1207,1150,
494,1149,494,494,494,494,1121,1238,1209,1121,494,494,1149,494,494,1121,1121,1179,1180,1180,1265,1263,1265,1263,1180,1264,1180,1263,1266,1262,
1179,1263,1264,1264,1010,1012,1012,1012,1014,1149,494,494,494,1121,1177,494,1177,1210,1150,1236,1151,1153,1153,1152,1153,1236,1153,1154,1150,1151,
1235,1151,1151,1152,1038,102,981,102,1070,1177,1177,1179,1263,1180,1264,1263,1264,1266,1178,494,494,1177,1149,1149,1121,494,1179,1266,1209,1121,
494,494,494,494,1066,102,102,102,1042,494,494,1210,1150,1151,1151,1153,1154,1150,1237,494,1121,494,1149,494,494,1121,1207,1150,1237,1149,
1149,1121,494,1177,1094,102,981,102,1042,1177,494,1235,1237,494,494,1121,1210,1178,1121,494,1177,494,1149,494,1149,494,1182,1234,494,494,
1181,1177,1121,1149,1066,1009,981,102,1098,1181,1177,494,1177,494,494,494,1182,1206,1121,494,494,1121,1149,494,494,1177,1210,1178,494,1177,
1234,494,494,494,1094,102,981,1009,1070,1237,494,494,1149,494,494,494,1238,1178,494,494,494,494,494,494,1149,494,1238,1234,1121,1149,
1209,494,1177,494,1038,102,102,1009,1098,1265,1180,480,1015,480,987,480,480,480,480,480,480,987,480,480,1181,494,1235,1237,1177,494,
1234,494,1177,1149,1066,102,102,102,1070,1151,1154,987,987,480,987,480,480,480,480,480,1015,480,480,1015,1209,1121,1179,1181,1149,1149,
1234,1149,494,494,1038,102,102,981,1042,1177,1238,480,480,480,480,480,1015,1015,480,987,480,480,480,480,1178,494,1235,1237,494,494,
1234,494,1149,1149,1094,102,102,1009,1070,1265,1266,1015,480,480,480,480,480,480,480,480,480,480,480,480,1262,1265,1264,1264,1264,1263,
1237,1149,1149,1149,1066,102,102,102,1070,1150,1153,1015,480,480,1015,480,480,480,987,987,480,480,480,1015,1150,1154,1150,1153,1152,1236,
1149,494,494,1179,1038,102,102,102,1070,1234,1149,480,480,987,987,987,987,480,480,987,480,480,480,480,1206,1207,1206,494,494,494,
494,494,1177,1207,1066,1009,1009,102,1070,1237,494,1015,987,480,987,480,480,480,480,480,1015,480,480,987,1237,1235,1237,494,494,494,
494,494,494,1207,1038,102,102,102,1042,1264,1263,987,480,987,480,480,480,480,1015,480,480,1015,480,480,494,494,494,1121,1121,494,
1149,494,1121,1182,1066,102,981,102,1098,1236,1154,480,480,480,480,480,480,1015,480,1015,480,480,480,480,1149,1121,494,494,1177,494,
1121,494,1121,1238,1122,1123,1123,1123,1126,494,1207,1015,480,480,480,480,480,480,480,480,480,480,480,1015,494,1177,494,494,494,494,
1149,1149,494,1210,1262,1180,1266,1178,494,494,1235,480,987,480,480,480,480,480,480,480,480,480,480,480,1121,494,1121,1149,1177,1149,
1149,494,494,1210,1150,1151,1236,1237,494,494,494,1015,480,987,480,480,480,480,987,987,1015,480,480,480,494,494,1121,1177,1177,1121,
1149,1149,494,1210,1234,1177,494,494,494,494,494,480,480,480,480,480,480,480,480,480,987,480,480,1015,1177,494,494,494,494,1149,
494,494,1149,1182,1209,494,494,494,494,494,494,480,480,480,987,1015,480,480,1015,480,480,480,480,480,1121,1121,494,494,494,494,
494,1149,494,1182,1178,494,494,494,494,494,494,987,987,987,480,480,987,480,480,987,987,480,480,1015,494,1177,494,494,494,1121,
494,494,494,1238,1234,494,494,1177,494,1177,1177,1121,494,494,494,494,1207,1178,494,1238,1234,494,1179,1263,1263,1263,1263,1263,1181,494,
494,494,494,1238,1209,1121,1177,1121,494,494,494,494,494,1179,1265,1265,1266,1262,1180,1266,1206,494,1210,1150,1236,1153,1154,1150,1237,494,
494,1177,494,1207,1178,494,494,494,494,1121,1177,1177,494,1210,1150,1153,1236,1152,1236,1236,1237,494,1207,1209,494,1177,1207,1178,494,494,
494,1177,1149,1238,1206,494,494,494,494,494,494,494,494,1238,1206,1149,1149,1177,1179,1265,1265,1265,1266,1209,494,494,1235,1237,1179,1264
</data>
</layer>
<layer id="2" name="Tile Layer 2" width="30" height="20">
<layer id="2" name="Tile Layer 2" width="30" height="50">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -46,10 +76,40 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0
</data>
</layer>

@ -128,13 +128,14 @@ void Hamster::HandlePlayerControls(){
if(aimingDir!=vf2d{}){
targetRot=aimingDir.norm().polar().y;
const vf2d currentVel{vel};
vel=vf2d{std::min(maxSpd,currentVel.polar().x+(maxSpd*HamsterGame::Game().GetElapsedTime())/timeToMaxSpd),rot}.cart();
vel+=vf2d{currentVel.polar().x+(GetMaxSpeed()*HamsterGame::Game().GetElapsedTime())/GetTimeToMaxSpeed(),rot}.cart();
vel=vf2d{std::min(GetMaxSpeed(),vel.polar().x),vel.polar().y}.cart();
frictionEnabled=false;
}
}
void Hamster::TurnTowardsTargetDirection(){
util::turn_towards_direction(rot,targetRot,turnSpd*HamsterGame::Game().GetElapsedTime());
util::turn_towards_direction(rot,targetRot,GetTurnSpeed()*HamsterGame::Game().GetElapsedTime());
}
void Hamster::MoveHamster(){
@ -143,7 +144,7 @@ void Hamster::MoveHamster(){
#pragma region Handle Friction
if(frictionEnabled){
const vf2d currentVel{vel};
vel=vf2d{std::max(0.f,currentVel.polar().x-friction*HamsterGame::Game().GetElapsedTime()),currentVel.polar().y}.cart();
vel=vf2d{std::max(0.f,currentVel.polar().x-GetFriction()*HamsterGame::Game().GetElapsedTime()),currentVel.polar().y}.cart();
}
#pragma endregion
}
@ -158,8 +159,8 @@ void Hamster::HandleCollision(){
vf2d collisionResolve2{h.GetPos()+vf2d{h.GetRadius(),float(randDir+geom2d::pi)}.cart()};
pos=collisionResolve1;
h.pos=collisionResolve2;
vel=vf2d{100.f,randDir}.cart();
h.vel=vf2d{100.f,float(randDir+geom2d::pi)}.cart();
vel=vf2d{GetBumpAmount(),randDir}.cart();
h.vel=vf2d{GetBumpAmount(),float(randDir+geom2d::pi)}.cart();
}else{
geom2d::line<float>collisionLine{geom2d::line<float>(GetPos(),h.GetPos())};
float distance{collisionLine.length()};
@ -169,8 +170,8 @@ void Hamster::HandleCollision(){
vf2d collisionResolve2{h.GetPos()+vf2d{bumpDistance/2.f,collisionLine.vector().polar().y}.cart()};
pos=collisionResolve1;
h.pos=collisionResolve2;
vel=vf2d{100.f,float(collisionLine.vector().polar().y+geom2d::pi)}.cart();
h.vel=vf2d{100.f,collisionLine.vector().polar().y}.cart();
vel=vf2d{GetBumpAmount(),float(collisionLine.vector().polar().y+geom2d::pi)}.cart();
h.vel=vf2d{GetBumpAmount(),collisionLine.vector().polar().y}.cart();
}
state=h.state=BUMPED;
bumpTimer=h.bumpTimer=0.12f;
@ -184,4 +185,49 @@ const float Hamster::GetRadius()const{
const Terrain::TerrainType Hamster::GetTerrainStandingOn()const{
return HamsterGame::Game().GetTerrainTypeAtPos(GetPos());
}
const float Hamster::GetTimeToMaxSpeed()const{
float finalTimeToMaxSpd{DEFAULT_TIME_TO_MAX_SPD};
if(GetTerrainStandingOn()==Terrain::ICE)finalTimeToMaxSpd*=3;
return finalTimeToMaxSpd;
}
const float Hamster::GetMaxSpeed()const{
float finalMaxSpd{DEFAULT_MAX_SPD};
switch(GetTerrainStandingOn()){
case Terrain::GRASS:{
finalMaxSpd*=0.80f;
}break;
case Terrain::SAND:{
finalMaxSpd*=0.60f;
}break;
case Terrain::SWAMP:{
finalMaxSpd*=0.50f;
}break;
case Terrain::SHORE:{
finalMaxSpd*=0.80f;
}break;
case Terrain::OCEAN:{
finalMaxSpd*=0.10f;
}break;
case Terrain::FOREST:{
finalMaxSpd*=0.50f;
}break;
}
return finalMaxSpd;
}
const float Hamster::GetFriction()const{
float finalFriction{DEFAULT_FRICTION};
if(GetTerrainStandingOn()==Terrain::ICE)finalFriction*=0.1f;
else if(GetTerrainStandingOn()==Terrain::SWAMP)finalFriction*=0.6f;
return finalFriction;
}
const float Hamster::GetTurnSpeed()const{
float finalTurnSpd{DEFAULT_TURN_SPD};
if(GetTerrainStandingOn()==Terrain::ICE)finalTurnSpd*=0.6f;
return finalTurnSpd;
}
const float Hamster::GetBumpAmount()const{
float finalBumpAmt{DEFAULT_BUMP_AMT};
return finalBumpAmt*GetMaxSpeed()/DEFAULT_MAX_SPD;
}

@ -61,14 +61,16 @@ class Hamster{
static const std::vector<std::string>NPC_HAMSTER_IMAGES;
static const std::string PLAYER_HAMSTER_IMAGE;
const float DEFAULT_MAX_SPD{128.f};
const float DEFAULT_TIME_TO_MAX_SPD{0.5f};
const float DEFAULT_FRICTION{400.f};
const float DEFAULT_TURN_SPD{2.f*geom2d::pi};
const float DEFAULT_BUMP_AMT{100.f};
vf2d pos;
vf2d vel;
float rot{};
float targetRot{};
float turnSpd{2.f*geom2d::pi};
float maxSpd{128.f};
float timeToMaxSpd{0.5f};
float friction{400.f};
bool frictionEnabled{false};
float collisionRadius{12.f};
float bumpTimer{};
@ -92,4 +94,9 @@ public:
void HandleCollision();
const float GetRadius()const;
const Terrain::TerrainType GetTerrainStandingOn()const;
const float GetTimeToMaxSpeed()const;
const float GetMaxSpeed()const;
const float GetFriction()const;
const float GetTurnSpeed()const;
const float GetBumpAmount()const;
};
Loading…
Cancel
Save