Example #1
0
        //Constructor
        public Map(int tilesize)
        {
            int x=0;
            int y=0;
            tileSize = tilesize;
            currentDimension = 2;
            spriteArrMax = 0;
            sprites[000] = null;
            sprites[001] = new Player(-200, -200);
            sprites[002] = new Boo(-200, -200);
            sprites[003] = new Goomba(-200, -200, false, (short)rnd.Next(1, 4));
            sprites[004] = new Koopa_green(-200, -200);
            sprites[005] = new Koopa_green(-200, -200, false, 1, 2);  //jumping
            sprites[006] = new Koopa_green(-200, -200, false, 1, 3);  //high jumping
            sprites[007] = new Koopa_red(-200, -200);
            sprites[008] = new Koopa_red(-200, -200, false, 1, 2);  //jumping
            sprites[009] = new Koopa_red(-200, -200, false, 1, 3);  //high jumping
            sprites[010] = new Bulletbill(-200, -200, false, (short)rnd.Next(1, 5));
            sprites[011] = new Bulletbill(-200, -200, false, 3,true);   //homing version (only type 3 !!!)
            sprites[012] = new Buzzybeetle(-200, -200, false);
            sprites[013] = new Spiny(-200, -200, false, 1, false);  //Spiny
            sprites[014] = new Spiny(-200, -200, false, 1, true);   //Spiny-Egg
            sprites[015] = new Piranhaplant(-200, -200, 1);     //Green Piranha Plant
            sprites[016] = new Piranhaplant(-200, -200, 2);     //Red Piranha Plant
            sprites[017] = new Hammerbros(-200, -200);
            sprites[018] = new Lakitu(-200, -200);
            sprites[019] = new Blooper(-200, -200,(short)rnd.Next(0,2));
            sprites[020] = new CheepCheep(-200, -200,false, 0); //Green CheepCheep
            sprites[021] = new CheepCheep(-200, -200, false, 1); //Red CheepCheep
            sprites[022] = new Bowser_smb1(-200, -200, false, false);   //smb1 Bowser
            sprites[023] = new Bowser_smb1(-200, -200, false, true);    //smb1 Bowser with Hammers

            sprites[100] = null;
            sprites[101] = new Coin(-200, -200, (short)rnd.Next(1, 6));     //fixed Coin
            sprites[102] = new Coin(-200, -200, (short)rnd.Next(1, 6), false);  //loose Coin
            sprites[103] = new Pow(-200, -200);
            sprites[104] = new Mushroom(-200, -200, false, (short)rnd.Next(1, 3));
            sprites[105] = new Mushroom_p(-200, -200);
            sprites[106] = new Fireflower(-200, -200, (short)rnd.Next(1, 4));
            sprites[107] = new Starman(-200, -200, false, (short)rnd.Next(1, 5));
            sprites[108] = new OneUp(-200, -200);
            sprites[109] = new ThreeUp(-200, -200);
            sprites[110] = new Keyy(-200, -200, (short)rnd.Next(1, 3));
            sprites[111] = new Spring_p(-200, -200);
            sprites[112] = new PSwitch_b(-200, -200);
            sprites[113] = new Cannon(-200, -200);

            sprites[200] = new Lava(-200, -200);
            sprites[201] = new Potaboo(-200, -200);
            sprites[202] = new Firebar(-200, -200);
            sprites[203] = new Winehead(-200, -200);
            sprites[204] = new Bricks(-200, -200, (short)rnd.Next(1, 5), (short)rnd.Next(102,114));
            sprites[205] = new Qm(-200, -200, 1, 102);
            sprites[206] = new Keyhole(-200, -200);
            sprites[207] = new Generator(-200, -200, 3);    //Sprite-generator
            sprites[208] = new WarpToWarp(-200, -200, true, 1, 0, warpNr);      //Warp Start-Point
            sprites[209] = new WarpToWarp(-200, -200, false, 3, 0, warpNr);  //Warp End-Point
            sprites[210] = new WarpToXYS(-200, -200, 200, 200);     //Warp to XY Coordinates (S=Section of that level)
            sprites[211] = new RollingRock(-200, -200);
            sprites[212] = new Platform(-200, -200);
            sprites[213] = new Platform_pulley(-200, -200, 6);
            sprites[214] = new FixedSpring(-200, -200, 0);  //Red normal fix spring
            sprites[215] = new FixedSpring(-200, -200, 1);  //Green strong fix spring

            maxTextureSize = GL.GetInteger(OpenTK.Graphics.OpenGL.GetPName.MaxTextureSize);
            Console.WriteLine("BG: " + Texture.backGround);
            MyImage.activeTexture = Texture.backGround;
            GL.BindTexture(TextureTarget.Texture2D, Texture.backGround);
            GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureWidth, out bgW);     //Get Width and
            GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureHeight, out bgH);    //Height from the loaded Background

            MyImage.activeTexture = Texture.tileSet;
            GL.BindTexture(TextureTarget.Texture2D, Texture.tileSet);
            GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureWidth, out tileSetW);    //Get Width and
            GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureHeight, out tileSetH);   //Height from the loaded tileset

            currentIDArr[0, 1] = 2;                                                 //numer of diffrent collision-types
            currentIDArr[1, 1] = Texture.bgTilesArray.GetLength(0) - 1;             //Max Back- / Fore-ground Object ID
            currentIDArr[2, 1] = ((tileSetW / tileSize) * (tileSetH / tileSize))-1; //max tileID
            currentIDArr[3, 1] = sprites.GetLength(0) - 1;                          //max spriteID
            currentIDArr[4, 1] = Texture.bgTilesArray.GetLength(0) - 1;             //Max Back- / Fore-ground Object ID

            currentIDArr[3, 0] = 100;

            while (y < map.GetLength(0))    //fill a new map with empty and no collision
            {
                while (x < map.GetLength(1))
                {
                    map[y, x, 0] = 0;           //collision info, 0=non-solid     1=solid     2=cloud (only top-solid)      3=Ladder        4=Lava/Instant-death      5=Spikes/1Hit
                    map[y, x, 1] = 0;           //Background Objects (not the actual Background !!!)
                    map[y, x, 2] = currentIDArr[2,1]-3; //Tile-IDs, -1 means no block there
                    map[y, x, 3] = 0;           //sprite-IDs, -1 means that the sprites was spawned and won't spawn endless each loop
                    map[y, x, 4] = 0;           //Foreground Objects (no collision)

                    x++;
                    if (x == map.GetLength(1))
                    { y++; x = 0; }
                    if (y == map.GetLength(0))
                        break;
                }
            }

            map[9, 9, 3] = 1; //Test Player
            map[11, 8, 2] = 0;//Block under Player
            map[11, 8, 0] = 1;//Solid under Player
            map[11, 9, 2] = 0;//Block under Player
            map[11, 9, 0] = 1;//Solid under Player
            map[11, 10, 2] = 0;//Block under Player
            map[11, 10, 0] = 1;//Solid under Player
            map[10, 10, 3] = 2; //Test Boo
            map[11, 11, 3] = 300;   //Test Fireball (harms player)
        }
 private void Awake() => lava = FindObjectOfType <Lava>();