MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / resolveFrame

Method resolveFrame

engine/src/entity.cpp:1096–1195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1094}
1095
1096void Player::resolveFrame(int elapsedframes)
1097{
1098 lastFrame = currentAtlasFrame;
1099
1100 if (velocity.y < 0)
1101 currentState = CS_FALLING;
1102
1103 float delaydivider = 1.0f;
1104 int endframe =
1105 static_cast<int>(frames->animations[animationState].size() - 1);
1106 bool loop = false;
1107 bool advance = true;
1108
1109 if (kicking)
1110 {
1111 setAnimationState(P_KICK, 0);
1112 }
1113 else if (lookingUp && holding && currentState != CS_MOVINGLEFT &&
1114 currentState != CS_MOVINGRIGHT)
1115 {
1116 setAnimationState(P_HOLD_LOOK, 0);
1117 }
1118 else if (crouching)
1119 {
1120 setAnimationState(P_DUCK, 0);
1121 }
1122 else
1123 {
1124 switch (currentState)
1125 {
1126 case CS_IDLE:
1127 if (holding)
1128 {
1129 setAnimationState(P_HOLD_IDLE, 0);
1130 }
1131 else
1132 {
1133 setAnimationState(P_IDLE, 0);
1134 }
1135 break;
1136
1137 case CS_MOVINGLEFT:
1138 case CS_MOVINGRIGHT:
1139 if (!holding)
1140 {
1141 setAnimationState(P_MOVE, currentAnimationFrame);
1142 }
1143 else
1144 {
1145 setAnimationState(P_HOLD_MOVE, currentAnimationFrame);
1146 }
1147 delaydivider = (1.0f + (2.0f * (int)isRunning));
1148 advanceAnimationFrame(elapsedframes, delaydivider, endframe,
1149 true);
1150 break;
1151
1152 case CS_JUMPING:
1153 if (!holding)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected