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

Method DrawTile

engine/src/tile.cpp:248–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248void TileMap::DrawTile(Camera *camera, ScreenRect dstRect, int index) {
249 if (!atlas || !atlas->sourceRectangles)
250 return;
251 if (index < 0 || index >= atlas->totalFrames)
252 return;
253
254 srcRect = atlas->sourceRectangles[index];
255 glTexCoord2d(srcRect.fLeft(), srcRect.fTop());
256 glVertex2f(dstRect.fLeft(), dstRect.fBottom());
257 glTexCoord2d(srcRect.fRight(), srcRect.fTop());
258 glVertex2f(dstRect.fRight(), dstRect.fBottom());
259 glTexCoord2d(srcRect.fRight(), srcRect.fBottom());
260 glVertex2f(dstRect.fRight(), dstRect.fTop());
261 glTexCoord2d(srcRect.fLeft(), srcRect.fBottom());
262 glVertex2f(dstRect.fLeft(), dstRect.fTop());
263}
264
265bool isAnimatedTile(int index) { return (index > 239) && (index < 256); }
266

Callers

nothing calls this directly

Calls 4

fLeftMethod · 0.80
fTopMethod · 0.80
fBottomMethod · 0.80
fRightMethod · 0.80

Tested by

no test coverage detected