Ejemplo n.º 1
0
 public Ghost(Texture2D tex, Rectangle src_rec, Rectangle pac_hitrec, Vector2 pos, Tiles tiles, pacman pac)
     : base(tex, src_rec, pac_hitrec, pos)
 {
     targetpos  = this.pos;
     this.tiles = tiles;
     int dire = Rand(0, 5);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            List <string> map = new List <string>();



            start_background = Content.Load <Texture2D>("pacman_arcade.png");
            font             = Content.Load <SpriteFont>("lives");
            //AStar = new AStarProgram();
            food_p = new Food_placement(food_tex, position, food_rec, food_hitrec, false);
            tiles  = new Tiles(tile_tex, tile_rec, tile_hitrec, position);

            StreamReader sr = new StreamReader(@"MyMap.txt");

            while (!sr.EndOfStream)
            {
                map.Add(sr.ReadLine());
            }

            sr.Close();

            for (int i = 0; i < map.Count; i++)
            {
                for (int j = 0; j < map[i].Length; j++)
                {
                    if (map[i][j] == 'p')
                    {
                        pac = new pacman(pac_tex, pac_rec, new Rectangle(16 * j, 16 * i, 16, 16), new Vector2(16 * j, 16 * i), tiles, food_p, dead);
                    }
                }
            }



            //for (int i = 0; i < map.Count; i++)
            //{
            //    for (int j = 0; j < map[i].Length; j++)
            //    {
            //        if (map[i][j] == 'w')
            //        {

            //            AStar.AddWalls(i,j);
            //        }
            //    }
            //}


            for (int i = 0; i < map.Count; i++)
            {
                for (int j = 0; j < map[i].Length; j++)
                {
                    if (map[i][j] == 'g')
                    {
                        ghost = new Ghost(ghost_tex, ghost_rec, new Rectangle(16 * j, 16 * i, 16, 16), new Vector2(16 * j, 16 * i), tiles, pac);
                    }
                }
            }



            height = graphics.PreferredBackBufferHeight = 150;
            width  = graphics.PreferredBackBufferWidth = 304;
            graphics.ApplyChanges();


            food_p.Load(Content);
            tiles.Load(Content);

            pac.Load(Content);
            ghost.Load(Content);

            base.Initialize();
        }