Exceptions et gestion des fichiers : sauvegarder et charger un niveau
CHAPITRE 8
163
public Tile()
{
}
public Tile(string assetName, Vector2 position)
{
this.assetName = assetName;
this.position = position;
}
public void LoadContent(ContentManager Content)
{
texture = Content.Load(assetName);
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, new Vector2(position.X * texture.Width, position.Y
➥* texture.Height), Color.White);
}
}
Occupons-nous maintenant de la classe qui correspond à la carte. Cette classe contiendra
simplement un tableau de tableau de Tile.public class Map.
{
Tile[][] tiles;
public Tile[][] Tiles
{
get
{
return tiles;
}
set
{
tiles = value;
}
}
public Map()
{
}
public Map(Vector2 size)
{
tiles = new Tile[(int)size.Y][];
for(int i = 0; i < tiles.Length; i ++)
tiles[i] = new Tile[(int)size.X];
}
=Labat FM.book Page 163 Vendredi, 19. juin 2009 4:01 16
Précédent

- 184/366

Suivant