예제 #1
0
        public void DrawExtraLines(
                ref bool trippy1,
                ref bool trippy2,
                ref SpriteBatch spriteBatch,
                ref Texture2D YPixel,
                ref Turret turret,
                ref int insideoutside,
                ref float LineMovement

            )
        {
            if (trippy1)
            {
                for (int i = -50; i < 130; i++)
                {
                    spriteBatch.Draw(YPixel, new Rectangle(i * 10, 0, 1, 600), null, Color.White);
                    spriteBatch.Draw(YPixel, new Rectangle(i * 10, 0, 1, 900), null, Color.White, turret.GetTurretROT() * 1.1f, new Vector2(0, 0), SpriteEffects.None, 1);
                    spriteBatch.Draw(YPixel, new Rectangle(i * 10, 0, 1, 900), null, Color.White, -turret.GetTurretROT() * 1.1f, new Vector2(0, 0), SpriteEffects.None, 1);
                }
            }
            else if (trippy2)
            {
                insideoutside = (int)(LineMovement);
                for (int i = -50; i < 130; i++)
                {
                    insideoutside *= -1;
                    spriteBatch.Draw(YPixel, new Rectangle((i * 10) + insideoutside, 0, 1, 600), null, Color.White);
                }
            }
        }
예제 #2
0
        public void Drawing(
            ref SpriteBatch spriteBatch,
            ref Texture2D YPixel,
            ref Vector2 BakkePos,
            ref float GroundRotation,
            ref Turret turret,
            ref Texture2D TurrentUnderdel,
            ref Vector2 TurrentUnderdelRect,
            ref Vector2 TurrentMidRect,
            ref Texture2D TurrentMid,
            ref List<EnemyHelo> ChopperList,
            ref List<Bullet> BulletList,
            ref List<EnemyParatrooper> ParatrooperList
            )
        {
            //GroundPosition += 0.01f; //This makes the ground spin

            //Draw ground
            spriteBatch.Draw(YPixel, BakkePos, null, Color.White, GroundRotation, new Vector2(0, 0), 1, SpriteEffects.None, 1);

            spriteBatch.Draw(TurrentMid, TurrentMidRect, Color.White);
            spriteBatch.Draw(TurrentUnderdel, TurrentUnderdelRect, Color.White);

            for (int i = 0; i < ChopperList.Count; i++)
            {
                ChopperList[i].Draw(spriteBatch);
            }

            for (int i = 0; i < ParatrooperList.Count; i++)
            {
                ParatrooperList[i].Draw(spriteBatch);
            }
            for (int i = 0; i < BulletList.Count; i++)
            {
                BulletList[i].Draw(spriteBatch);
            }
            turret.Draw(spriteBatch);
        }
예제 #3
0
        //----------------------------------------Class Begin-----------------------------------
        //Console.writeline(stuff);
        public void PlayInput(
               ref GameTime gameTime,
               ref TimeSpan PreviousTripTime,
               ref TimeSpan TripTime,
               ref bool trippy1,
               ref bool trippy2,
               ref Single TurretROT,
               ref Turret turret,
               ref Vector2 BulletOrigin,
               ref Vector2 BulletOriginAtZero,
               ref TimeSpan PreviousFireTime,
               ref float MoveLimit,
               ref TimeSpan FireRate,
               ref int FireContinously,
               ref Vector2 TurrentOrigin,
               ref Texture2D BulletTexture,
               ref List<Bullet> BulletList,
               ref float TurretRotAtSpace,
               ref GameState gamestate,
               ref TimeSpan PauseTimeCooldown,
               ref TimeSpan TotalPauseTime
           )
        {
            //T
            if (Keyboard.GetState().IsKeyDown(Keys.T) && (gameTime.TotalGameTime - PreviousTripTime) > TripTime && !trippy2)
            {
                if (trippy1)
                {
                    trippy1 = false;
                }
                else
                {
                    trippy1 = true;
                }
                PreviousTripTime = gameTime.TotalGameTime;
            }
            //Y
            if (Keyboard.GetState().IsKeyDown(Keys.Y) && (gameTime.TotalGameTime - PreviousTripTime) > TripTime && !trippy1)
            {
                if (trippy2)
                {
                    trippy2 = false;
                }
                else
                {
                    trippy2 = true;
                }
                PreviousTripTime = gameTime.TotalGameTime;
            }
               ////Vector calculations
               // Mouse.GetState().Y
               //     Mouse.GetState().X
                    //405, 452 location to turning point
                    //float a = (float) (Math.Atan(((Mouse.GetState().X-405)/(Mouse.GetState().Y-452)))*(180/Math.PI));

            //float r= sqrt(x*x+y*y);
            int x= Mouse.GetState().X-405;
            int y= Mouse.GetState().Y-452;

               double r = Math.Sqrt((Math.Pow(x,2)+Math.Pow(y,2)));
               float a = (float)(Math.Acos(x / r));

                    turret.Move(a);

            //Arrow left
               //Might wanna move MoveLimit to Turret.cs instead
            if (Keyboard.GetState().IsKeyDown(Keys.Left) && (TurretROT > -MoveLimit))
            {
                turret.MoveLeft();
                TurretROT = turret.GetTurretROT();
            }
            //Arrow Right
            if (Keyboard.GetState().IsKeyDown(Keys.Right) && (TurretROT < MoveLimit))
            {
                turret.MoveRigth();
                TurretROT = turret.GetTurretROT();

            }
            //Arrow up
            if (Keyboard.GetState().IsKeyDown(Keys.Up))
            {
                turret.TurretZero();
                BulletOrigin = BulletOriginAtZero;
            }
            //Arrow Down
            if (Keyboard.GetState().IsKeyDown(Keys.Down))
            {
                if (gameTime.TotalGameTime - PauseTimeCooldown > TimeSpan.FromSeconds(1))
                {
                    gamestate = GameState.Pause;
                    PauseTimeCooldown = gameTime.TotalGameTime;
                }
            }
            //Space
            if ((gameTime.TotalGameTime - TotalPauseTime) - PreviousFireTime > FireRate)
            {
                if ((Keyboard.GetState().IsKeyDown(Keys.Space))||Mouse.GetState().LeftButton==ButtonState.Pressed)//Obligotary SPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACE
                {

                    BulletOrigin.X = BulletOriginAtZero.X + (TurrentOrigin.Y * (float)Math.Sin(turret.GetTurretROT()));
                    //BulletOrigin.Y =  BulletOriginAtZero.Y  * (float)Math.Cos(turret.GetTurretROT());
                    BulletOrigin.Y = -2+ BulletOriginAtZero.Y - (TurrentOrigin.Y * (float)Math.Cos(turret.GetTurretROT()));
                    Console.WriteLine("degree: "+a);

                    TurretRotAtSpace = turret.GetTurretROT();
                    FireContinously = 1;

                    Bullet bullet = new Bullet();
                    bullet.Initialize(BulletTexture, BulletOrigin, TurretRotAtSpace);
                    BulletList.Add(bullet);

                    PreviousFireTime = (gameTime.TotalGameTime - TotalPauseTime);
                }

            }
        }
예제 #4
0
        protected override void Initialize()
        {
            this.IsMouseVisible = true;
            //Graphics
            graphics.PreferredBackBufferHeight = 505;
            graphics.PreferredBackBufferWidth = 800;
            graphics.ApplyChanges();

            //General
            gamestate = GameState.Playing;
            BakkePos = new Vector2(0, 475);
            GroundRotation = -(float)((Math.PI / 180) * 90);
            rnd = new Random();

            //Extra features
            LineMovement = 0;
            trippy1 = false;
            trippy2 = false;
            Retract = true;
            Background = new Animation2();//          640 448                 //Graphics settings
            Background.Initialize(new Vector2(0, 0), 500, 500, 5, new Rectangle(0,0,800,475), Color.Black, true);

            //FPS
            fps = 0;
            fpscount = 0;
            fpsmeasurement = TimeSpan.FromSeconds(1);
            prevFPSmeasurement = TimeSpan.Zero;

            //Turret
            turret = new Turret();
            TurretRotAtSpace = 0;
            AmountOfTroopersOnTurret = new Vector2(0, 0);//Left and right
            FireContinously = 0;
            BulletOrigin = new Vector2(398f, 427);
            BulletOriginAtZero = BulletOrigin;
            TurrentOrigin = new Vector2(5, 25);//Omrisse av kanonen
            TurrentMidRect = new Vector2(380, 409);
            TurrentUnderdelRect = new Vector2(360, 425);//Plassering for bakken blir 475
            MoveLimit = ((float)(Math.PI / 180)) * 65;//var 88

            //Time
            TimePassed = new Vector2(0, 0);
            TripTime =TimeSpan.FromSeconds(0.5f);
            PreviousTripTime = TimeSpan.Zero;
            PauseTimeCooldown = TimeSpan.Zero;
            TotalPauseTime = TimeSpan.Zero;
            FireRate=TimeSpan.FromSeconds(0.4f);//0.4
            EnemyRate = TimeSpan.FromMilliseconds(1500);
            MoveRate = TimeSpan.FromSeconds(0.00002f);
            PreviousMoveTime = TimeSpan.Zero;
            PreviousEnemyTime = TimeSpan.Zero;
            PreviousFireTime = TimeSpan.Zero;

            //Lists
            BulletList = new List<Bullet>();
            ChopperList = new List<EnemyHelo>();
            ParatrooperList = new List<EnemyParatrooper>();

            //Classes
            PlayKeyboard    = new StatePlayKeyboard();
            SpecialF        = new SpecialFeatures();
            Spawn           = new Spawner();
            ListUpdater     = new UpdateLists();
            CollisionDetect = new CollisionDetection();
            text            = new TextOnScreen();
            draw            = new Draw();
            Sally           = new SaveAndLoadGame();
            PauseKeyboard   = new StatePauseKeyboard();
            //Sally.SaveGame(47);
            Sally.LoadGame();
            base.Initialize();
        }