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
134 5. Sprites and Animation
planet.setX(GAME_WIDTH*0.5f - planet.getWidth()*0.5f);
planet.setY(GAME_HEIGHT*0.5f - planet.getHeight()*0.5f);
return;
}
Listing 5.28. Initializing the nebula and planet.
e Spacewar::render function calls graphics->spriteBegin() to begin draw-
ing sprites. en it calls nebula.draw() and planet.draw() functions to add the neb-
ula and planet to the scene. Sprite drawing is ended by calling graphics->spriteEnd()
(Listing 5.29).
e order of drawing is important. We want the planet to appear in front of the nebula so we
draw the nebula rst and then draw the planet.
We override the releaseAll and resetAll functions ...
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