Пример #1
0
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     End.SetQ();
     base.Initialize();
 }
Пример #2
0
        public void Update(ref bool fps, ref int game)
        {
            KeyboardState kstate = Keyboard.GetState();

            if (game == 2) // menu
            {
                if (kstate.IsKeyDown(Keys.A))
                {
                    game = 1;
                }
            }


            // ########################################## Gameplay #############################################################################
            else if (game == 1)
            {
                if (HealthBar.EHealth < 1 && lastHealth != (int)HealthBar.EHealth) // Earning money
                {
                    money += random(10 + Events.EnemyDMG + (Controlls.Dmg / 11), 51 + Events.EnemyDMG + (Controlls.Dmg / 11));
                    score += random(10 + Events.EnemyDMG + (Controlls.Dmg / 11), 51 + Events.EnemyDMG + (Controlls.Dmg / 11));
                }
                if (Star.Star_speed == 1) // Laser
                {
                    if (Events.Status == 1)
                    {
                        if (kstate.IsKeyDown(Keys.Q) && Laser.LaserMoving == 0 && Turns.Turn == 1) // Laser attack mot fienden
                        {
                            Turns.Turn = 2;
                            Laser.Eshoot(random(dmg - 20, dmg + 1));
                            //Laser.shoot((float)random(170, 330));
                        }
                    }
                }

                // ####################################### Köpa #######################################################################
                if (Star.Star_speed == 1)
                {
                    if (Events.Status == 0)
                    {
                        if (kstate.IsKeyDown(Keys.E) && !kprev.IsKeyDown(Keys.E) && money >= 50 + Events.PriceChange) // Köpa vapen
                        {
                            dmg   += 10;
                            score += 10;
                            money -= 50 + Events.PriceChange;
                        }
                    }
                    if (Events.Status == 2)
                    {
                        if (kstate.IsKeyDown(Keys.E) && !kprev.IsKeyDown(Keys.E) && money >= 30 + Events.PriceChange) // Köpa Liv
                        {
                            HealthBar.Heal();
                            money -= 30 + Events.PriceChange;
                        }
                    }
                    if (Events.Status == 3)
                    {
                        if (kstate.IsKeyDown(Keys.E) && !kprev.IsKeyDown(Keys.E) && money >= 20 + Events.PriceChange) // Betting
                        {
                            if (random(1, Events.Bet + 1) == 1)
                            {
                                money += (20 + Events.PriceChange) * (Events.Bet - 1);
                            }

                            else
                            {
                                money -= 20 + Events.PriceChange;
                            }
                        }
                    }
                }

                // ################################### Internet #############################################################
                if (Star.Star_speed == 1)
                {
                    if (kstate.IsKeyDown(Keys.I) && !kprev.IsKeyDown(Keys.I))
                    {
                        if (Internet.Active == true)
                        {
                            Internet.Active = false;
                        }
                        else
                        {
                            Internet.Active = true;
                        }
                    }
                }

                // ################################ FTL Jump ###############################################################
                if (PlayerShip.Jump == false)
                {
                    if (kstate.IsKeyDown(Keys.Space))
                    {
                        if (Events.Status != 1 || Events.Status == 1 && HealthBar.EHealth < 1)
                        {
                            Star.Jump();
                            Turns.Turn      = 1;
                            PlayerShip.Jump = true;
                            Events.Jump();
                        }
                    }
                }
            }

            if (kstate.IsKeyDown(Keys.P) && fps == false && !kprev.IsKeyDown(Keys.P)) // show fps
            {
                fps = true;
            }
            else if (kstate.IsKeyDown(Keys.P) && fps == true && !kprev.IsKeyDown(Keys.P))
            {
                fps = false;
            }

            if (kstate.IsKeyDown(Keys.N) && !kprev.IsKeyDown(Keys.N))
            {
                End.SetQ();
            }

            kprev      = kstate;
            lastHealth = (int)HealthBar.EHealth;

            /*if (kstate.IsKeyDown(Keys.K) && Laser.LaserMoving == 0) // Test mot spelar skeppet
             * {
             *  Laser.shoot((float)random(170, 330));
             *  End.SetQ();
             * }*/
        }
Пример #3
0
        protected override void Draw(GameTime gameTime)
        {
            /*_graphics.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width;
             * _graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
             * _graphics.IsFullScreen = true;
             * _graphics.ApplyChanges();*/

            GraphicsDevice.Clear(Color.Black);
            _spriteBatch.Begin();
            // TODO: Add your drawing code here
            stars.Draw(_spriteBatch);

            if (game == 2)
            {
                _spriteBatch.DrawString(Alvin, "Press A to start", new Vector2(GraphicsDevice.Viewport.Width / 2 - 90, 220), Color.White);
            }
            else if (game == 1)
            {
                laser.Draw(_spriteBatch);
                player.Draw(_spriteBatch);
                if (Star.Star_speed == 1)
                {
                    events.Draw(_spriteBatch);
                    if (Events.Status == 1)
                    {
                        enemy.Draw(_spriteBatch);
                    }
                    health.Draw(_spriteBatch);
                    controll.Draw(_spriteBatch);
                    internet.Draw(_spriteBatch);
                }
            }
            else
            {
                _spriteBatch.DrawString(Alvin, End.Qoute(), new Vector2(GraphicsDevice.Viewport.Width / 2 - End.Qoute().Length * 4, 220), Color.White);
                _spriteBatch.DrawString(Alvin, "Score: " + Controlls.Score, new Vector2(GraphicsDevice.Viewport.Width / 2 - (20 + Controlls.Score / 10), 200), Color.White);
            }
            if (show_fps)
            {
                _spriteBatch.DrawString(Alvin, fpsS.ToString("fps 0"), new Vector2(5, 5), Color.White);
            }
            _spriteBatch.End();
            base.Draw(gameTime);
        }