Le mode multijoueur
CHAPITRE 11
239
map = new Map(new byte[,] {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 1, 0, 0, 0, 1, 0},
{0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 0, 1, 0},
{0, 1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 1, 0},
{0, 1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 1, 0},
{0, 1, 3, 0, 0, 0, 3, 3, 0, 0, 0, 0, 2, 2, 0, 0, 1, 0},
{0, 1, 3, 0, 3, 3, 3, 3, 3, 0, 0, 0, 2, 2, 0, 0, 1, 0},
{0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 2, 0, 1, 0},
{0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 2, 2, 0, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
});
cameraA = new Rectangle(0, 0, 5, 5);
cameraB = new Rectangle(1, 1, 5, 5);
herosA = new Tile(cameraA.X + 2, cameraA.Y + 2, 4);
herosA.Position = new Vector2(64, 64);
herosB = new Tile(cameraB.X + 2, cameraB.Y + 2, 4);
herosB.Position = new Vector2(64, 64);
viewportA.Width = graphics.PreferredBackBufferWidth;
viewportA.Height = graphics.PreferredBackBufferHeight / 2;
viewportB.Y = graphics.PreferredBackBufferHeight / 2;
viewportB.Width = graphics.PreferredBackBufferWidth;
viewportB.Height = graphics.PreferredBackBufferHeight / 2;
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
foreach (Tile tile in map.TileList)
{
tile.LoadContent(Content, "tile");
}
herosA.LoadContent(Content, "tile");
herosB.LoadContent(Content, "tile");
}
protected override void Update(GameTime gameTime)
{
if (ServiceHelper.Get().KeyHasBeenPressed(Keys.Up))
{
if (map.TileList[herosA.Y - 1, herosA.X].Type >= 0)
{
cameraA.Y -= 1;
=Labat FM.book Page 239 Vendredi, 19. juin 2009 4:01 16
CHAPITRE 11
239
map = new Map(new byte[,] {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 1, 0, 0, 0, 1, 0},
{0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 0, 1, 0},
{0, 1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 1, 0},
{0, 1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 1, 0},
{0, 1, 3, 0, 0, 0, 3, 3, 0, 0, 0, 0, 2, 2, 0, 0, 1, 0},
{0, 1, 3, 0, 3, 3, 3, 3, 3, 0, 0, 0, 2, 2, 0, 0, 1, 0},
{0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 2, 0, 1, 0},
{0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 2, 2, 0, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
});
cameraA = new Rectangle(0, 0, 5, 5);
cameraB = new Rectangle(1, 1, 5, 5);
herosA = new Tile(cameraA.X + 2, cameraA.Y + 2, 4);
herosA.Position = new Vector2(64, 64);
herosB = new Tile(cameraB.X + 2, cameraB.Y + 2, 4);
herosB.Position = new Vector2(64, 64);
viewportA.Width = graphics.PreferredBackBufferWidth;
viewportA.Height = graphics.PreferredBackBufferHeight / 2;
viewportB.Y = graphics.PreferredBackBufferHeight / 2;
viewportB.Width = graphics.PreferredBackBufferWidth;
viewportB.Height = graphics.PreferredBackBufferHeight / 2;
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
foreach (Tile tile in map.TileList)
{
tile.LoadContent(Content, "tile");
}
herosA.LoadContent(Content, "tile");
herosB.LoadContent(Content, "tile");
}
protected override void Update(GameTime gameTime)
{
if (ServiceHelper.Get
{
if (map.TileList[herosA.Y - 1, herosA.X].Type >= 0)
{
cameraA.Y -= 1;
=Labat FM.book Page 239 Vendredi, 19. juin 2009 4:01 16
