Beispiel #1
0
        //constructeur
        public Personnage(String nomRessource, int largeur, int hauteur, int xSalle, int ySalle, Salle salle)
        {
            BitmapImage bitmap = new BitmapImage();

            //on initialise
            bitmap.BeginInit();
            //on donne le chemin de l'image
            bitmap.UriSource = new Uri("pack://application:,,/ressources/" + nomRessource);
            //Fin initiaisation
            bitmap.EndInit();

            image.Source = bitmap;
            //on donne la largeur/hauteur a l'image
            image.Width  = largeur;
            image.Height = hauteur;
            Canvas.SetZIndex(image, 10000);

            _salle  = salle;
            _xSalle = xSalle;
            _ySalle = ySalle;
            mettreAJourPositionGraphique();
        }
Beispiel #2
0
        //méthode -------------------------------------------

        public Jeu(Canvas canvas1, TextBlock tbInventaire, Inventaire inventaire)
        {
            //sauvegarde du canvas / inventaire

            _canvas       = canvas1;
            _tbInventaire = tbInventaire;
            _inventaire   = inventaire;

            //Création Salle
            _salle = new Salle(40, 40, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +     // X = mur
                               "XXXXXXXXXXXXXXXXXXXXXXXF.........FXXXXXX" +             // . = sol
                               "XXXXX.C..OXXXXXXXXXXXXX...........XXXXXX" +             // O = coffre ouvert
                               "XXXXX...S................TTTTTT...XXXXXX" +             // F = coffre fermé
                               "XXXXXXXXXXXXXXXXXXXXXXX..TTTTTT...XXXXXX" +             // S = flaque de sang
                               "XXXXXXXXXXXXXXXXXXXXXXX...........XXXXXX" +             // T = table basse
                               "XXXXXXXXXXXXXXXXXXXXXXX..........fXXXXXX" +             // C = crâne
                               "XXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXT.C.XXXXXXXXXXXX.XXXXXXXXXXXXXXXX" +             //
                               "XXXXXXX....XXXXXXXXXXXX.XXXXXXXXXXXXXXXX" +             //
                               "XXXXXXX.................XXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXX.S....XXXXXXXXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXX......XXXXXXXXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXX.F.S.............XXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXX..S........XXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXX.........S.XXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXX.S...T.....XXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXX...........XXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXX" +             //
                               "XXXXXXF.....C.............XXXXXXXXXXXXXX" +             //
                               "XXXXXXF....XXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXF...TXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXX" +             //
                               "XXXXXXXXXXXXXXXXXXXXXSXXXXXXXXXXXXXXXXXXX");


            // on ajoute la salle dans le canvas
            _salle.setX((Convert.ToInt32(canvas1.ActualWidth) - _salle.getL() * Tuile.LARGEUR) / 2);
            _salle.setY((Convert.ToInt32(canvas1.ActualHeight) - _salle.getH() * Tuile.HAUTEUR) / 2);

            _salle.ajouteAuCanvas(canvas1);
            _salle.miseAJourPosition();


            //Création personnage
            _heros = new Personnage("héros.png", 32, 32, 10, 10, _salle);

            //set/mise à jour position dans le canvas
            _heros.mettreAJourPositionGraphique();
            _heros.ajouteAuCanvas(canvas1);
        }