Game Development Reference
In-Depth Information
Rendering bitmaps
Instead of doing a simple demo of drawing a single bitmap on the screen, we will
make a small 2D tile-based world. In 2D graphics, the term tile refers to a small bit-
map image that represents one square of space in the 2D world. A
tile set
or
tile
sheet
is a single bitmap file that contains numerous tiles. A single 2D graphic tile is
also referred to as a
sprite
. To get started, add a new project named
TileWorld
to
the
SlimFramework
solution. So far, we've directly used the game window classes
we made. This time, we will see how we will do this in a real-world game project.
Add a new class file to the
TileWorld
project and name it
TileGameWindow.cs
.
As you may have guessed, we will make this new class inherit from the
GameWindow
class in our
SlimFramework
project. But first, we need to add a reference to the
SlimFramework
project. We've already covered this, so go ahead and add the ref-
erence. Don't forget to add a reference to SlimDX as well. You will also need to add
a reference to
System.Drawing
if there isn't one already. Also, don't forget to set
TileWorld
as the startup project.
Next, we need to add our
using
statements to the top of the
TileGameWindow.cs
file. We will need to add the following
using
statements:
using System.Windows.Forms;
using System.Collections,Generic;
using System.Diagnostics;
using System.Drawing;
using System;
using SlimDX;
using SlimDX.Direct2D;
using SlimDX.DirectInput;
using SlimDX.Windows;
Next, we need to create a couple of structs and member variables. First, let's define
the following
constant
at the top of this class:
const float PLAYER_MOVE_SPEED = 0.05f;