Skip to Content
Programming 2D Games
book

Programming 2D Games

by Charles Kelly
June 2012
Beginner
438 pages
15h 26m
English
A K Peters/CRC Press
Content preview from Programming 2D Games
2679.4. Shadows and Reflections
//========================================================================
// Draw the plane and shadow
//========================================================================
void Plane::draw()
{
// Draw shadow
planeY = spriteData.y; // Save plane Y
spriteData.y = planeNS::SHADOW_Y;
// Draw shadow using colorFilter 25% alpha
shadow.draw(spriteData, graphicsNS::ALPHA25 & graphicsNS::BLACK);
spriteData.y = planeY; // Restore plane Y
// Draw plane
Entity::draw();
}
Listing 9.8. Drawing the plane and shadow.
e plane’s draw function draws the shadow then the plane. We draw the shadow rst
because we want the plane to alwa ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning 3D Game Programming

Beginning 3D Game Programming

Tom Miller

Publisher Resources

ISBN: 9781466508705