Développement XNA pour la XBox et le PC
94
playerTwo.Position = new Vector2(770, graphics.PreferredBackBufferHeight /
➥2 - playerTwo.Texture.Height / 2);
ball.LoadContent(Content, "ball");
ball.Position = new Vector2((graphics.PreferredBackBufferWidth / 2) -
➥(ball.Texture.Width / 2), (graphics.PreferredBackBufferHeight / 2) -
➥(ball.Texture.Height / 2));
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
base.Update(gameTime);
if (started)
{
playerOne.Update(gameTime);
playerTwo.Update(gameTime);
ball.Update(gameTime, playerOne, playerTwo, ref started);
}
else
{
if (ServiceHelper.Get().IsKeyDown(Keys.Space))
{
started = true;
Window.Title = "Pong !";
}
}
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
spriteBatch.Begin();
playerOne.Draw(spriteBatch);
playerTwo.Draw(spriteBatch);
ball.Draw(spriteBatch);
spriteBatch.End();
}
}
Votre jeu est maintenant prêt. Vous pouvez le compiler et l’essayer pendant des heures…
Ou peut-être un peu moins !
=Labat FM.book Page 94 Vendredi, 19. juin 2009 4:01 16
Précédent

- 115/366

Suivant