Example #1
0
        public Game(PongImage image)
        {
            Image = image;
            Area = new Area(this);
            Ball = new Ball(this);
            Ball.Collision += new Ball.CollisionEventHandler(Ball_Collision);
            Player1 = new Player(this, PlayerIndex.Player1);
            Player2 = new Player(this, PlayerIndex.Player2);
            Kinect = new Kinect(this);

            gameTimer = new Timer();
            gameTimer.Elapsed += new ElapsedEventHandler(gameTimer_Elapsed);
            gameTimer.Interval = 1;
            gameTimer.Start();

            gameStartTimer = new Timer();
            gameStartTimer.Elapsed += new ElapsedEventHandler(gameStartTimer_Elapsed);
            gameStartTimer.Interval = Parameters.Game.GameStartDelay * 1000;

            gameScreenshotTimer = new Timer();
            gameScreenshotTimer.Elapsed += new ElapsedEventHandler(gameScreenshotTimer_Elapsed);
            gameScreenshotTimer.Interval = Parameters.Game.ScreenshotDelay * 1000;
        }
Example #2
0
        private void skeletonMovement(Skeleton skeleton, Player player, JointType jointType)
        {
            // Map SkeletonPoint (cm) to DepthPoint (pixels)
            DepthImagePoint depthPoint = coordinateMapper.MapSkeletonPointToDepthPoint(skeleton.Joints[jointType].Position, sensor.DepthStream.Format);

            var position = new Point(depthPoint.X, depthPoint.Y);
            position.X = position.X < 0 ? 0 : position.X;
            position.X = position.X > sensor.DepthStream.FrameWidth ? sensor.DepthStream.FrameWidth : position.X;
            position.Y = position.Y < 0 ? 0 : position.Y;
            position.Y = position.Y > sensor.DepthStream.FrameHeight ? sensor.DepthStream.FrameHeight : position.Y;

            if (player.KinectPreviousPosition == null)
                player.KinectPreviousPosition = position;

            double kinectYDelta = (position.Y - player.KinectPreviousPosition.Y) * Parameters.Area.Height / sensor.DepthStream.FrameHeight * Parameters.Paddle.KinectAccelaration;

            player.TrackPointPosition = new Point(position.X * Parameters.Area.Width / sensor.DepthStream.FrameWidth,
                position.Y * Parameters.Area.Height / sensor.DepthStream.FrameHeight);

            player.KinectPreviousPosition = position;
            player.Paddle.Move(kinectYDelta);
        }
Example #3
0
 public Paddle(Game game, Player player)
 {
     this.game = game;
     this.player = player;
     YPosition = game.Area.InnerBorder.Height / 2;
 }