Exemplo n.º 1
0
        public Point[] LightSaberPos= new Point[2]; //highest top point & lower hand position  

        public MotionTracker(Game game, KinectTracker tracker, Players player)
            : base(game)
        {
            this.game = game;
            this.player = player;
            this.tracker = tracker;
            contentManager = new ContentManager(game.Services);
      
        }
Exemplo n.º 2
0
        G2D_Bar bar2D; // 宣告一個長條圖物件

        //G2D_Sprite_Bullet bullet; // 宣告一個物件
        //Texture2D myBullet; // 宣告一個2D紋理圖
        //KeyboardState oldKey;
        //List<G2D_Sprite_Bullet> bulletList = new List<G2D_Sprite_Bullet>(); // 紀錄子彈的動態陣列

        //G2D_Sprite_Explore2 myExplore2;
        //end

        public GamePong()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            tracker = new KinectTracker();
            player = new Players(this, tracker);
            ball = new Ball(this, tracker);
            paddle = new Paddle(this, tracker);
            motion = new MotionTracker(this, tracker, player); //motion detect and draw


            Components.Add(ball);
            Components.Add(paddle);
            //Components.Add(player);
            //Components.Add(motion);

            ball.CollisionSquare = paddle;

            //box2d1 = new Drawbar(this);
            //box2d2 = new Drawbar(this);

            //Components.Add(box2d1);
            //Components.Add(box2d2);


            //Player


            this.IsMouseVisible = true;
            this.Window.AllowUserResizing = true;

            // Call Window_ClientSizeChanged when screen size is changed
            Window.AllowUserResizing = true;
            Window.ClientSizeChanged += new EventHandler<EventArgs>(Window_ClientSizeChanged);


            //Kinect
            tracker.GamingState = KinectTracker.GamingStates.KinectPaddleBall;
            if (!tracker.isKinectDeviceReady)
            {
                tracker.GamingState = KinectTracker.GamingStates.PaddleBall;
                //Show Error Dialog
                Button btnOK = new Button();
                btnOK.Text = "Please check Kinect!!";
                btnOK.Width = 100; btnOK.Height = 60;
                btnOK.Left = 50;  btnOK.Top=50;

                System.Windows.Forms.Form winForm = new System.Windows.Forms.Form();
                winForm.Text = "Kinect device error!";
                winForm.Controls.Add(btnOK);
                winForm.ShowDialog();
                //Environment.Exit(-1);
            }
        }