public GameScene() { this.Camera.SetViewFromViewport(); _physics = new PongPhysics(); ball = new Ball(_physics.SceneBodies[(int)PongPhysics.BODIES.Ball]); _player = new Paddle(Paddle.PaddleType.PLAYER, _physics.SceneBodies[(int)PongPhysics.BODIES.Player]); _ai = new Paddle(Paddle.PaddleType.AI, _physics.SceneBodies[(int)PongPhysics.BODIES.Ai]); _scoreboard = new Scoreboard(); this.AddChild(_scoreboard); this.AddChild(ball); this.AddChild(_player); this.AddChild(_ai); // This is debug routine that will draw the physics bounding box around the players paddle if(DEBUG_BOUNDINGBOXS) { this.AdHocDraw += () => { var bottomLeftPlayer = _physics.SceneBodies[(int)PongPhysics.BODIES.Player].AabbMin; var topRightPlayer = _physics.SceneBodies[(int)PongPhysics.BODIES.Player].AabbMax; Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bottomLeftPlayer*PongPhysics.PtoM,topRightPlayer*PongPhysics.PtoM)); var bottomLeftAi = _physics.SceneBodies[(int)PongPhysics.BODIES.Ai].AabbMin; var topRightAi = _physics.SceneBodies[(int)PongPhysics.BODIES.Ai].AabbMax; Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bottomLeftAi*PongPhysics.PtoM,topRightAi*PongPhysics.PtoM)); var bottomLeftBall = _physics.SceneBodies[(int)PongPhysics.BODIES.Ball].AabbMin; var topRightBall = _physics.SceneBodies[(int)PongPhysics.BODIES.Ball].AabbMax; Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bottomLeftBall*PongPhysics.PtoM,topRightBall*PongPhysics.PtoM)); }; } //Now load the sound fx and create a player _pongSound = new Sound("/Application/audio/pongblip.wav"); _pongBlipSoundPlayer = _pongSound.CreatePlayer(); Scheduler.Instance.ScheduleUpdateForTarget(this,0,false); }
public GameScene(bool localMultiplayer) { this.Camera.SetViewFromViewport(); m_physics = new PongPhysics(); m_ball = new Ball(m_physics.SceneBodies[(int)PongPhysics.BODIES.Ball]); if (localMultiplayer == true) { m_player1 = new Paddle(Paddle.PaddleType.PLAYER1, m_physics.SceneBodies[(int)PongPhysics.BODIES.Player1]); m_player2 = new Paddle(Paddle.PaddleType.PLAYER2, m_physics.SceneBodies[(int)PongPhysics.BODIES.Player2]); this.AddChild(m_player1); this.AddChild(m_player2); } else { m_player1 = new Paddle(Paddle.PaddleType.PLAYER1, m_physics.SceneBodies[(int)PongPhysics.BODIES.Player1]); m_ai = new Paddle(Paddle.PaddleType.AI, m_physics.SceneBodies[(int)PongPhysics.BODIES.Ai]); this.AddChild(m_player1); this.AddChild(m_ai); } m_scoreboard = new Scoreboard(); this.AddChild(m_scoreboard); this.AddChild(m_ball); // This is debug routine that will draw the physics bounding box around the players paddle if (DEBUG_BOUNDINGBOXS) { this.AdHocDraw += () => { var bottomLeftPlayer = m_physics.SceneBodies[(int)PongPhysics.BODIES.Player1].AabbMin; var topRightPlayer = m_physics.SceneBodies[(int)PongPhysics.BODIES.Player1].AabbMax; Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bottomLeftPlayer * PongPhysics.PtoM, topRightPlayer * PongPhysics.PtoM)); var bottomLeftPlayer2 = m_physics.SceneBodies[(int)PongPhysics.BODIES.Player2].AabbMin; var topRightPlayer2 = m_physics.SceneBodies[(int)PongPhysics.BODIES.Player2].AabbMax; Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bottomLeftPlayer2 * PongPhysics.PtoM, topRightPlayer2 * PongPhysics.PtoM)); var bottomLeftAi = m_physics.SceneBodies[(int)PongPhysics.BODIES.Ai].AabbMin; var topRightAi = m_physics.SceneBodies[(int)PongPhysics.BODIES.Ai].AabbMax; Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bottomLeftAi * PongPhysics.PtoM, topRightAi * PongPhysics.PtoM)); var bottomLeftBall = m_physics.SceneBodies[(int)PongPhysics.BODIES.Ball].AabbMin; var topRightBall = m_physics.SceneBodies[(int)PongPhysics.BODIES.Ball].AabbMax; Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bottomLeftBall * PongPhysics.PtoM, topRightBall * PongPhysics.PtoM)); }; } //Now load the sound fx and create a player m_pongSound = new Sound("/Application/audio/pongblip.wav"); m_pongBlipSoundPlayer = m_pongSound.CreatePlayer(); Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false); }