示例#1
0
文件: Level.cs 项目: BigDub/Platform
 public static Level LoadLevel(String filename, Tileset tiles)
 {
     System.IO.StreamReader stream = new System.IO.StreamReader(filename);
     int Wi = int.Parse(stream.ReadLine());
     int He = int.Parse(stream.ReadLine());
     Level l = new Level(tiles, Wi, He);
     l.file = filename;
     for (int y = 0; y < He; y++)
     {
         String[] arr = stream.ReadLine().Split(',');
         for (int x = 0; x < Wi; x++)
             l.data[x, y] = byte.Parse(arr[x]);
     }
     stream.Close();
     return l;
 }
示例#2
0
 //assuming that the x and y given are in the middle of the side
 //for direction expects to specify whether checking the top, bottom, right or left of the player
 private bool collideSide(int x, int y, int height, int width, string direction, Level lvl)
 {
     if (direction == "top" || direction == "bottom")
     {
         if (direction == "top")
             y = y - (height / 2);
         else
             y = y + (height / 2);
         for (int i = (x - (width / 2)); i < (x + (width / 2)); i++)
         {
             if (lvl.checkCollision(i, y) == true)
                 return true;
         }
         return false;
     }
     else
     {
         if (direction == "right")
             x = x + (width / 2);
         else
             x = x - (width / 2);
         for (int i = (y - (height / 2)); i < (y + (height / 2)); i++)
         {
             if (lvl.checkCollision(x, i) == true)
                 return true;
         }
         return false;
     }
 }
示例#3
0
文件: Game1.cs 项目: BigDub/Platform
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            e = Content.Load<Effect>("StandardEffect");
            e.Parameters["World"].SetValue(Matrix.Identity);
            e.Parameters["View"].SetValue(Matrix.CreateLookAt(cameraPosition, cameraPosition - Vector3.UnitZ, Vector3.UnitY));
            e.Parameters["Projection"].SetValue(Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, 4 / 3, 0.1f, 30));

            testModel = Content.Load<Model>("Character");

            global.e = e;
            global.content = Content;

            Tileset installation = Tileset.LoadTileset("Content\\Installation.txt");
            currentLevel = Level.LoadLevel("Content\\Level.txt", installation);
        }
示例#4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            spriteWalk.LoadSprite(Content.Load<Texture2D>("StickAnimation"),
                (int)PlayerVector.X, (int)PlayerVector.Y,
                0, 0, 6, 50, 100, 15);
            spriteWin.LoadSprite(Content.Load<Texture2D>("StickAnimation"),
                (int)PlayerVector.X, (int)PlayerVector.Y,
                0, 100, 6, 50, 100, 15);
            duckTexture = Content.Load<Texture2D>("StickDuck");
            stand = Content.Load<Texture2D>("Stick");
            jumpUp = Content.Load<Texture2D>("StickJumpUp");
            jumpDown = Content.Load<Texture2D>("StickJumpDown");
            Texture2D projectile = Content.Load<Texture2D>("projectile");
            Texture2D badGuys = Content.Load<Texture2D>("badStickAnimation");

            brick = Content.Load<Texture2D>("brick");
            blankLevel = Content.Load <Texture2D>("blankLevel");

            lvl = new Level(brick, badGuys, projectile, blankLevel, GraphicsDevice, spriteBatch);
            // TODO: use this.Content to load your game content here
        }