Пример #1
0
        public ZipLine(Vector2 pos1, Vector2 pos2, Room.LevelTheme theme)
        {
            this.pos1 = pos1;
            this.pos2 = pos2;

            slope = (dY = pos2.Y - pos1.Y) / (dX = pos2.X - pos1.X);
            angle = (float)Math.Atan2(dY, dX);
            while (angle < 0) angle += MathHelper.TwoPi;

            poleTex = Game1.poleTex;
            lineTex = Game1.lineTex;

            if (theme == Room.LevelTheme.Grass || theme == Room.LevelTheme.Factory)
                lineColor = Color.Black;
            else
                lineColor = Color.White;

            acceleration = new Vector2(0.4f * (float)(Math.Sin(angle) * Math.Cos(angle)), 0.4f * (float)(Math.Sin(angle) * Math.Sin(angle)));
        }
Пример #2
0
        protected override void Update(GameTime gameTime)
        {
            //			if (Keyboard.GetState().IsKeyDown(Keys.Z))
            //				this.TargetElapsedTime = TimeSpan.FromSeconds(0.5f);
            //			else
            //				this.TargetElapsedTime = TimeSpan.FromSeconds(0.016f);

            if (!Keyboard.GetState().IsKeyDown(Keys.Escape))
                pressEscape = true;
            if (Keyboard.GetState().IsKeyDown(Keys.Escape) && pressEscape || exit)
            {
                if (Game1.finishedSS)
                {
                    Game1.finishedSS = false;
                    SimpleAES enc = new SimpleAES();
                    if (!File.Exists("Content\\records.txt"))
                    {
                        StreamWriter w = new StreamWriter("Content\\records.txt");
                        w.WriteLine(enc.EncryptToString("fullgame 0 -1"));
                        w.Flush();
                        w.Dispose();
                    }
                    else
                    {
                        StreamReader r = new StreamReader("Content\\records.txt");
                        string s = enc.DecryptString(r.ReadLine());
                        while (s.Split(' ')[1] != "0" && s.Split(' ')[0] != "fullgame" && !r.EndOfStream)
                            s = enc.DecryptString(r.ReadLine());
                        if (s.Split(' ')[1] == "0" && s.Split(' ')[0] == "fullgame")
                            totalRecord = int.Parse(s.Split(' ')[2]);
                        else
                            totalRecord = -1;
                        r.Close();
                        r.Dispose();
                    }
                }
                totalTime = 0;
                startTotalTime = false;
                currentRoom.viewingLeaderboards = false;
                pressEscape = false;
                if (currentRoom is MainMenu)
                    this.Exit();
                else if (currentRoom is SkinSelection)
                    currentRoom = new Settings();
                else if (currentRoom is FGLeaderboard)
                    currentRoom = new LevelSelect(0);
                else
                    currentRoom = new MainMenu(true);
            }

            currentRoom.Update(gameTime);
            base.Update(gameTime);
        }
Пример #3
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            finishTex = Content.Load<Texture2D>("finish");
            poleTex = Content.Load<Texture2D>("pole");
            lineTex = Content.Load<Texture2D>("pixel");
            Texture2D[] images = new Texture2D[3];
            for (int i = 1; i <= images.Length; i++)
                images[i - 1] = Content.Load<Texture2D>("booster000" + i.ToString());
            boosterTex = new AnimatedTexture(images, 600, true, false);
            platformTex = Content.Load<Texture2D>("floating platform");
            messageTex = Content.Load<Texture2D>("message");
            boxTex = Content.Load<Texture2D>("box");
            explosionTex = Content.Load<Texture2D>("explosion particle");
            rocketTex = Content.Load<Texture2D>("rocket");
            launcherTex = Content.Load<Texture2D>("launcher");
            flamethrowerTex = Content.Load<Texture2D>("flamethrower");

            tileSet = new Texture2D[5];
            deathWallSet = new Texture2D[5];
            backgrounds = new Texture2D[5];
            tileSet[0] = Content.Load<Texture2D>("tiles/tilegrass");
            tileSet[1] = Content.Load<Texture2D>("tiles/tilelava");
            tileSet[2] = Content.Load<Texture2D>("tiles/tilenight");
            tileSet[3] = Content.Load<Texture2D>("tiles/tilecave");
            tileSet[4] = Content.Load<Texture2D>("tiles/tilefactory");
            deathWallSet[0] = Content.Load<Texture2D>("tiles/deathgrass");
            deathWallSet[1] = Content.Load<Texture2D>("tiles/deathlava");
            deathWallSet[2] = Content.Load<Texture2D>("tiles/deathnight");
            deathWallSet[3] = Content.Load<Texture2D>("tiles/deathcave");
            deathWallSet[4] = Content.Load<Texture2D>("tiles/deathfactory");
            mirrorTex = Content.Load<Texture2D>("tiles/mirror");
            backgrounds[0] = Content.Load<Texture2D>("backgrounds/bggrass");
            backgrounds[1] = Content.Load<Texture2D>("backgrounds/bglava");
            backgrounds[2] = Content.Load<Texture2D>("backgrounds/bgnight");
            backgrounds[3] = Content.Load<Texture2D>("backgrounds/bgcave");
            backgrounds[4] = Content.Load<Texture2D>("backgrounds/bgfactory");

            medalTex = Content.Load<Texture2D>("medal");
            wallTex = Content.Load<Texture2D>("pixel");

            skinPreviews = new Texture2D[6];
            skinPreviews[0] = Content.Load<Texture2D>("skins/speed runner/speed runner normal0001");
            skinPreviews[1] = Content.Load<Texture2D>("skins/blob/blob normal0001");
            skinPreviews[2] = Content.Load<Texture2D>("skins/stick figure/stick figure normal0001");
            skinPreviews[3] = Content.Load<Texture2D>("skins/mr guy/mr guy normal0001");
            skinPreviews[4] = Content.Load<Texture2D>("skins/mario/mario normal");
            skinPreviews[5] = Content.Load<Texture2D>("skins/ninja/ninja normal0001");
            prevLocked = Content.Load<Texture2D>("skins/locked");

            run = Content.Load<SoundEffect>("sounds/run").CreateInstance();
            slide = Content.Load<SoundEffect>("sounds/slide").CreateInstance();
            jump = Content.Load<SoundEffect>("sounds/jump");
            boost = Content.Load<SoundEffect>("sounds/boost");
            collide = Content.Load<SoundEffect>("sounds/collision");
            finish = Content.Load<SoundEffect>("sounds/finish");
            damage = Content.Load<SoundEffect>("sounds/damage");
            rocketLaunch = Content.Load<SoundEffect>("sounds/rocket launch");
            explosion = Content.Load<SoundEffect>("sounds/explosion");

            playingGrass = true;
            playingLava = false;
            playingNight = false;
            playingCave = false;
            playingFactory = false;
            grassMusic  = Content.Load<Song>("music/grass");
            lavaMusic = Content.Load<Song>("music/lava");
            nightMusic = Content.Load<Song>("music/night");
            caveMusic = Content.Load<Song>("music/cave");
            factoryMusic = Content.Load<Song>("music/factory");

            titlefont = Content.Load<SpriteFont>("titlefont");
            msgfont = Content.Load<SpriteFont>("msgfont");
            mnufont = Content.Load<SpriteFont>("mnufont");
            currentRoom = new MainMenu(false);

            Settings.GetSettings();
            LoadNewSkin(this, Settings.skin);

            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(grassMusic);
        }
Пример #4
0
        public void SetPoles(Room r)
        {
            pole1 = FindPole(r, pos1);
            pole2 = FindPole(r, pos2);

            if (pole1.X < pole2.X)
                DrawBox = new Rectangle(pole1.X, Math.Min(pole1.Y, Math.Min(pole1.Bottom, Math.Min(pole2.Bottom, pole2.Y))), pole2.X + 16 - pole1.X, Math.Max(pole1.Bottom, Math.Max(pole1.Y, Math.Max(pole2.Y, pole2.Bottom))) - Math.Min(pole1.Y, Math.Min(pole1.Bottom, Math.Min(pole2.Bottom, pole2.Y))));
            else
                DrawBox = new Rectangle(pole2.X, Math.Min(pole1.Y, Math.Min(pole1.Bottom, Math.Min(pole2.Bottom, pole2.Y))), pole1.X + 16 - pole2.X, Math.Max(pole1.Bottom, Math.Max(pole1.Y, Math.Max(pole2.Y, pole2.Bottom))) - Math.Min(pole1.Y, Math.Min(pole1.Bottom, Math.Min(pole2.Bottom, pole2.Y))));
        }
Пример #5
0
        private Rectangle FindPole(Room r, Vector2 pos)
        {
            int above, below;
            above = below = (int)pos.Y;

            above -= 16;
            below += 48;

            Rectangle final = new Rectangle();
            bool hit = false;
            while (!hit && (above > 0 || below < r.roomHeight))
            {
                foreach (Wall w in r.Walls)
                {
                    if (w is PlatformWall || w is FloatingPlatform)
                        continue;

                    if (w.Bounds.Contains((int)pos.X + 1, above))
                    {
                        final = new Rectangle((int)pos.X, above, 16, (int)pos.Y - above + 16);
                        hit = true;
                    }
                    else if (w.Bounds.Contains((int)pos.X + 1, below))
                    {
                        final = new Rectangle((int)pos.X, (int)pos.Y - 16, 16, below - (int)pos.Y);
                        hit = true;
                    }
                }
                above -= 32;
                below += 32;
            }

            if (!hit)
                final = new Rectangle((int)pos.X, (int)pos.Y - 16, 16, below - (int)pos.Y);

            return final;
        }