MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / R_drawSceneLights

Function R_drawSceneLights

engine/src/game.cpp:1682–1726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1680}
1681
1682void R_drawSceneLights(TileMap* ptilemap, float ls)
1683{
1684 ScreenRect dstRect;
1685 float bounce;
1686 for (int i = 0; i < ptilemap->animatedTiles.size(); i++)
1687 {
1688 float lx =
1689 ptilemap->animatedTiles[i].position.x * ptilemap->w_tileSize.x -
1690 ls / 2 + ptilemap->w_tileSize.x / 2;
1691 float ly =
1692 ptilemap->animatedTiles[i].position.y * ptilemap->w_tileSize.y -
1693 ls / 2 + ptilemap->w_tileSize.y / 2;
1694 if (lx < camera.position.x + camera.size.x &&
1695 lx + ls > camera.position.x &&
1696 ly < camera.position.y + camera.size.y &&
1697 ly + ls > camera.position.y)
1698 {
1699 bounce = ptilemap
1700 ->imageLayer[ptilemap->animatedTiles[i].position.x]
1701 [ptilemap->animatedTiles[i].position.y]
1702 .bounce;
1703 dstRect = ScreenRect(lx, ly + bounce, ls, ls);
1704 if (ptilemap
1705 ->imageLayer[ptilemap->animatedTiles[i].position.x]
1706 [ptilemap->animatedTiles[i].position.y]
1707 .atileIndex == 245)
1708 glColor4f(1.0f, 0.0f, 0.0f, 0.75f);
1709 else if (ptilemap
1710 ->imageLayer[ptilemap->animatedTiles[i].position.x]
1711 [ptilemap->animatedTiles[i].position.y]
1712 .atileIndex == 246)
1713 glColor4f(0.1f, 0.1f, 1.0f, 0.15f);
1714 else
1715 glColor4f(1.0f, 1.0f, 0.2f, 0.25f);
1716 glTexCoord2d(0, 0);
1717 glVertex2f(dstRect.fLeft(), dstRect.fTop());
1718 glTexCoord2d(1, 0);
1719 glVertex2f(dstRect.fRight(), dstRect.fTop());
1720 glTexCoord2d(1, 1);
1721 glVertex2f(dstRect.fRight(), dstRect.fBottom());
1722 glTexCoord2d(0, 1);
1723 glVertex2f(dstRect.fLeft(), dstRect.fBottom());
1724 }
1725 }
1726}
1727
1728void R_render()
1729{

Callers 1

R_renderFunction · 0.85

Calls 5

ScreenRectClass · 0.85
fLeftMethod · 0.80
fTopMethod · 0.80
fRightMethod · 0.80
fBottomMethod · 0.80

Tested by

no test coverage detected