public void draw(SpriteBatch s, Personnage heros, Camera camera) { for (int y = 0; y < tailMap.GetLength(1); y++) { for (int x = 0; x < tailMap.GetLength(0); x++) { affichage.X = 32 * x; affichage.Y = 32 * y; if (heros.position.X > camera.CameraWidth / 2) affichage.X = camera.CameraWidth / 2 - heros.position.X + 32 * x; if (heros.position.Y > camera.CameraHeight / 2) affichage.Y = camera.CameraHeight / 2 - heros.position.Y + 32 * y; switch (tailMap[x, y]) { case 0: s.Draw(tile_0, new Rectangle(affichage.X, affichage.Y, 32, 32), Color.White); break; case 1: s.Draw(tile_1, new Rectangle(affichage.X, affichage.Y, 32, 32), Color.White); break; case 2: s.Draw(water, new Rectangle(affichage.X, affichage.Y, 32, 32), Color.White); break; } } } }
protected override void Initialize() { coffre = new Recompense(Content.Load<Texture2D>("coffre_ferme"), Content.Load<Texture2D>("coffre_ouvert"), new Rectangle(rnd.Next(0, 750), rnd.Next(0, 450), 25, 25)); liste_coffre = new List<Recompense>(); attaque_cac = new Animations(Content.Load<Texture2D>("animation_attaque"), new Rectangle(0, 0, 0, 0)); map = new Map(Content.Load<Texture2D>("tile0"), Content.Load<Texture2D>("tile1"), Content.Load<Texture2D>("tile_water"), "map.txt"); munitionsLoaded = new List<Munitions>(); munitionsShooted = new List<Munitions>(); munitionspossédées = new Stack<Munitions>(); map.init(); pileronflex = new List<Personnage>(); for (int i = 0; i < 25; i++) { munitionsLoaded.Add(new Munitions(new Vector2(100, 100), Content.Load<Texture2D>("tir_vertical"),laser)); munitionspossédées.Push(new Munitions(new Vector2(100, 100), Content.Load<Texture2D>("tir_vertical"), laser)); } for (int i = 0; i <= 3; i++) { pileronflex.Add(new Personnage(Content.Load<Texture2D>("ronflex"), new Rectangle(rnd.Next(100, 800), rnd.Next(150, 500), 32, 32), 10, 1, 0, 0, null, null, map)); pileronflex[i].numero = 2; } for (int i = 4; i < 7; i++) { pileronflex.Add(new Personnage(Content.Load<Texture2D>("cyborgcostar"), new Rectangle(rnd.Next(100, 800), rnd.Next(150, 500), 32, 32), 10, 2, 0, 0, null, null, map)); pileronflex[i].numero = 4; } Keyboard = new KeyboardEvent(); this.IsMouseVisible = true; #region variables menu mousevent = new MouseEvent(); jouer_menu = new MenuButton(new Vector2(50, 425), Content.Load<Texture2D>("jouer"), Content.Load<Texture2D>("joueractiv"), Content.Load<Texture2D>("play"), Content.Load<Texture2D>("playactiv")); options_menu = new MenuButton(new Vector2(250, 425), Content.Load<Texture2D>("option"), Content.Load<Texture2D>("optionactiv"), Content.Load<Texture2D>("option"), Content.Load<Texture2D>("optionactiv")); credit_menu = new MenuButton(new Vector2(450, 425), Content.Load<Texture2D>("credits"), Content.Load<Texture2D>("creditactiv"), Content.Load<Texture2D>("credits"), Content.Load<Texture2D>("creditactiv")); quit_menu = new MenuButton(new Vector2(650, 425), Content.Load<Texture2D>("quit"), Content.Load<Texture2D>("quitactiv"), Content.Load<Texture2D>("exit"), Content.Load<Texture2D>("exitactiv")); langue_menu = new MenuButton(new Vector2(275, 425), Content.Load<Texture2D>("langue"), Content.Load<Texture2D>("langueactiv"), Content.Load<Texture2D>("language"), Content.Load<Texture2D>("languageactiv")); angl_menu = new MenuButton(new Vector2(400, 425), Content.Load<Texture2D>("fra"), Content.Load<Texture2D>("fraactiv"), Content.Load<Texture2D>("english"), Content.Load<Texture2D>("englishactiv")); PE_menu = new MenuButton(new Vector2(20, 425), Content.Load<Texture2D>("PE"), Content.Load<Texture2D>("PEactiv"), Content.Load<Texture2D>("FS"), Content.Load<Texture2D>("FSactiv")); Onoff_menu = new MenuButton(new Vector2(150, 425), Content.Load<Texture2D>("offactiv"), Content.Load<Texture2D>("onactiv"), Content.Load<Texture2D>("offactiv"), Content.Load<Texture2D>("onactiv")); Retour = new MenuButton(new Vector2(700, 425), Content.Load<Texture2D>("bouton_retour"), Content.Load<Texture2D>("bouton_retour"), Content.Load<Texture2D>("back"), Content.Load<Texture2D>("backactiv")); mag1 = new MenuButton(new Vector2(400, 130), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto")); mag2 = new MenuButton(new Vector2(400, 230), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto")); mag3 =new MenuButton(new Vector2(400, 330 ), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto")); mag4 = new MenuButton(new Vector2(400, 430), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto"), Content.Load<Texture2D>("tuto")); #endregion // Initialisation des variables monstres et personnages : laser = Color.Red; inventaire = new List<Equipements>(); equip = new List<Equipements>(); item1 = new Equipements("Main", Content.Load<Texture2D>("item1"), 50, 50, 50); item2 = new Equipements("Tete", Content.Load<Texture2D>("item1"), 50, 50, 50); inventaire.Add(item1); inventaire.Add(item2); inventaire[0].stack(inventaire); heros = new Personnage(Content.Load<Texture2D>("walk_iso"), new Rectangle(00, 00, 75, 101), 300, 5, 5, 5, inventaire, equip, map); Font_PDV = Content.Load<SpriteFont>("Font_PDV"); heros = new Personnage(Content.Load<Texture2D>("heros"), new Rectangle(200, 200, 24, 32), 350,5,5,5, inventaire, equip ,map); camera = new Camera(new Vector2(heros.position.X, heros.position.Y), Content.Load<Texture2D>("map")); heros.Inventaire(); #region musique musique_jeu_principal_lancer = false; musique_menu_lancer = false; old_keys_deplacement = Keys.U; etre_toucher_ou_pas = false; cri_montre_devient_rouge_fait = false; #endregion musique base.Initialize(); }