MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawGroundSpriteAt

Function DrawGroundSpriteAt

src/viewport.cpp:556–567  ·  view source on GitHub ↗

* Draws a ground sprite at a specific world-coordinate relative to the current tile. * If the current tile is drawn on top of a foundation the sprite is added as child sprite to the "foundation"-ParentSprite. * * @param image the image to draw. * @param pal the provided palette. * @param x position x (world coordinates) of the sprite relative to current tile. * @param y position y (world coo

Source from the content-addressed store, hash-verified

554 * @param extra_offs_y Pixel Y offset for the sprite position.
555 */
556void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32_t x, int32_t y, int z, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
557{
558 /* Switch to first foundation part, if no foundation was drawn */
559 if (_vd.foundation_part == FOUNDATION_PART_NONE) _vd.foundation_part = FOUNDATION_PART_NORMAL;
560
561 if (_vd.foundation[_vd.foundation_part] != -1) {
562 Point pt = RemapCoords(x, y, z);
563 AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, pt.x + extra_offs_x * ZOOM_BASE, pt.y + extra_offs_y * ZOOM_BASE);
564 } else {
565 AddTileSpriteToDraw(image, pal, _cur_ti.x + x, _cur_ti.y + y, _cur_ti.z + z, sub, extra_offs_x * ZOOM_BASE, extra_offs_y * ZOOM_BASE);
566 }
567}
568
569/**
570 * Draws a ground sprite for the current tile.

Callers 2

DrawRoadBitsFunction · 0.85
DrawGroundSpriteFunction · 0.85

Calls 3

RemapCoordsFunction · 0.85
AddTileSpriteToDrawFunction · 0.85

Tested by

no test coverage detected