public void GameOver(Gameplay game) { Statistiques.Score += score; lost = true; vitesse = new Vector2(0, 0); force = new Vector2(0, 0); balle.position = balle.positionInitiale; }
public void Update(GameTime gameTime, Gameplay game) { pongStart = Ressources.GetLangue(Langue.Choisie).pongStart; pongOver = Ressources.GetLangue(Langue.Choisie).pongOver; if (GameState.State == "newGame" && KB.New.IsKeyDown(Keys.Escape)) GameState.State = "menuPause"; if (!startgame) { if (KB.New.IsKeyDown(Keys.Enter)) startgame = true; } else { float dt = (float)gameTime.ElapsedGameTime.TotalSeconds; Vector2 acceleration = force; if (!lost) { #region Input if (KB.New.IsKeyDown(Keys.Right) && player.position.X + player.texture.Width < 1082) player.position.X += 8; if (KB.New.IsKeyDown(Keys.Left) && player.position.X > 260) player.position.X -= 8; #endregion balle.container = new Rectangle((int)balle.position.X, (int)balle.position.Y, balle.texture.Width, balle.texture.Height); #region Collisions if (balle.container.Intersects(player.container)) { score++; AudioRessources.wingold.Play(AudioRessources.volume, 0f, 0f); vitesse.Y = random.Next(-1500, -1000); vitesse.X = random.Next(-1100, 1100); } if (balle.position.Y <= 100) { balle.position.Y = 100; vitesse.Y = random.Next(1000, 1500); vitesse.X = random.Next(-1100, 1100); } if (balle.position.X >= 1040 - balle.texture.Width) { balle.position.X = 1040 - balle.texture.Width; vitesse.X *= -1; force.X *= -1; } if (balle.position.X <= 240) { balle.position.X = 240; vitesse.X *= -1; force.X *= -1; } #endregion vitesse += acceleration * dt; balle.position += vitesse * dt; player.Update(); } if (balle.position.Y > 800) GameOver(game); if (KB.New.IsKeyDown(Keys.Enter) && lost) { NewGame(); GameState.State = "inGame"; } } }
protected override void Initialize() { this.IsMouseVisible = true; KB.Old = Keyboard.GetState(); Langue.Choisie = "en"; Ressources.LoadLangue(); menu = new Menu(); menu.Initialize(-37, 0); //initialisation menu game = new Gameplay(); multigame = new MultiGameplay(); menupauseaide = new MenuPauseAide(); menuaide = new MenuAide(); menuaide.Initialize(); //initialisation menu aide menuchoose = new MenuChoose(game, Content); menuchoose.Initialize(); //initialisation menu options menuconnection = new MenuConnection(multigame); menuconnection.Initialize(); multimenuchoose = new MultiMenuChoose(multigame, Components); multimenuchoose.Initialize(); menuname = new MenuName(); menuname.Initialize(); //initialisation menu options menuoptions = new MenuOptions(menu, menuaide, menuchoose); menuoptions.Initialize(); //initialisation menu options gameover = new GameOver(); multigameover = new MultiGameOver(); multigamewin = new MultiGameWin(); pong = new Pong(); pong.Initialize(); keybonusgame = new KeyBonusGame(); keybonusgame.Initialize(); menupause = new MenuPause(pong, keybonusgame); menupause.Initialize(450, 0); //initialisation menu pause multimenupause = new MultiMenuPause(); multimenupause.Initialize(450, 0); //initialisation menu pause menumode = new MenuMode(); menumode.Initialize(); audioPlay = new AudioPlay(1f); GameState.State = "Generique"; //mise à l'état initial base.Initialize(); }
private int selection; //selection verticale #endregion Fields #region Constructors public MenuChoose(Gameplay game, ContentManager Content) { this.game = game; this.Content = Content; }
private Texture2D image; //image #endregion Fields #region Constructors public gameFini(Gameplay game) { this.game = game; }