示例#1
0
        protected override void LoadContent()
        {
            // Alla sprites ritas här
            spriteBatch = new SpriteBatch(GraphicsDevice);

            IsMouseVisible = true;

            playerTexture = Content.Load <Texture2D>("player");
            player        = new Player(playerTexture, new Vector2(offsetPlayer, screen.Height / 2 - playerTexture.Height / 2), Vector2.Zero, 5f, screen);

            ballTexture = Content.Load <Texture2D>("Ball");
            ball        = new Ball(ballTexture, new Vector2(screen.Width / 2 - ballTexture.Width / 2, screen.Height / 2 - ballTexture.Height / 2), Vector2.Zero, 5f, screen);


            playerAI_texture = Content.Load <Texture2D>("player");
            playerAI         = new Player_AI(playerAI_texture, new Vector2(screen.Width - playerAI_texture.Width / 2, screen.Height - playerAI_texture.Height / 2), Vector2.Zero, 5f, screen);

            scorePlayer = Content.Load <SpriteFont>("ScoreFont");
            scoreAI     = Content.Load <SpriteFont>("ScoreFont");

            Font = Content.Load <SpriteFont>("Time");

            //paus
            PausedTexture   = Content.Load <Texture2D>("Paused");
            PausedRectangle = new Rectangle(0, 0, PausedTexture.Width, PausedTexture.Height);
            btnPlay         = new Button();
            btnPlay.Load(Content.Load <Texture2D>("Play"), new Vector2(200, 225));
            btnQuit = new Button();
            btnQuit.Load(Content.Load <Texture2D>("Pause"), new Vector2(200, 275));

            Restart();
        }
示例#2
0
 public void BoundsPlayer(Player player, Player_AI playerAI)
 {
     //gräns
     if (spriteBox.Intersects(player.spriteBox) || spriteBox.Intersects(playerAI.spriteBox))
     {
         direction.X *= -1;
     }
 }
示例#3
0
        public void ScorePlayer(Player player, Player_AI playerAI)
        {
            //poäng räkning
            if (position.X < 0)
            {
                playerAI.Score += 1;
                restart         = true;
            }

            if (position.X > screen.Width - texture.Width)
            {
                player.Score += 1;
                restart       = true;
            }
        }