MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / drawRoutine6

Method drawRoutine6

src/Battlescape/UnitSprite.cpp:893–1064  ·  view source on GitHub ↗

* Drawing routine for snakemen. */

Source from the content-addressed store, hash-verified

891 * Drawing routine for snakemen.
892 */
893void UnitSprite::drawRoutine6()
894{
895 Surface *torso = 0, *legs = 0, *leftArm = 0, *rightArm = 0, *itemA = 0, *itemB = 0;
896 // magic numbers
897 const int Torso = 24, legsStand = 16, die = 96;
898 const int larmStand = 0, rarmStand = 8, rarm1H = 99, larm2H = 107, rarm2H = 115, rarmShoot = 123;
899 const int legsWalk[8] = { 32, 40, 48, 56, 64, 72, 80, 88 };
900 const int yoffWalk[8] = {3, 3, 2, 1, 0, 0, 1, 2}; // bobbing up and down
901 const int xoffWalka[8] = {0, 0, 1, 2, 3, 3, 2, 1};
902 const int xoffWalkb[8] = {0, 0, -1, -2, -3, -3, -2, -1};
903 const int yoffStand[8] = {2, 1, 1, 0, 0, 0, 0, 0};
904 const int offX[8] = { 8, 10, 5, 2, -8, -10, -5, -2 }; // for the weapons
905 const int offY[8] = { -6, -3, 0, 0, 2, -3, -7, -9 }; // for the weapons
906 const int offX2[8] = { -8, 2, 7, 13, 7, 0, -3, -15 }; // for the weapons
907 const int offY2[8] = { 1, -4, -2, 0, 3, 3, 5, 0 }; // for the weapons
908 const int offX3[8] = { 0, 6, 6, 12, -4, -5, -5, -13 }; // for the left handed rifles
909 const int offY3[8] = { -4, -4, -1, 0, 5, 0, 1, 0 }; // for the left handed rifles
910
911 if (_unit->isOut())
912 {
913 // unit is drawn as an item
914 return;
915 }
916
917 if (_unit->getStatus() == STATUS_COLLAPSING)
918 {
919 torso = _unitSurface->getFrame(die + _unit->getFallingPhase());
920 torso->blit(this);
921 return;
922 }
923
924 const int unitDir = _unit->getDirection();
925 const int walkPhase = _unit->getWalkingPhase();
926
927 torso = _unitSurface->getFrame(Torso + unitDir);
928 leftArm = _unitSurface->getFrame(larmStand + unitDir);
929 rightArm = _unitSurface->getFrame(rarmStand + unitDir);
930
931
932 // when walking, torso(fixed sprite) has to be animated up/down
933 if (_unit->getStatus() == STATUS_WALKING)
934 {
935 int xoffWalk = 0;
936 if(unitDir < 3)
937 xoffWalk = xoffWalka[walkPhase];
938 if(unitDir < 7 && unitDir > 3)
939 xoffWalk = xoffWalkb[walkPhase];
940 torso->setY(yoffWalk[walkPhase]);
941 torso->setX(xoffWalk);
942 legs = _unitSurface->getFrame(legsWalk[unitDir] + walkPhase);
943 rightArm->setY(yoffWalk[walkPhase]);
944 leftArm->setY(yoffWalk[walkPhase]);
945 rightArm->setX(xoffWalk);
946 leftArm->setX(xoffWalk);
947 }
948 else
949 {
950 legs = _unitSurface->getFrame(legsStand + unitDir);

Callers

nothing calls this directly

Calls 12

isOutMethod · 0.80
getFrameMethod · 0.80
getFallingPhaseMethod · 0.80
getWalkingPhaseMethod · 0.80
isTwoHandedMethod · 0.80
getHandSpriteMethod · 0.80
getStatusMethod · 0.45
blitMethod · 0.45
getDirectionMethod · 0.45
setYMethod · 0.45
setXMethod · 0.45
getRulesMethod · 0.45

Tested by

no test coverage detected