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

Method drawProjectile

src/Geoscape/DogfightState.cpp:1506–1556  ·  view source on GitHub ↗

* Draws projectiles on the radar screen. * Depending on what type of projectile it is, it's * shape will be different. Currently works for * original sized blobs 3 x 6 pixels. */

Source from the content-addressed store, hash-verified

1504 * original sized blobs 3 x 6 pixels.
1505 */
1506void DogfightState::drawProjectile(const CraftWeaponProjectile* p) {
1507 if(_minimized)
1508 {
1509 return;
1510 }
1511 int xPos = _battle->getWidth() / 2 + p->getHorizontalPosition();
1512 // Draw missiles.
1513 if(p->getGlobalType() == CWPGT_MISSILE)
1514 {
1515 xPos -= 1;
1516 int yPos = _battle->getHeight() - p->getPosition() / 8;
1517 for(int x = 0; x < 3; ++x)
1518 {
1519 for(int y = 0; y < 6; ++y)
1520 {
1521 int pixelOffset = _projectileBlobs[p->getType()][y][x];
1522 if(pixelOffset == 0)
1523 {
1524 continue;
1525 }
1526 else
1527 {
1528 Uint8 radarPixelColor = _window->getPixel(xPos + x + 3, yPos + y + 3); // + 3 cause of the window frame
1529 Uint8 color = radarPixelColor - pixelOffset;
1530 if(color < 108)
1531 {
1532 color = 108;
1533 }
1534 _battle->setPixel(xPos + x, yPos + y, color);
1535 }
1536 }
1537 }
1538 }
1539 // Draw beams.
1540 else if(p->getGlobalType() == CWPGT_BEAM)
1541 {
1542 int yStart = _battle->getHeight() - 2;
1543 int yEnd = _battle->getHeight() - (_currentDist / 8);
1544 Uint8 pixelOffset = p->getState();
1545 for(int y = yStart; y > yEnd; --y)
1546 {
1547 Uint8 radarPixelColor = _window->getPixel(xPos + 3, y + 3);
1548 Uint8 color = radarPixelColor - pixelOffset;
1549 if(color < 108)
1550 {
1551 color = 108;
1552 }
1553 _battle->setPixel(xPos, y, color);
1554 }
1555 }
1556}
1557
1558/**
1559 * Toggles usage of weapon number 1.

Callers

nothing calls this directly

Calls 9

getHorizontalPositionMethod · 0.80
getGlobalTypeMethod · 0.80
getPixelMethod · 0.80
setPixelMethod · 0.80
getStateMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45
getPositionMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected