void AjusterPositionCaméra() { Vector3 position = Position - DISTANCE_BALLE_CAMÉRA * Vector3.Normalize(Position - AnciennePositionCaméra) + HAUTEUR_CAMÉRA * Vector3.Up; CaméraJeu.Déplacer(position, Position, Vector3.Up); AnciennePositionCaméra = position; }
protected override void Update(GameTime gameTime) { Window.ClientSizeChanged += new EventHandler <EventArgs>(Window_ClientSizeChanged); GérerClavier(); TempsÉcouléDepuisMAJ += (float)gameTime.ElapsedGameTime.TotalSeconds; if (TempsÉcouléDepuisMAJ >= INTERVALLE_MAJ_STANDARD) { if (ModeDeJeu == 1 && NbJoueurConnectés != 2) { CoursePeutCommencer = false; } CaméraJeu.CréerPointDeVue(); if (CourseActive && !ImageToucheActive && LaCourse != null) { Interface.CourseActive = true; GestionOrientationCaméra();//Si course est activée } TempsÉcouléDepuisMAJ = 0; } if (MenuActif && !ImageToucheActive && GestionInput.EstEnfoncée(Keys.G)) { MenuActif = false; ImageToucheActive = true; } if (ImageToucheActive && !CourseActive && GestionInput.EstEnfoncée(Keys.H) && CoursePeutCommencer) { ImageToucheActive = false; //Interface.CourseActive = true; CourseActive = true; Carte.CourseActive = true; foreach (Voiture x in ListeVoiture) { x.CourseActive = true; } foreach (Sol x in LaCourse.LaPiste) { x.CourseActive = true; } LaCourse.CourseActive = true; } if (ModeDeJeu == 1) { LeClient.EnvoiInfoDéplacement(IDVoitureUtilisateur); NbJoueurConnectés = LeClient.NbJoueursConnectés; Interface.NbJoueursConnectés = LeClient.NbJoueursConnectés; LaCourse.NbFranchis[1] = LeClient.NbFranchisAdversaire; } Window.Title = NbJoueurConnectés.ToString() + " - " + MenuActif.ToString(); //Window.Title = LaCourse.NbFranchis[0].ToString() + " - " + LaCourse.NbFranchis[1].ToString() + " - " + (LaPiste.Count() * NbTours * 2).ToString() + " - " + LaCourse.CourseTerminée.ToString(); base.Update(gameTime); }
void AjusterCaméra() { float positionX = Position.X + 20; float positionY = 25; float positionZ = Position.Z + 20; Vector3 positionCaméra = new Vector3(positionX, positionY, positionZ); CaméraJeu.Déplacer(positionCaméra, Position, Vector3.Up); }
private void GérerClavier() { Vector3 cibleCaméra = new Vector3(0, 0, 0); Vector3 positionCaméra0 = new Vector3(0, 250, 125); Vector3 positionCaméra1 = new Vector3(0, 300, 0F); //Vector3 positionCaméra2 = new Vector3(-20, 30, 30); Vector3 positionCaméra2 = new Vector3(30, 30, -20); Vector3 cibleCaméra2 = new Vector3(-20, 10, -20); Vector3 positionCaméra3 = new Vector3(-90, 30, -140); Vector3 cibleCaméra3 = new Vector3(-90, 10, -90); Vector3 positionCaméra4 = new Vector3(-75, 20, 50); Vector3 cibleCaméra4 = new Vector3(-90, 10, 90); if (GestionInput.EstEnfoncée(Keys.Escape)) { Exit(); } if (GestionInput.EstNouvelleTouche(Keys.D1) || GestionInput.EstNouvelleTouche(Keys.NumPad1)) { CaméraJeu.Déplacer(positionCaméra0, cibleCaméra, Vector3.Up); } else { if (GestionInput.EstNouvelleTouche(Keys.D2) || GestionInput.EstNouvelleTouche(Keys.NumPad2)) { CaméraJeu.Déplacer(positionCaméra1, cibleCaméra, Vector3.Forward); } else { if (GestionInput.EstNouvelleTouche(Keys.D3) || GestionInput.EstNouvelleTouche(Keys.NumPad3)) { CaméraJeu.Déplacer(positionCaméra2, cibleCaméra2, Vector3.Up); } else { if (GestionInput.EstNouvelleTouche(Keys.D4) || GestionInput.EstNouvelleTouche(Keys.NumPad5)) { CaméraJeu.Déplacer(positionCaméra3, cibleCaméra3, Vector3.Up); } else { if (GestionInput.EstNouvelleTouche(Keys.D5) || GestionInput.EstNouvelleTouche(Keys.NumPad5)) { CaméraJeu.Déplacer(positionCaméra4, cibleCaméra4, Vector3.Up); } } } } } }
void CommencerPartie() { Chanson.Play(); CaméraJeu.ResetCaméra(PositionCaméra, CibleCaméra, OVCaméra); TempsRestantB = TempsDePartie; TempsRestantN = TempsDePartie; TempsÉcrit = ((int)(TempsDePartie / 60)).ToString() + ":" + ((int)(TempsDePartie % 60)).ToString(); ArrièrePlanDéroulant.ModifierActivation(); Components.Add(PartiEnCours = new Partie(this, TempsDePartie, NomMap, CouleursÉchiquier, OrigineÉchiquier)); Components.Add(UnAfficheurFPS = new AfficheurFps(this, "Arial", Color.Blue, INTERVALLE_CALCUL_FPS)); Components.Add(TempsB = new TexteAffichable(this, "Arial", TempsÉcrit, new Vector2((GraphicsDevice.Viewport.Width - UnAfficheurFPS.PositionDroiteBas.X), UnAfficheurFPS.PositionDroiteBas.Y), Color.White, 1f)); Components.Add(TempsN = new TexteAffichable(this, "Arial", TempsÉcrit, new Vector2((GraphicsDevice.Viewport.Width - UnAfficheurFPS.PositionDroiteBas.X), UnAfficheurFPS.PositionDroiteBas.Y), Color.Black, 1f)); Components.Add(unAfficheur3D = new Afficheur3D(this)); }
void CalculerMonde() { Monde = Matrix.Identity * Matrix.CreateScale(Scale) * Matrix.CreateFromYawPitchRoll(Rotation.Y, -MathHelper.PiOver2, Rotation.Z) * Matrix.CreateTranslation(new Vector3(Position.X, Position.Y, Position.Z)); MondeCamera = Matrix.Identity * Matrix.CreateScale(Scale) * Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z) * Matrix.CreateTranslation(new Vector3(Position.X, Position.Y + 0.3f, Position.Z)); Matrix rotationMatrix = Matrix.CreateRotationX(RotationCamera.X) * Matrix.CreateRotationY(RotationCamera.Y); Vector3 lookAtOffset = Vector3.Transform(Vector3.UnitZ, rotationMatrix); CaméraJeu.CameraUpdate(MondeCamera, lookAtOffset, Position); }
public override void Update(GameTime gameTime) { //LE COMPTEUR AUGMENTE DE 1 APRÈS CHAQUE TOUR POUR CHANGER DE JOUEUR if (Compteur % 2 == 0) { Couleur = WHITE; AutreCouleur = BLACK; } else { Couleur = BLACK; AutreCouleur = WHITE; } //ON VÉRIFIE QUE LA CAMÉRA A FINI DE TOURNER AVANT DE CONSIDÉRER LE CLICK if (CaméraJeu.aFiniTourner()) { GérerDéplacement(); } base.Update(gameTime); }
protected override void Update(GameTime gameTime) { float tempsÉcoulé = (float)gameTime.ElapsedGameTime.TotalSeconds; TempsÉcouléDepuisMAJ += tempsÉcoulé; if (TempsÉcouléDepuisMAJ > INTERVALLE_MAJ_STANDARD) { switch (CurrentGameState) { case GameState.MenuPrincipal: if (GestionInput.EstNouvelleTouche(Keys.Escape)) { this.Exit(); } if (B1.Clicked == true) { DéterminerSettings(); CommencerPartie(); VoilerBoutons(0, 2); CurrentGameState = GameState.EnJeu; } if (B2.Clicked == true) { CurrentGameState = GameState.Options; VoilerBoutons(0, 2); AfficherBoutons(2, 5); } break; case GameState.Options: if (B3.Clicked == true) { CurrentGameState = GameState.ClrsÉchiquier; VoilerBoutons(2, 5); AfficherBoutons(7, 11); } if (B4.Clicked == true) { CurrentGameState = GameState.TempsPartie; VoilerBoutons(2, 5); AfficherBoutons(11, 15); } if (B5.Clicked == true) { CurrentGameState = GameState.Musique; VoilerBoutons(2, 5); AfficherBoutons(15, 19); } if (GestionInput.EstNouvelleTouche(Keys.Escape)) { CurrentGameState = GameState.MenuPrincipal; VoilerBoutons(2, 5); AfficherBoutons(0, 2); } break; case GameState.ClrsÉchiquier: if (B8.Clicked || B9.Clicked || B10.Clicked == true || B11.Clicked == true) { CurrentGameState = GameState.Options; VoilerBoutons(7, 11); AfficherBoutons(2, 5); } break; case GameState.TempsPartie: if (B12.Clicked || B13.Clicked || B14.Clicked || B15.Clicked == true) { CurrentGameState = GameState.Options; VoilerBoutons(11, 15); AfficherBoutons(2, 5); } break; case GameState.Musique: if (B16.Clicked || B17.Clicked || B18.Clicked || B19.Clicked == true) { CurrentGameState = GameState.Options; VoilerBoutons(15, 19); AfficherBoutons(2, 5); } break; case GameState.EnPause: if (GestionInput.EstNouvelleTouche(Keys.Escape) || B6.Clicked == true) { CurrentGameState = GameState.EnJeu; VoilerBoutons(5, 7); Components.Remove(Anand); } if (B7.Clicked == true) { VoilerBoutons(5, 7); QuitterPartie(); } break; case GameState.EnJeu: if (PartiEnCours.PartieTerminée) { TempsÉcouléDepuisFinDePartie += tempsÉcoulé; if (!Components.Contains(Gagnant)) { switch (PartiEnCours.TourActuel.AutreCouleur) { case "White": Components.Add(Gagnant = new TexteAffichable(this, "Arial", VAINQUEUR_N, Color.LightGreen, 0, 3.0f, PROFONDEUR_DEFAUT - 0.5f)); break; case "Black": Components.Add(Gagnant = new TexteAffichable(this, "Arial", VAINQUEUR_B, Color.LightGreen, 0, 3.0f, PROFONDEUR_DEFAUT - 0.5f)); break; } } Afficheur3D afficheur3DTemporaire; Components.Add(afficheur3DTemporaire = new Afficheur3D(this)); if (TempsÉcouléDepuisFinDePartie > TEMPS_FIN_DE_PARTIE) { QuitterPartie(); Components.Remove(Gagnant); Components.Remove(afficheur3DTemporaire); TempsÉcouléDepuisFinDePartie = 0; } } else { if (GestionInput.EstNouvelleTouche(Keys.P)) { switch (Chanson.State) { case SoundState.Playing: Chanson.Pause(); break; case SoundState.Paused: Chanson.Resume(); break; } } if (GestionInput.EstNouvelleTouche(Keys.Escape)) { CurrentGameState = GameState.EnPause; Components.Add(Anand = new ZoneDéroulante(this, "Anand", new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), INTERVALLE_MAJ_STANDARD)); Components.Remove(B6); Components.Remove(B7); Components.Add(B6); Components.Add(B7); AfficherBoutons(5, 7); } if (PartiEnCours.TourActuel.Couleur == "White" && CaméraJeu.aFiniTourner()) { TempsRestantB = TempsRestantB - tempsÉcoulé; ChangerTemps("W"); string temps = ((int)(TempsRestantB / 60)).ToString() + ":" + ((int)(TempsRestantB % 60)).ToString(); TempsB.ModifierTexte(temps); } else { if (CaméraJeu.aFiniTourner()) { TempsRestantN = TempsRestantN - tempsÉcoulé; ChangerTemps("N"); string temps = ((int)(TempsRestantN / 60)).ToString() + ":" + ((int)(TempsRestantN % 60)).ToString(); TempsN.ModifierTexte(temps); } } } break; } TempsÉcouléDepuisMAJ = 0; } base.Update(gameTime); }
protected void BougerCaméra(float déplacementHorizontal, float déplacementProfondeur) { ((CaméraJeu) as CaméraSubjective).GérerDéplacement(déplacementProfondeur, déplacementHorizontal); CaméraJeu.CréerPointDeVue(CaméraJeu.Position, new Vector3(Position.X, Position.Y + 2f, Position.Z), CaméraJeu.OrientationVerticale); }