On this page we have provided several samples illustrated various technical challenges in
game development. These samples include many examples that are commonly requested in this
course. All of these samples come with source code. You are allowed to use the code here
as reference or directly in your own games.
Right now, you will note that the samples page is pretty sparse. That is because a lot of
our legacy sample code is in MonoGame and XNA. In fact, some of those samples are in an
older version of XNA that no longer works. We are currently working to port our samples
to LibGDX, but it is going to take a while.
Because this page is a work-in-progress, we are always looking for more help. If you
find a bug, would like to update one of the demos, or would like to add a new demo,
you are more than welcome. In that case, contact the
with your contribution.
This example demonstrates image drawing, rotation and scaling, and background drawing
from an image. It also has sound effects and simple mathematics for physics. This is
the code from the first programming lab.
This example shows how to use free lists to keep control over your allocations.
Free lists are supported by the Pool class in LibGDX. These are particularly
useful for particle systems.
This example shows how to use JSON to define your level format. The modifying the
file allows you to change the level without recompiling the demo; just hit start.
However, not that the file level.json in Eclipse is not the file used by
the executable. You want the file in desktop/bin/jsons instead.
This example shows off parallax scrolling to give your game some feeling
of depth. Parallax scrolling does not actually give you 3D game play, but it
does make the game look nicer.
This example shows off how to use the Box2D physics engine for movement and
collision. It is much simpler than Lab 4 because there are no joints involved.
This shows the bare minimum that you can do with the engine. Use the number keys
0-9 to change the various settings in the demo.
This example shows off how to use Box2d to make a top-down game with simple lighting
effects. It requires an additional library called Box2DLights, which was an option
when you set up your game. Like the JSON Demo, this example defines the level layout
with JSON files, allowing you to reset the lights on the fly. There are multiple
light settings in this demo. Use the keys P and N to page through them all.
This example shows you how to do sophisticated texture mapping, beyond what is done
in the basic SpriteBatch class. This required us to make an alternative class to
SpriteBatch classed VertexBatch. The application itself is simple and displays
a single textured polygon. Press = or - to change the number of vertices on the
polygon, and press T to then texture on or off. You can distort the polygon by
clicking on a vertex and dragging it.