Beispiel #1
0
        public void CheckCollisionsWithGrassBlocks(List<Grass> GrassObjects, List<Leeg> EmptyBlocks)
        {
            if (Position.X <= 0)
            {
                MoveLeft = false;
                Position.X += speed;
            }
            if (Position.X >= 1250)
            {
                MoveRight = false;
                Position.X -= speed;
            }
            Grass savegrassblok = new Grass();
            foreach (Grass g in GrassObjects)
            {
                if (this.Rightcollisionrectangle.IntersectsWith(g.Leftcollisionrectangle))
                {
                    this.MoveLeft = false;
                    this.Position.X -= 10;
                }
                if (this.Leftcollisionrectangle.IntersectsWith(g.Rightcollisionrectangle))
                {
                    this.MoveRight = false;
                    g.Position.X -= 0;
                    this.Position.X += 10;
                }
                if (this.Uppercollisionrectangle.IntersectsWith(g.Lowercollisionrectangle))
                {
                    savegrassblok = g;
                    this.up = false;
                    this.Jump = false;
                }
                if (this.Lowercollisionrectangle.IntersectsWith(g.Uppercollisionrectangle))
                {
                    this.ground = (g.Position.Y - 76);
                    savegrassblok = g;
                }
            }
            foreach (Leeg L in EmptyBlocks)
            {
                if (this.Lowercollisionrectangle.IntersectsWith(savegrassblok.Uppercollisionrectangle) == false && this.Lowercollisionrectangle.IntersectsWith(L.Rect) == true)
                {
                    this.ground = 500;

                }
            }
        }
Beispiel #2
0
        public void Createworld()
        {
            for (int x = 0; x <12; x++)
            {
                for (int y = 0; y < 72; y++)
                {
                    if (IntTylearray[x,y] == 0)
                    {
                        Leeg L = new Leeg(y * 50, x* 50);
                        EmptyBlocks.Add(L);

                    }
                    if (IntTylearray[x, y] == 1)
                    {
                             if (i == 0)
                            {
                                //De vijand zal nu beginnen met naar rechts te lopen.
                                Enemy v = new Enemy(y * 50, x * 50, false, true);
                                Vijanden.Add(v);
                                i++;
                            }
                            else if(i == 1)
                            {
                                //De vijand zal nu beginnen met naar links te lopen.
                                Enemy v = new Enemy(y * 50, x * 50, true, false);
                                Vijanden.Add(v);
                                i = 0;
                            }

                    }
                    if (IntTylearray[x, y] == 2)
                    {
                        Grass m = new Grass (y * 50, x * 50);
                        GrassObjects.Add(m);

                    }
                    if (IntTylearray[x, y] == 3)
                    {
                        LifeItem l = new LifeItem(y * 50, x * 50);
                        LifeObjects.Add(l);

                    }
                    if (IntTylearray[x, y] == 4)
                    {
                        NextLevelDoor n = new NextLevelDoor(y * 50, x * 50);
                        NextLevelObjects.Add(n);
                    }
                    if (IntTylearray[x, y] == 5)
                    {
                        held = new Hero(y * 50,x * 50);
                        GameObjects.Add(held);
                    }
                }
            }
        }
Beispiel #3
0
        private void Createworld()
        {
            for (int x = 0; x <11; x++)
            {
                for (int y = 0; y < 25; y++)
                {

                    if (IntTylearray[x,y] == 0)
                    {
                        Leeg l = new Leeg();
                        EmptyBlocks.Add(l);

                    }
                    if (IntTylearray[x, y] == 1)
                    {
                        Grass g = new Grass(y * 50, x * 50);
                        GrassObjects.Add(g);
                    }
                    if (IntTylearray[x, y] == 2)
                    {
                        MetalBlock m = new MetalBlock (y * 50, x * 50);
                        MetalObjects.Add(m);

                    }
                    if (IntTylearray[x, y] == 3)
                    {
                        LifeItem l = new LifeItem(y * 50, x * 50);
                        LifeObjects.Add(l);

                    }
                    if (IntTylearray[x, y] == 4)
                    {
                        NextLevelDoor n = new NextLevelDoor(y * 50, x * 50);
                        NextLevelObjects.Add(n);

                    }

                }
            }
        }