Book Image

LibGDX Game Development By Example

By : James Cook
Book Image

LibGDX Game Development By Example

By: James Cook

Overview of this book

Table of Contents (18 chapters)
LibGDX Game Development By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introducing the ShapeRenderer class


You are probably wondering why we are not diving straight into making more improvements to the game. Well, it is because I would like to show you something that will make your life easier when you start making more games, especially if you don't have any art ready for the game you are making and you want to see things come to life sooner. As an eager game developer myself, I know what that is like; you have an idea and you want to bring it to life faster than your artist can design, draw, and deliver. Alternatively, in the case of our Snake game, we can draw the grid that our snake moves in.

So, I introduce you to the ShapeRenderer class; its job is simple. According to http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html, the ShapeRenderer class does the following:

"Renders points, lines, shape outlines and filled shapes."

This means we will have the ability to draw boxes on the screen. Let's put this into...