Game Development Reference
In-Depth Information
Chapter 4. Object
Debug Rendering
Our current application is not very scalable, and does not provide much in the way of
debug information to help us work with the physics system. So in this chapter, we will
be performing some code refactoring to help us handle these situations in a robust
Handling multiple objects
We're currently hard coding one pointer and making one call to DrawBox() to create
our first object. Continuing down this path by adding a second pointer, and a second
call to DrawBox() would make introducing even more objects into the scene an awk-
ward and painful process.
A wise course of action to take at this early stage is to build a system that allows us to
encapsulate important object data (such as the object's shape, collision shape, mo-
tion state, and color) in its own class. This way we can iterate through all of our ob-
jects, regardless of private information, and use common calls to update and render
In order to accomplish this, we will have to make five significant changes to our object
• Create a GameObject class to store our object's data
• Instantiate our objects from GameObject and store them in a data structure
• Modify our rendering system to iterate through the aforementioned data struc-
• Have the rendering system detect the type of shape and render the appropri-
ate polygons
• Write a new function to simplify the creation of objects
Search WWH ::

Custom Search