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

Method drawRoutine1

src/Battlescape/UnitSprite.cpp:545–680  ·  view source on GitHub ↗

* Drawing routine for floaters. */

Source from the content-addressed store, hash-verified

543 * Drawing routine for floaters.
544 */
545void UnitSprite::drawRoutine1()
546{
547
548 Surface *torso = 0, *leftArm = 0, *rightArm = 0, *itemA = 0, *itemB = 0;
549 // magic numbers
550 const int stand = 16, walk = 24, die = 64;
551 const int larm = 8, rarm = 0, larm2H = 67, rarm2H = 75, rarmShoot = 83, rarm1H= 91; // note that arms are switched vs "normal" sheets
552 const int yoffWalk[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // bobbing up and down
553 const int offX[8] = { 8, 10, 7, 4, -9, -11, -7, -3 }; // for the weapons
554 const int offY[8] = { -6, -3, 0, 2, 0, -4, -7, -9 }; // for the weapons
555 const int offX2[8] = { -8, 3, 7, 13, 6, -3, -5, -13 }; // for the weapons
556 const int offY2[8] = { 1, -4, -1, 0, 3, 3, 5, 0 }; // for the weapons
557 const int offX3[8] = { 0, 6, 6, 12, -4, -5, -5, -13 }; // for the left handed rifles
558 const int offY3[8] = { -4, -4, -1, 0, 5, 0, 1, 0 }; // for the left handed rifles
559 if (_unit->isOut())
560 {
561 // unit is drawn as an item
562 return;
563 }
564
565 if (_unit->getStatus() == STATUS_COLLAPSING)
566 {
567 torso = _unitSurface->getFrame(die + _unit->getFallingPhase());
568 torso->blit(this);
569 return;
570 }
571
572 const int unitDir = _unit->getDirection();
573 const int walkPhase = _unit->getWalkingPhase();
574
575 leftArm = _unitSurface->getFrame(larm + unitDir);
576 rightArm = _unitSurface->getFrame(rarm + unitDir);
577 // when walking, torso(fixed sprite) has to be animated up/down
578 if (_unit->getStatus() == STATUS_WALKING)
579 {
580 torso = _unitSurface->getFrame(walk + (5 * unitDir) + (walkPhase / 1.6)); // floater only has 5 walk animations instead of 8
581 torso->setY(yoffWalk[walkPhase]);
582 }
583 else
584 {
585 torso = _unitSurface->getFrame(stand + unitDir);
586 }
587
588 sortRifles();
589
590 // holding an item
591 if (_itemA)
592 {
593 // draw handob item
594 if (_unit->getStatus() == STATUS_AIMING && _itemA->getRules()->isTwoHanded())
595 {
596 int dir = (_unit->getDirection() + 2)%8;
597 itemA = _itemSurfaceA->getFrame(_itemA->getRules()->getHandSprite() + dir);
598 itemA->setX(offX[unitDir]);
599 itemA->setY(offY[unitDir]);
600 }
601 else
602 {

Callers

nothing calls this directly

Calls 13

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
getRulesMethod · 0.45
setXMethod · 0.45

Tested by

no test coverage detected