示例#1
0
        public PlayerShip(int shipIndex)
        {
            this.shipIndex = shipIndex;

            EventHandler.KeyDown += OnKeyDown;
            EventHandler.KeyUp   += OnKeyUp;

            cannon         = new Cannon();
            cannon.Center  = Center;
            cannon.Right   = Right;
            cannon.Visible = false;
            AddChild(cannon);
            playerShip = LoadImage();
        }
示例#2
0
        public SideCannons(int duration = 2500)
        {
            this.duration = duration;
            startTime     = Environment.TickCount;

            Height = 100;

            Cannon c1 = new Cannon();

            c1.Center       = Center;
            c1.CenterY      = Top;
            c1.ShotInterval = 150;
            AddChild(c1);

            Cannon c2 = new Cannon();

            c2.Center       = Center;
            c2.CenterY      = Bottom;
            c2.ShotInterval = 150;
            AddChild(c2);
        }
示例#3
0
        private void DrawBackground()
        {
            for (int i = 0; i < map.Hoogte; i++)
            {
                for (int j = 0; j < map.Breedte; j++)
                {
                    switch (map.GetElement(j, i))
                    {
                    case 0:

                        break;

                    case 1:
                        spriteArray[j, i] = new Grass(j, i, video, @"Sprites\grass\grass.png");
                        break;

                    case 2:
                        spriteArray[j, i] = new Grass(j, i, video, @"Sprites\grass\grassRight.png");
                        break;

                    case 3:
                        spriteArray[j, i] = new Grass(j, i, video, @"Sprites\grass\grassLeft.png");
                        break;

                    case 4:
                        spriteArray[j, i] = new Grass(j, i, video, @"Sprites\grass\grassCornerRight.png");
                        break;

                    case 5:
                        spriteArray[j, i] = new Grass(j, i, video, @"Sprites\grass\grassCornerLeft.png");
                        break;

                    case 6:
                        spriteArray[j, i] = new Sand(j, i, video, @"Sprites\sand\sand.png");
                        break;

                    case 7:
                        spriteArray[j, i] = new Sand(j, i, video, @"Sprites\sand\sandBorderLeft.png");
                        break;

                    case 8:
                        spriteArray[j, i] = new Sand(j, i, video, @"Sprites\sand\sandBorderRight.png");
                        break;

                    case 9:
                        spriteArray[j, i] = new Sand(j, i, video, @"Sprites\sand\sandCornerRight.png");
                        break;

                    case 10:
                        spriteArray[j, i] = new Sand(j, i, video, @"Sprites\sand\sandCornerLeft.png");
                        break;

                    case 11:
                        spriteArray[j, i] = new Finish(j, i, video);
                        break;

                    case 12:
                        spriteArray[j, i] = new CoinBlock(j, i, video);
                        break;

                    case 13:
                        spriteArray[j, i] = new InvisibleWall(j, i, video);
                        break;

                    case 14:
                        spriteArray[j, i] = new Cannon(j, i, video);
                        break;

                    case 15:
                        spriteArray[j, i] = new EnemyShell(j, i, video);
                        break;

                    case 16:
                        spriteArray[j, i] = new Spikes(j, i, video, @"Sprites\enemies\spikesUp.png");
                        break;

                    case 17:
                        spriteArray[j, i] = new Spikes(j, i, video, @"Sprites\enemies\spikesDown.png");
                        break;

                    case 18:
                        spriteArray[j, i] = new Spikes(j, i, video, @"Sprites\enemies\spikesRight.png");
                        break;

                    case 19:
                        spriteArray[j, i] = new Spikes(j, i, video, @"Sprites\enemies\spikesLeft.png");
                        break;

                    case 20:
                        spriteArray[j, i] = new Block(j, i, video);
                        break;

                    case 21:
                        spriteArray[j, i] = new AngryStone(j, i, video);
                        break;

                    case 22:
                        spriteArray[j, i] = new DroppingGround(j, i, video);
                        break;
                    }
                }
            }
        }
示例#4
0
文件: Map.cs 项目: kuno86/Platformer
        //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)
        }