コード例 #1
0
 public override void LoadContent()
 {
     VectorFont.Initialize(StateManager.game);
     spriteBatch = new SpriteBatch(StateManager.graphicsDevice);
     spriteFont  = StateManager.Content.Load <SpriteFont>("Font");
     oldKeyState = Keyboard.GetState();
 }
コード例 #2
0
 public override void LoadContent()
 {
     lander = new Lander(StateManager.game);
     lander.Initialize();
     VectorFont.Initialize(StateManager.game);
     terrain             = new Terrain(StateManager.game);
     terrain.TerrainName = terrainFileName;
     terrain.Initialize();
     sentScore        = false;
     win              = StateManager.Content.Load <SoundEffect>("LanderVictorySound");
     lose             = StateManager.Content.Load <SoundEffect>("LanderExplosionSound");
     bgColor          = Color.Black;
     oldKeyboardState = Keyboard.GetState();
 }
コード例 #3
0
 public override void LoadContent()
 {
     VectorFont.Initialize(StateManager.game);
     oldKeyState = Keyboard.GetState();
 }
コード例 #4
0
ファイル: Lander.cs プロジェクト: AidanFairman/LunarLander
        public override void Initialize()
        {
            pb           = new PrimitiveBatch(Game.GraphicsDevice);
            isThrusting  = false;
            gravityPerMS = gravity / 1000.0f;
            thrustPower  = 0 - (gravityPerMS * 2.0f);
            VectorFont.Initialize(Game);
            fullLander = new LanderParts(new List <Vector2>(), new Vector2(15.0f, 5.0f));
            Fuel       = 100;
            angleRad   = MathHelper.ToRadians(0);

            rocketBoosterEffect = Game.Content.Load <SoundEffect>("RocketThrust");

            #region initialize parts
            landerCan = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "LanderCan.txt")), fullLander.Position);

            manCan = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "ManCap.txt")), fullLander.Position);

            thrust1 = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "Thrust.txt")), fullLander.Position);
            thrust2 = new LanderParts(LanderTextToVector.GetXMirrorPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "Thrust.txt")), fullLander.Position);

            thruster = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "Thruster.txt")), fullLander.Position);

            legRight = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "LegR.txt")), fullLander.Position);
            legLeft  = new LanderParts(LanderTextToVector.GetXMirrorPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "LegR.txt")), fullLander.Position);
            #endregion

            #region construct lander
            LinkedList <Vector2> tempLander = new LinkedList <Vector2>();
            Vector2 partPosition            = new Vector2(0f, 0f);

            foreach (Vector2 v2 in manCan.Part)
            {
                tempLander.AddLast(v2 + partPosition);
            }
            partPosition.Y += 4;
            foreach (Vector2 v2 in landerCan.Part)
            {
                tempLander.AddLast(v2 + partPosition);
            }
            partPosition.Y += 3;
            partPosition.X -= 5;
            foreach (Vector2 v2 in legLeft.Part)
            {
                tempLander.AddLast(v2 + partPosition);
            }
            partPosition.X += 11;
            foreach (Vector2 v2 in legRight.Part)
            {
                tempLander.AddLast(v2 + partPosition);
            }
            partPosition.X -= 5;
            partPosition.Y += 3;
            foreach (Vector2 v2 in thruster.Part)
            {
                tempLander.AddLast(v2 + partPosition);
            }

            partPosition.Y += 1;

            thrustLocation = new Vector2(partPosition.X * landerScale, partPosition.Y * landerScale);
            LinkedListNode <Vector2> node = tempLander.First;

            for (int i = 0; i < tempLander.Count; ++i)
            {
                node.Value *= landerScale;
                node        = node.Next;
                if (i < thrust1.Part.Count)
                {
                    thrust1.Part[i] *= landerScale;
                    thrust2.Part[i] *= landerScale;
                }
            }

            float minimumLanderXPosition = 0;
            float maximumLanderXPosition = 0;
            float minimumLanderYPosition = 0;
            float maximumLanderYPosition = 0;

            foreach (Vector2 v2 in tempLander)
            {
                if (minimumLanderXPosition > v2.X)
                {
                    minimumLanderXPosition = v2.X;
                }
                if (maximumLanderXPosition < v2.X)
                {
                    maximumLanderXPosition = v2.X;
                }
                if (minimumLanderYPosition > v2.Y)
                {
                    minimumLanderYPosition = v2.Y;
                }
                if (maximumLanderYPosition < v2.Y)
                {
                    maximumLanderYPosition = v2.Y;
                }
            }
            Vector2 cornerModifier = new Vector2(0 - minimumLanderXPosition, 0 - minimumLanderYPosition);
            thrustLocation += cornerModifier;
            for (int i = 0; i < thrust1.Part.Count; ++i)
            {
                thrust1.Part[i] += thrustLocation;
                thrust2.Part[i] += thrustLocation;
            }
            landerCenter = new Vector2((maximumLanderXPosition - minimumLanderXPosition) / 2, (maximumLanderYPosition - minimumLanderYPosition) / 2);
            foreach (Vector2 v2 in tempLander)
            {
                fullLander.Part.Add(v2 + cornerModifier);
            }
            #endregion

            Start();
            oldKeyboardState     = new KeyboardState();
            landerColor          = Color.Silver;
            thrustColor          = Color.OrangeRed;
            fullLanderUnmodified = new List <Vector2>(fullLander.Part);
            thrust1Unmodified    = new List <Vector2>(thrust1.Part);
            thrust2Unmodified    = new List <Vector2>(thrust2.Part);

            base.Initialize();
        }