Beispiel #1
0
        /* GroundSprite txt format
         * *GroundSprite*
         * width multiplier
         * height multiplier
         * x
         * y
         * spritename
         */
        public static ArrayList readGround(string fPath, ContentManager content, int sWidth, int sHeight)
        {
            ArrayList    groundlist = new ArrayList();
            FileStream   file       = new FileStream(fPath, FileMode.Open, FileAccess.Read);
            StreamReader sr         = new StreamReader(file);
            string       line;

            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                if (line.Contains("*GroundSprite*"))
                {
                    int   tilex;
                    int   tiley;
                    float gx;
                    float gy;

                    tilex = Convert.ToInt32(sr.ReadLine());
                    tiley = Convert.ToInt32(sr.ReadLine());
                    GroundSprite gs = new GroundSprite(tilex, tiley);

                    gx = (float)Convert.ToDouble(sr.ReadLine());
                    gy = (float)Convert.ToDouble(sr.ReadLine());
                    Texture2D groundTex = content.Load <Texture2D>(sr.ReadLine());

                    gs.position.X = gx;
                    gs.position.Y = sHeight - gy;
                    gs.setBaseSprite(groundTex);
                    groundlist.Add(gs);
                }
            }

            sr.Close();
            file.Close();
            return(groundlist);
        }
Beispiel #2
0
 public void addGround(GroundSprite gsprite)
 {
     ground.Add(gsprite);
 }