Example #1
0
        public GameWorld(ContentManager Content)
        {
            ballTex = Content.Load<Texture2D>("UI/lives");
            backgroundTex = Content.Load<Texture2D>("UI/background");
            startTex = Content.Load<Texture2D>("UI/startScreen");
            gameFont = Content.Load<SpriteFont>("UI/gameFont");

            MediaPlayer.Play(Content.Load<Song>("Sound/bg_music"));

            rightPlayer = new Pad(Content, 1);
            leftPlayer = new Pad(Content, 0);
            ball = new Ball(Content);
            disco = new Disco[maxDisco];

            for (int i = 0; i < maxDisco; i++)
            {
                disco[i] = new Disco(Content);
            }

            Reset(GameState.GameStart); //Sets the game to initial positions and sets correct gamestate
        }
Example #2
0
File: Game1.cs Project: CSLU/Pong
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            p = new Puck(Content, new Rectangle(0,0,this.graphics.GraphicsDevice.Viewport.Width, this.graphics.GraphicsDevice.Viewport.Height));
            leftPad = new Pad(Content, new Rectangle(0, 0, this.graphics.GraphicsDevice.Viewport.Width, this.graphics.GraphicsDevice.Viewport.Height), true);
            rightPad = new Pad(Content, new Rectangle(0, 0, this.graphics.GraphicsDevice.Viewport.Width, this.graphics.GraphicsDevice.Viewport.Height), false);

            leftScorePos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width / 10, this.graphics.GraphicsDevice.Viewport.Height * 0.02f);
            rightScorePos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width - this.graphics.GraphicsDevice.Viewport.Width / 10, this.graphics.GraphicsDevice.Viewport.Height * 0.02f);
            ballsLeftPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width/2, this.graphics.GraphicsDevice.Viewport.Height * 0.02f);
            winnerPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width/2 - 200, this.graphics.GraphicsDevice.Viewport.Height/2 - 100);
            winnerTextPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width/2, this.graphics.GraphicsDevice.Viewport.Height/2);
            ballTextPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width / 2, this.graphics.GraphicsDevice.Viewport.Height / 2 + 10);
            ballTextLabelPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width / 2, this.graphics.GraphicsDevice.Viewport.Height / 2 - 10);
            nextgameTextLabelPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width / 2, this.graphics.GraphicsDevice.Viewport.Height / 2 + 70);
            ballsLeft = BALLS_START;

            gamestate = MAIN_GAME_STATE;
            trails = new Trail[NUM_TRAILS];

            base.Initialize();
        }