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

Method drawRoutine7

src/Battlescape/UnitSprite.cpp:1069–1131  ·  view source on GitHub ↗

* Drawing routine for chryssalid. */

Source from the content-addressed store, hash-verified

1067 * Drawing routine for chryssalid.
1068 */
1069void UnitSprite::drawRoutine7()
1070{
1071
1072 Surface *torso = 0, *legs = 0, *leftArm = 0, *rightArm = 0;
1073 // magic numbers
1074 const int Torso = 24, legsStand = 16, die = 224;
1075 const int larmStand = 0, rarmStand = 8;
1076 const int legsWalk[8] = { 48, 48+24, 48+24*2, 48+24*3, 48+24*4, 48+24*5, 48+24*6, 48+24*7 };
1077 const int larmWalk[8] = { 32, 32+24, 32+24*2, 32+24*3, 32+24*4, 32+24*5, 32+24*6, 32+24*7 };
1078 const int rarmWalk[8] = { 40, 40+24, 40+24*2, 40+24*3, 40+24*4, 40+24*5, 40+24*6, 40+24*7 };
1079 const int yoffWalk[8] = {1, 0, -1, 0, 1, 0, -1, 0}; // bobbing up and down
1080
1081 if (_unit->isOut())
1082 {
1083 // unit is drawn as an item
1084 return;
1085 }
1086
1087 if (_unit->getStatus() == STATUS_COLLAPSING)
1088 {
1089 torso = _unitSurface->getFrame(die + _unit->getFallingPhase());
1090 torso->blit(this);
1091 return;
1092 }
1093
1094 const int unitDir = _unit->getDirection();
1095 const int walkPhase = _unit->getWalkingPhase();
1096
1097 torso = _unitSurface->getFrame(Torso + unitDir);
1098
1099
1100 // when walking, torso(fixed sprite) has to be animated up/down
1101 if (_unit->getStatus() == STATUS_WALKING)
1102 {
1103 torso->setY(yoffWalk[walkPhase]);
1104 legs = _unitSurface->getFrame(legsWalk[unitDir] + walkPhase);
1105 leftArm = _unitSurface->getFrame(larmWalk[unitDir] + walkPhase);
1106 rightArm = _unitSurface->getFrame(rarmWalk[unitDir] + walkPhase);
1107 }
1108 else
1109 {
1110
1111 legs = _unitSurface->getFrame(legsStand + unitDir);
1112 leftArm = _unitSurface->getFrame(larmStand + unitDir);
1113 rightArm = _unitSurface->getFrame(rarmStand + unitDir);
1114 leftArm->setY(0);
1115 rightArm->setY(0);
1116 torso->setY(0);
1117 }
1118
1119 // blit order depends on unit direction
1120 switch (unitDir)
1121 {
1122 case 0: leftArm->blit(this); legs->blit(this); torso->blit(this); rightArm->blit(this); break;
1123 case 1: leftArm->blit(this); legs->blit(this); torso->blit(this); rightArm->blit(this); break;
1124 case 2: leftArm->blit(this); legs->blit(this); torso->blit(this); rightArm->blit(this); break;
1125 case 3: legs->blit(this); torso->blit(this); leftArm->blit(this); rightArm->blit(this); break;
1126 case 4: rightArm->blit(this); legs->blit(this); torso->blit(this); leftArm->blit(this); break;

Callers

nothing calls this directly

Calls 8

isOutMethod · 0.80
getFrameMethod · 0.80
getFallingPhaseMethod · 0.80
getWalkingPhaseMethod · 0.80
getStatusMethod · 0.45
blitMethod · 0.45
getDirectionMethod · 0.45
setYMethod · 0.45

Tested by

no test coverage detected