Game Development Reference
In-Depth Information
_playerCharacter
ΒΌ
new PlayerCharacter(_textureManager);
}
public void Update(double elapsedTime)
{
// Get controls and apply to player character
}
public void Render(Renderer renderer)
{
_playerCharacter.Render(renderer);
}
}
}
This code describes a level. It takes the input and persistent game data in the
constructor. The input object is used to move the
PlayerCharacter
. The
persistent game data can be used to keep track of such things as the score or any
other data that should be recorded over a number of levels. The texture manager
is used to create the player, enemies, and background sprites.
The
PlayerCharacter
class will contain a sprite that represents the player
spaceship. The CD contains a sprite called spaceship.tga in the Assets directory.
This needs to be added to the project and its properties changed so that it
is copied into the build directory. Load this
texture in the form.cs
InitializeTextures
method.
private void InitializeTextures()
{
// Init DevIl
Il.ilInit();
Ilu.iluInit();
Ilut.ilutInit();
Ilut.ilutRenderer(Ilut.ILUT_OPENGL);
_textureManager.LoadTexture("player_ship", "spaceship.tga");
Now that the player sprite is loaded into the
TextureManager,
the
PlayerCharacter
class can be written.
public class PlayerCharacter
{
Search WWH ::
Custom Search