예제 #1
0
        /// <summary>
        /// Method that counts down time and removes block if crumbling is set to true
        /// </summary>
        /// <param name="fps">Current fps the program is running at</param>
        /// <param name="levelMap">Reference to the levelmap for current loaded level</param>
        /// <param name="playerState">Reference to the state of the player.</param>
        public override void Update(float fps, ref GameObject[,] levelMap, ref int playerState)
        {
            if (Crumbling)
            {
                sprite = animationFrames[1];
                time -= 1/fps;
                if (time <= 0)
                {
                    foreach (GameObject g in levelMap)
                    {
                        if (g != null)
                        {
                            if (g.GetType().ToString() == "Dash.Dash")
                            {
                                foreach (Rect r in collisionBoxes)
                                {
                                    RectangleF rect = r.HitBox(position.X, position.Y - 10);

                                    foreach (Rect r2 in g.CollisionBoxes)
                                    {
                                        if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y)))
                                        {
                                            Dash d = (Dash) g;
                                            d.Falling = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    collisionBoxes = new List<Rect>();
                    sprite = null;
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Virtual update method for gameobjects with no code because the default behavior for gameobjects is to do nothing.
 /// </summary>
 /// <param name="fps">Current fps the program is running at</param>
 /// <param name="levelMap">Reference to the levelmap for current loaded level</param>
 /// <param name="playerState">Reference to the state of the player.</param>
 public virtual void Update(float fps, ref GameObject[,] levelMap, ref int playerState)
 {
 }
예제 #3
0
        /// <summary>
        /// Override for update that gets user input and moves accordingly
        /// </summary>
        /// <param name="fps">Current fps the program is running at</param>
        /// <param name="levelMap">Reference to the levelmap for current loaded level</param>
        /// <param name="playerState">Reference to the state of the player.</param>
        public override void Update(float fps, ref GameObject[,] levelMap, ref int playerState)
        {
            base.Update(fps, ref levelMap, ref playerState);
            if (Keyboard.IsKeyDown(Config.RightKey)) //if rightkey is down
            {
                if (!dashUp && !dashLeft) //if not dashing left or up, dash right
                {
                    dashRight = true;
                }
            }
            else if (Keyboard.IsKeyDown(Config.LeftKey)) //if leftkey is down
            {
                if (!dashUp && !dashRight) //if not dashing right or up, dash left
                {
                    dashLeft = true;
                }
            }
            else if (Keyboard.IsKeyDown(Config.UpKey)) //if upkey is down
            {
                if (!dashLeft && !dashRight && !falling) //if not dashing right or left or falling, dash up
                {
                    dashUp = true;
                }

            }
            CheckEdge(fps);
            CheckCollisions(ref levelMap, fps, ref playerState);

            if (dashUp) //if dashup move speed multiplied by 1/fps up
            {
                position.Y -= speed * (1 / fps);
            }
            else if (dashLeft) //if dashup move speed multiplied by 1/fps left
            {
                sprite = animationFrames[4];
                direction = true;
                position.X -= speed * (1 / fps);

            }
            else if (dashRight) //if dashup move speed multiplied by 1/fps right
            {
                sprite = animationFrames[3];
                direction = false;
                position.X += speed * (1 / fps);
            }
            else if (falling && DateTime.Now > fallDelay.AddMilliseconds(20)) //if falling and datetime is larger than delay move speed multiplied by 1/fps down
            {
                position.Y += fallSpeed * (1 / fps);
                if (playerState != 2)
                {
                    if (direction)
                    {
                        sprite = animationFrames[1];
                    }
                    else
                    {
                        sprite = animationFrames[0];
                    }
                }

            }
            else
            {
                if (playerState != 2)
                {
                    if (direction)
                    {
                        sprite = animationFrames[1];
                    }
                    else
                    {
                        sprite = animationFrames[0];
                    }
                }

            }
        }
예제 #4
0
        /// <summary>
        /// Checks for collisions with triggers
        /// </summary>
        /// <param name="g">GameObject to check</param>
        /// <param name="playerState">Reference to the state of the player.</param>
        /// <param name="levelMap">Reference to the levelmap for current loaded level</param>
        private void CheckTriggerCollisions(GameObject g, ref int playerState, ref GameObject[,] levelMap)
        {
            foreach (Rect r in collisionBoxes) //loops through all the Collisionboxes for player object
            {
                RectangleF rect = r.HitBox(position.X, position.Y); //creates rectangle from current hitbox

                foreach (Rect r2 in g.CollisionBoxes) //loops thru all the collisionboxes for the g object
                {
                    if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with the hitbox trigger the button
                    {
                        TriggerBlock t = (TriggerBlock)g;
                        if (t.Type == 1) //if type is 1 then open door linked to the trigger
                        {
                            t.Pressed = true;
                            if (levelMap[t.Target.Y, t.Target.X] != null && levelMap[t.Target.Y, t.Target.X].GetType().ToString() == "Dash.GateBlock") //if the object linked to the trigger is of type gateblock open it and remove the hitboxes
                            {
                                GateBlock gate = (GateBlock)levelMap[t.Target.Y, t.Target.X];
                                gate.Open = true;
                                gate.CollisionBoxes = new List<Rect>();
                            }
                        }
                        else if (t.Type == 2) //if type is 2 then playerstate will be set to current level finished
                        {
                            playerState = 1;
                        }
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Checks for collisions with enemies
        /// </summary>
        /// <param name="g">Gameobject to check</param>
        /// <param name="playerState">Reference to the state of the player.</param>
        private void CheckEnemyCollisions(GameObject g, ref int playerState)
        {
            foreach (Rect r in collisionBoxes) //loops through all the Collisionboxes for player object
            {
                RectangleF rect = r.HitBox(position.X, position.Y); //creates rectangle from current hitbox

                foreach (Rect r2 in g.CollisionBoxes) //loops thru all the collisionboxes for the g object
                {
                    if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with the hitbox stop moving, set playerstate to dead switch to death sprite image and play gameover sound
                    {
                        Audio.PlaySoundFX("Audio\\Game Over_1.mp3");
                        playerState = 2;
                        dashRight = false;
                        falling = false;
                        dashLeft = false;
                        dashUp = false;
                        sprite = animationFrames[2];

                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Checks for collisions with crumbling blocks
        /// </summary>
        /// <param name="g">Gameobject to check</param>
        /// <param name="fps">Current fps the program is running at</param>
        private void CheckCrumblingCollisions(GameObject g, float fps)
        {
            foreach (Rect r in collisionBoxes) //loops through all the Collisionboxes for player object
            {
                RectangleF rect = r.HitBox(position.X, position.Y + speed * (1 / fps));  //creates rectangle from current hitbox moved 10 pixels down

                foreach (Rect r2 in g.CollisionBoxes) //loops thru all the collisionboxes for the g object
                {
                    if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with the hitbox stop falling and make it start crumble
                    {
                        CrumblingBlock c = (CrumblingBlock)g;
                        c.Crumbling = true;
                        falling = false;
                        position.Y = g.Position.Y + r2.Position.Y - collisionBoxes[0].HitBox(Position.X, Position.Y).Height;
                    }
                }
            }
        }
예제 #7
0
 /// <summary>
 /// Method that checks collisions with all other objects on levelmap
 /// </summary>
 /// <param name="levelMap">Reference to the levelmap for current loaded level</param>
 /// <param name="fps">Current fps the program is running at</param>
 /// <param name="playerState">Reference to the state of the player.</param>
 private void CheckCollisions(ref GameObject[,] levelMap, float fps, ref int playerState)
 {
     foreach (GameObject g in levelMap) //runs thru all the gameobjects in foreground map
     {
         if (g != null && g.GetType().ToString() == "Dash.TriggerBlock") //if its an object of the type triggerblock
         {
             CheckTriggerCollisions(g, ref playerState, ref levelMap);
         }
         else if (g != null && g.GetType().ToString() == "Dash.Enemy") //if its an object of type enemy
         {
             CheckEnemyCollisions(g, ref playerState);
         }
         else if (g != null && g.GetType().ToString() == "Dash.CrumblingBlock" && falling) //if its an object of type CrumblingBlock
         {
             CheckCrumblingCollisions(g, fps);
         }
         else if (g != null && g.GetType().ToString() != "Dash.Dash" && g.GetType().ToString() != "Dash.Enemy") //else if its any other type of object other than the player object
         {
             CheckBlockCollisions(g, fps);
         }
     }
 }
예제 #8
0
        /// <summary>
        /// Checks for collisions with solid objects
        /// </summary>
        /// <param name="g">GameObject to check</param>
        /// <param name="fps">Current fps the program is running at</param>
        private void CheckBlockCollisions(GameObject g, float fps)
        {
            foreach (Rect r in collisionBoxes) //loops through all the Collisionboxes for player object
            {
                RectangleF rect = r.HitBox(position.X, position.Y); //creates rectangle from current hitbox
                if (dashRight)  //dashing right
                {
                    rect.Offset(new PointF(speed * (1 / fps), 0)); //offsets rectangle

                    foreach (Rect r2 in g.CollisionBoxes)  //loops thru all the collisionboxes for the g object
                    {
                        if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with hitbox stop dashing right start falling and move to the object
                        {
                            dashRight = false;
                            falling = true;
                            position.X = g.Position.X + r2.Position.X - collisionBoxes[0].HitBox(position.X, position.Y).Width;
                        }
                    }

                    RectangleF rect2 = r.HitBox(position.X, position.Y);
                    rect2.Offset(new PointF(1, 0));

                    foreach (Rect r2 in g.CollisionBoxes)  //loops thru all the collisionboxes for the g object
                    {
                        if (rect2.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with hitbox stop dashing right start falling and move to the object
                        {
                            dashRight = false;
                            falling = true;
                        }
                    }
                }
                else if (dashLeft) //dashing left
                {
                    rect.Offset(-speed * (1 / fps), 0); //offsets rectangle

                    foreach (Rect r2 in g.CollisionBoxes) //loops thru all the collisionboxes for the g object
                    {
                        if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with hitbox stop dashing left start falling and move to the object
                        {
                            dashLeft = false;
                            falling = true;
                            position.X = g.Position.X - r2.Position.X + r2.HitBox(g.Position.X, g.Position.Y).Width;
                        }
                    }

                    RectangleF rect2 = r.HitBox(position.X, position.Y);
                    rect2.Offset(new PointF(-1, 0));

                    foreach (Rect r2 in g.CollisionBoxes)  //loops thru all the collisionboxes for the g object
                    {
                        if (rect2.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with hitbox stop dashing right start falling and move to the object
                        {
                            dashLeft = false;
                            falling = true;
                        }
                    }

                }
                else if (dashUp) //dashing up
                {
                    rect.Offset(0, -speed * (1 / fps)); //offsets rectagle

                    foreach (Rect r2 in g.CollisionBoxes) //loops thru all the collisionboxes for the g object
                    {
                        if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with hitbox stop dashing up start falling after a delay and move to the object
                        {
                            dashUp = false;
                            falling = true;
                            position.Y = g.Position.Y + r2.Position.Y + r2.HitBox(g.Position.X, g.Position.Y).Height;
                            fallDelay = DateTime.Now;
                        }
                    }

                    RectangleF rect2 = r.HitBox(position.X, position.Y);
                    rect2.Offset(new PointF(0, -1));

                    foreach (Rect r2 in g.CollisionBoxes)  //loops thru all the collisionboxes for the g object
                    {
                        if (rect2.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with hitbox stop dashing right start falling and move to the object
                        {
                            dashUp = false;
                            falling = true;
                        }
                    }

                }
                else if (falling) //falling
                {
                    RectangleF rect2 = r.HitBox(position.X, position.Y);
                    rect2.Offset(new PointF(0, 1));

                    foreach (Rect r2 in g.CollisionBoxes)  //loops thru all the collisionboxes for the g object
                    {
                        if (rect2.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with hitbox stop dashing right start falling and move to the object
                        {
                            falling = false;
                            fallSpeed = speed;
                        }
                    }

                    if (falling)
                    {
                        rect.Offset(0, fallSpeed * (1 / fps)); //offsets rectangle

                        foreach (Rect r2 in g.CollisionBoxes) //loops thru all the collisionboxes for the g object
                        {
                            if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y))) //if player collides with hitbox stop falling and move to object
                            {
                                falling = false;
                                fallSpeed = speed;
                                position.Y = g.Position.Y + r2.Position.Y - collisionBoxes[0].HitBox(Position.X, Position.Y).Height;
                            }
                        }
                    }
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Builds the map arrays
        /// </summary>
        /// <param name="map">Map field to output to</param>
        /// <returns>Array based of the input string</returns>
        private GameObject[,] CreateMap(string map)
        {
            string[] temp = map.Split('_');

            GameObject[,] lvlMap = new GameObject[temp.Length, temp[0].Split(';').Length];

            int y = 0;
            foreach (string s1 in temp)
            {
                int x = 0;
                foreach (string s2 in s1.Split(';'))
                {
                    List<Rect> collisionBoxes;
                    switch (s2)
                    {
                        case "OO":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "", collisionBoxes);
                            break;

                        #region Buttons
                        case "BB":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new Point(14, 7), new PointF(x * 48, y * 48), "Graphics\\BB.gif;Graphics\\B3.gif", collisionBoxes);
                            break;
                        case "BB1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new Point(7, 6), new PointF(x * 48, y * 48), "Graphics\\BB.gif;Graphics\\B3.gif", collisionBoxes);
                            break;
                        case "BL":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new PointF(x * 48, y * 48), "Graphics\\BL.gif;Graphics\\B2.gif", collisionBoxes);
                            break;
                        case "BL1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0,0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1,new Point(10,2),  new PointF(x * 48, y * 48), "Graphics\\BL.gif;Graphics\\B2.gif", collisionBoxes);
                            break;
                        case "BL2":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new Point(0, 7), new PointF(x * 48, y * 48), "Graphics\\BL.gif;Graphics\\B2.gif", collisionBoxes);
                            break;
                        case "BR":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new PointF(x * 48, y * 48), "Graphics\\BR.gif;Graphics\\B1.gif", collisionBoxes);
                            break;
                        case "BR1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1,new Point(13,0),  new PointF(x * 48, y * 48), "Graphics\\BR.gif;Graphics\\B1.gif", collisionBoxes);
                            break;
                        case "BR2":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1,new Point(13,10),  new PointF(x * 48, y * 48), "Graphics\\BR.gif;Graphics\\B1.gif", collisionBoxes);
                            break;
                        case "BT":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new PointF(x * 48, y * 48), "Graphics\\BT.gif;Graphics\\B4.gif", collisionBoxes);
                            break;
                        case "BT1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0,0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1,new Point(10,1),  new PointF(x * 48, y * 48), "Graphics\\BT.gif;Graphics\\B4.gif", collisionBoxes);
                            break;
                        case "BT2":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new Point(17, 4), new PointF(x * 48, y * 48), "Graphics\\BT.gif;Graphics\\B4.gif", collisionBoxes);
                            break;
                        case "BT3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new Point(8, 1), new PointF(x * 48, y * 48), "Graphics\\BT.gif;Graphics\\B4.gif", collisionBoxes);
                            break;
                        case "BT4":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new TriggerBlock(1, new Point(0, 8), new PointF(x * 48, y * 48), "Graphics\\BT.gif;Graphics\\B4.gif", collisionBoxes);
                            break;
                        case "BHT":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 24));
                            lvlMap[y, x] = new TriggerBlock(2, new PointF(x * 48, y * 48), "", collisionBoxes);
                            break;
                        case "BHB":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new TriggerBlock(2, new PointF(x * 48, y * 48), "", collisionBoxes);
                            break;
                        case "BVL":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 48));
                            lvlMap[y, x] = new TriggerBlock(2, new PointF(x * 48, y * 48), "", collisionBoxes);
                            break;
                        case "BVR":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 48));
                            lvlMap[y, x] = new TriggerBlock(2, new PointF(x * 48, y * 48), "", collisionBoxes);
                            break;

                        #endregion

                        #region Corners (half-tile)

                        case "C1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\C1.gif", collisionBoxes);
                            break;
                        case "C3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\C3.gif", collisionBoxes);
                            break;
                        case "C7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 24), 24, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\C7.gif", collisionBoxes);
                            break;
                        case "C9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 24, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\C9.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Doors

                        case "DH":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 144, 48));
                            lvlMap[y, x] = new GateBlock(new PointF(x * 48, y * 48), "Graphics\\DH.gif;Graphics\\D2.gif", collisionBoxes);
                            break;
                        case "DV":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 144));
                            lvlMap[y, x] = new GateBlock(new PointF(x * 48, y * 48), "Graphics\\DV.gif;Graphics\\D1.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Edges

                        case "E1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\E1.gif", collisionBoxes);
                            break;
                        case "E2":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\E2.gif", collisionBoxes);
                            break;
                        case "E3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\E3.gif", collisionBoxes);
                            break;
                        case "E4":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\E4.gif", collisionBoxes);
                            break;
                        case "E6":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\E6.gif", collisionBoxes);
                            break;
                        case "E7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\E7.gif", collisionBoxes);
                            break;
                        case "E8":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\E8.gif", collisionBoxes);
                            break;
                        case "E9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\E9.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Floor/Ceiling spikes (hor. surf.)

                        case "F1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 24));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\F1.gif", collisionBoxes);
                            break;
                        case "F2":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 24));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\F2.gif", collisionBoxes);
                            break;
                        case "F3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 24));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\F3.gif", collisionBoxes);
                            break;
                        case "F7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\F7.gif", collisionBoxes);
                            break;
                        case "F8":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\F8.gif", collisionBoxes);
                            break;
                        case "F9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\F9.gif", collisionBoxes);
                            break;
                        case "KU":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\KU.gif", collisionBoxes);
                            break;
                        case "KD":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 48, 24));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\KD.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Background tiles

                        case "G1":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\G1.gif", collisionBoxes);
                            break;
                        case "G2":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\G2.gif", collisionBoxes);
                            break;
                        case "G3":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\G3.gif", collisionBoxes);
                            break;
                        case "G4":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\G4.gif", collisionBoxes);
                            break;
                        case "G5":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\G5.gif", collisionBoxes);
                            break;
                        case "L1":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\L1.gif", collisionBoxes);
                            break;
                        case "L2":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\L2.gif", collisionBoxes);
                            break;
                        case "L3":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\L3.gif", collisionBoxes);
                            break;
                        case "L4":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\L4.gif", collisionBoxes);
                            break;
                        case "L5":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\L5.gif", collisionBoxes);
                            break;
                        case "Q1":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\Q1.gif", collisionBoxes);
                            break;
                        case "Q2":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\Q2.gif", collisionBoxes);
                            break;
                        case "Q3":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\Q3.gif", collisionBoxes);
                            break;
                        case "Q4":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\Q4.gif", collisionBoxes);
                            break;
                        case "Q5":
                            collisionBoxes = new List<Rect>();
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\Q5.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Hole blocks

                        case "H1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\H1.gif", collisionBoxes);
                            break;
                        case "H3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\H3.gif", collisionBoxes);
                            break;
                        case "H7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\H7.gif", collisionBoxes);
                            break;
                        case "H9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\H9.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Indented blocks

                        case "I1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\I1.gif", collisionBoxes);
                            break;
                        case "I3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\I3.gif", collisionBoxes);
                            break;
                        case "I7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\I7.gif", collisionBoxes);
                            break;
                        case "I9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\I9.gif", collisionBoxes);
                            break;
                        case "IH":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\IH.gif", collisionBoxes);
                            break;
                        case "IV":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\IV.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Mounted spikes (vert. surf.)

                        case "M1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 48));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\M1.gif", collisionBoxes);
                            break;
                        case "M3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 48));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\M3.gif", collisionBoxes);
                            break;
                        case "M4":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 48));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\M4.gif", collisionBoxes);
                            break;
                        case "M6":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 48));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\M6.gif", collisionBoxes);
                            break;
                        case "M7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 48));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\M7.gif", collisionBoxes);
                            break;
                        case "M9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 48));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\M9.gif", collisionBoxes);
                            break;
                        case "KL":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 48));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\KL.gif", collisionBoxes);
                            break;
                        case "KR":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 48));
                            lvlMap[y, x] = new Enemy(new PointF(x * 48, y * 48), "Graphics\\KR.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Nub-corners

                        case "N1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\N1.gif", collisionBoxes);
                            break;
                        case "N3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\N3.gif", collisionBoxes);
                            break;
                        case "N7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\N7.gif", collisionBoxes);
                            break;
                        case "N9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\N9.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Platforms

                        case "VB5":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 144));
                            lvlMap[y, x] = new MovableBlock(100, 2, 3, new PointF(x * 48, y * 48), "Graphics\\VB.gif", collisionBoxes);
                            break;
                        case "VB7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 144));
                            lvlMap[y, x] = new MovableBlock(100, 2, 5, new PointF(x * 48, y * 48), "Graphics\\VB.gif", collisionBoxes);
                            break;
                        case "VB9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 144));
                            lvlMap[y, x] = new MovableBlock(100, 2, 6, new PointF(x * 48, y * 48), "Graphics\\VB.gif", collisionBoxes);
                            break;
                        case "VB11":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 144));
                            lvlMap[y, x] = new MovableBlock(100, 2, 8, new PointF(x * 48, y * 48), "Graphics\\VB.gif", collisionBoxes);
                            break;
                        case "HB5":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 144, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 5, new PointF(x * 48, y * 48), "Graphics\\HB.gif", collisionBoxes);
                            break;
                        case "HB9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 144, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 6, new PointF(x * 48, y * 48), "Graphics\\HB.gif", collisionBoxes);
                            break;
                        case "HB11":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 144, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 8, new PointF(x * 48, y * 48), "Graphics\\HB.gif", collisionBoxes);
                            break;
                        case "HB12":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 144, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 10, new PointF(x * 48, y * 48), "Graphics\\HB.gif", collisionBoxes);
                            break;
                        case "HB16":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 144, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 13, new PointF(x * 48, y * 48), "Graphics\\HB.gif", collisionBoxes);
                            break;
                        case "VM5":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 96));
                            lvlMap[y, x] = new MovableBlock(80, 2, 3, new PointF(x * 48, y * 48), "Graphics\\VM.gif", collisionBoxes);
                            break;
                        case "VM6":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 96));
                            lvlMap[y, x] = new MovableBlock(100, 2, 5, new PointF(x * 48, y * 48), "Graphics\\VM.gif", collisionBoxes);
                            break;
                        case "VM7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 96));
                            lvlMap[y, x] = new MovableBlock(100, 2, 6, new PointF(x * 48, y * 48), "Graphics\\VM.gif", collisionBoxes);
                            break;
                        case "HM3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 96, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 2, new PointF(x * 48, y * 48), "Graphics\\HM.gif", collisionBoxes);
                            break;
                        case "HM4":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 96, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 3, new PointF(x * 48, y * 48), "Graphics\\HM.gif", collisionBoxes);
                            break;
                        case "HM5":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 96, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 4, new PointF(x * 48, y * 48), "Graphics\\HM.gif", collisionBoxes);
                            break;
                        case "HM7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 96, 48));
                            lvlMap[y, x] = new MovableBlock(100, 4, 5, new PointF(x * 48, y * 48), "Graphics\\HM.gif", collisionBoxes);
                            break;
                        case "PS4":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new MovableBlock(100, 2, 3, new PointF(x * 48, y * 48), "Graphics\\PS.gif", collisionBoxes);
                            break;
                        case "CP":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 144, 48));
                            lvlMap[y, x] = new CrumblingBlock(new PointF(x * 48, y * 48), "Graphics\\CP.gif;Graphics\\CC.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Player

                        case "PL":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 96, 96));
                            lvlMap[y, x] = new Dash(400, new PointF(x * 48, y * 48), "Graphics\\PL.gif;Graphics\\PL.gif;Graphics\\PD.gif;Graphics\\PB.gif;Graphics\\PB.gif", collisionBoxes);
                            break;
                        #endregion

                        #region Rivet-blocks

                        case "R1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R1.gif", collisionBoxes);
                            break;
                        case "R2":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R2.gif", collisionBoxes);
                            break;
                        case "R3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R3.gif", collisionBoxes);
                            break;
                        case "R4":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R4.gif", collisionBoxes);
                            break;
                        case "R5":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R5.gif", collisionBoxes);
                            break;
                        case "R6":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R6.gif", collisionBoxes);
                            break;
                        case "R7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R7.gif", collisionBoxes);
                            break;
                        case "R8":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R8.gif", collisionBoxes);
                            break;
                        case "R9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\R9.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Solid half-tiles and dec. full-tiles

                        case "S1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 48));
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\S1.gif", collisionBoxes);
                            break;
                        case "S3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 48));
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\S3.gif", collisionBoxes);
                            break;
                        case "S7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 24));
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\S7.gif", collisionBoxes);
                            break;
                        case "S9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 24));
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\S9.gif", collisionBoxes);
                            break;
                        case "SB":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\SB.gif", collisionBoxes);
                            break;
                        case "SG":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\SG.gif", collisionBoxes);
                            break;
                        case "SH":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\SH.gif", collisionBoxes);
                            break;
                        case "SL":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 24, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\SL.gif", collisionBoxes);
                            break;
                        case "SP":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\SP.gif", collisionBoxes);
                            break;
                        case "SR":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(24, 0), 24, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\SR.gif", collisionBoxes);
                            break;
                        case "ST":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\ST.gif", collisionBoxes);
                            break;
                        case "SV":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\SV.gif", collisionBoxes);
                            break;

                        #endregion

                        #region U-shaped blocks

                        case "U2":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\U2.gif", collisionBoxes);
                            break;
                        case "U4":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\U4.gif", collisionBoxes);
                            break;
                        case "U6":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\U6.gif", collisionBoxes);
                            break;
                        case "U8":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\U8.gif", collisionBoxes);
                            break;

                        #endregion

                        #region Walkways

                        case "W7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\W7.gif", collisionBoxes);
                            break;
                        case "W8":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\W8.gif", collisionBoxes);
                            break;
                        case "W9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\W9.gif", collisionBoxes);
                            break;
                        case "WB":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 24), 48, 24));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\WB.gif", collisionBoxes);
                            break;

                        #endregion

                        #region X-marked blocks

                        case "X1":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\X1.gif", collisionBoxes);
                            break;
                        case "X3":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\X3.gif", collisionBoxes);
                            break;
                        case "X7":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\X7.gif", collisionBoxes);
                            break;
                        case "X9":
                            collisionBoxes = new List<Rect>();
                            collisionBoxes.Add(new Rect(new PointF(0, 0), 48, 48));
                            lvlMap[y, x] = new GridBlock(new PointF(x * 48, y * 48), "Graphics\\X9.gif", collisionBoxes);
                            break;

                        #endregion

                        default:
                            lvlMap[y, x] = null;
                            break;
                    }
                    x++;
                }
                y++;
            }

            return lvlMap;
        }
예제 #10
0
        /// <summary>
        /// Method that moves the block
        /// </summary>
        /// <param name="fps">Current fps the program is running at</param>
        /// <param name="levelMap">Reference to the levelmap for current loaded level</param>
        /// <param name="playerState">Reference to the state of the player.</param>
        public override void Update(float fps, ref GameObject[,] levelMap, ref int playerState)
        {
            base.Update(fps, ref levelMap, ref playerState);

            switch (direction)
            {
                case 1:
                    if (startDirection == 2)
                    {
                        if (this.position.Y <= startPosition.Y)
                        {
                            direction = 2;
                            this.position.Y += speed * 1 / fps;
                        }
                        else
                        {
                            this.position.Y -= speed * 1 / fps;
                        }
                    }
                    else
                    {
                        if (this.position.Y <= endPosition.Y)
                        {
                            direction = 2;
                            this.position.Y += speed * 1 / fps;
                        }
                        else
                        {
                            this.position.Y -= speed * 1 / fps;
                        }
                    }
                    break;
                case 2:
                    if (startDirection == 1)
                    {
                        if (this.position.Y <= startPosition.Y)
                        {
                            direction = 1;
                            this.position.Y -= speed * 1 / fps;
                        }
                        else
                        {
                            this.position.Y += speed * 1 / fps;
                        }
                    }
                    else
                    {
                        if (this.position.Y >= endPosition.Y)
                        {
                            direction = 1;
                            this.position.Y -= speed * 1 / fps;
                        }
                        else
                        {
                            this.position.Y += speed * 1 / fps;
                        }
                    }

                    break;
                case 3:
                    if (startDirection == 4)
                    {
                        if (this.position.X <= startPosition.X)
                        {
                            direction = 4;
                            this.position.X += speed * 1 / fps;
                        }
                        else
                        {
                            this.position.X -= speed * 1 / fps;
                        }
                    }
                    else
                    {
                        if (this.position.X <= endPosition.X)
                        {
                            direction = 4;
                            this.position.X += speed * 1 / fps;
                        }
                        else
                        {
                            this.position.X -= speed * 1 / fps;
                        }
                    }
                    break;
                case 4:
                    if (startDirection == 3)
                    {
                        if (this.position.X >= startPosition.X)
                        {
                            direction = 3;
                            this.position.X -= speed * 1 / fps;
                        }
                        else
                        {
                            this.position.X += speed * 1 / fps;
                        }
                    }
                    else
                    {
                        if (this.position.X >= endPosition.X)
                        {
                            direction = 3;
                            this.position.X -= speed * 1 / fps;
                        }
                        else
                        {
                            this.position.X += speed * 1 / fps;
                        }
                    }
                    break;
            }
            CheckCollisions(ref levelMap, fps);
        }
예제 #11
0
        /// <summary>
        /// If hitbox of block collides with player it moves the player accordingly
        /// </summary>
        /// <param name="levelMap"></param>
        /// <param name="g"></param>
        /// <param name="fps"></param>
        private void MovePlayer(ref GameObject[,] levelMap,GameObject g, float fps)
        {
            foreach (Rect r in collisionBoxes)
            {
                RectangleF rect = r.HitBox(position.X, position.Y - 2);

                foreach (Rect r2 in g.CollisionBoxes)
                {
                    if (rect.IntersectsWith(r2.HitBox(g.Position.X, g.Position.Y)))
                    {
                        Dash d = (Dash)g;
                        if (!d.DashLeft && !d.DashRight && !d.DashUp)
                        {
                            if (direction == 1)
                            {
                                g.Position = new PointF(g.Position.X, g.Position.Y - speed * 1 / fps);
                            }
                            else if (direction == 2)
                            {
                                g.Position = new PointF(g.Position.X, g.Position.Y + speed * 1 / fps);
                            }
                            else if (direction == 3)
                            {
                                g.Position = new PointF(g.Position.X - speed * 1 / fps, g.Position.Y);
                            }
                            else if (direction == 4)
                            {
                                g.Position = new PointF(g.Position.X + speed * 1 / fps, g.Position.Y);
                            }
                        }
                    }
                }
            }

            Dash player = (Dash)g;

            foreach (GameObject g2 in levelMap) //runs thru all the gameobjects in foreground map
            {
                if (g2 != null && g2.GetType().ToString() != "Dash.Dash" && g2.GetType().ToString() != "Dash.TriggerBlock" && g2.GetType().ToString() != "Dash.Enemy")
                {
                    if (!player.DashLeft && !player.DashRight && !player.DashUp)
                    {
                        foreach (Rect r in player.CollisionBoxes)
                        {
                            RectangleF rect = r.HitBox(player.Position.X, player.Position.Y);

                            foreach (Rect r2 in g2.CollisionBoxes)
                            {
                                if (rect.IntersectsWith(r2.HitBox(g2.Position.X, g2.Position.Y)))
                                {
                                    if (direction == 1)
                                    {

                                    }
                                    else if (direction == 2)
                                    {

                                    }
                                    else if (direction == 3)
                                    {
                                        player.Position = new PointF(g2.Position.X - r2.Position.X + r2.HitBox(g2.Position.X, g2.Position.Y).Width, player.Position.Y);
                                    }
                                    else if (direction == 4)
                                    {
                                        player.Position = new PointF(g2.Position.X + r2.Position.X - player.CollisionBoxes[0].HitBox(player.Position.X, player.Position.Y).Width, player.Position.Y);
                                    }

                                }
                            }
                        }
                    }
                }
            }
        }
예제 #12
0
 /// <summary>
 /// finds player object in levelMap
 /// </summary>
 /// <param name="levelMap"></param>
 /// <param name="fps"></param>
 private void CheckCollisions(ref GameObject[,] levelMap, float fps)
 {
     foreach (GameObject g in levelMap)
     {
         if (g != null)
         {
             if (g.GetType().ToString() == "Dash.Dash")
             {
                 MovePlayer(ref levelMap, g, fps);
             }
         }
     }
 }