public void KinectUpdate(KinectData kinectData) { idleShoulderHeight = kinectData.PersonIdleHeight; spaceRequiredToJump = idleShoulderHeight + GameConstants.PlayerForwardJumpModifier; spaceRequiredToSideJump = idleShoulderHeight + GameConstants.PlayerSideJumpModifier; if (kinectData.Skeleton != null) { CheckPlayerStance(kinectData.Skeleton); } }
/// <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() { LoadConfigFile(); graphics.PreferredBackBufferWidth = GameConstants.HorizontalGameResolution; graphics.PreferredBackBufferHeight = GameConstants.VerticalGameResolution; graphics.IsFullScreen = GameConstants.IsGameInFullScreen; IsMouseVisible = GameConstants.IsMouseVisible; graphics.ApplyChanges(); kinectData = new KinectData(); camera = new Camera(graphics); if (kinectData.IsKinectConnected) { try { kinectData.KinectSensor.AllFramesReady += KinectAllFramesReady; kinectData.KinectSensor.SkeletonStream.Enable(); kinectData.KinectSensor.Start(); } catch { } } mainMenu = new MainMenu(this) {IsGameInMenuMode = true}; kinectPlayer = new KinectPlayer(new Vector3(GameConstants.FirstPlatformPosition + (GameConstants.RowLength/2)*GameConstants.SpaceBetweenPlatforms,GameConstants.PlatformGroundLevel,GameConstants.BeginningOfBoardPositionZ)); platformList = new List<Platform>(); platformGenerator=new PlatformCollection(); TargetElapsedTime = TimeSpan.FromSeconds(1.0f / GameConstants.GameUpdatesPerSecond); PreparePlatformsForNewGame(); base.Initialize(); }
public void KinectUpdate(KinectData kinectData) { if (kinectData.Skeleton!= null) { idlePersonHeight = kinectData.PersonIdleHeight; kinectHandPosition[(int)GameConstants.Hand.Left].X = ((0.5f * kinectData.Skeleton.Joints[JointType.HandLeft].Position.X) + 0.5f) * GameConstants.HorizontalGameResolution; kinectHandPosition[(int)GameConstants.Hand.Left].Y = ((-0.5f * kinectData.Skeleton.Joints[JointType.HandLeft].Position.Y) + 0.5f + 0.3f * idlePersonHeight) * GameConstants.VerticalGameResolution; kinectHandPosition[(int)GameConstants.Hand.Right].X = ((0.5f * kinectData.Skeleton.Joints[JointType.HandRight].Position.X) + 0.5f) * GameConstants.HorizontalGameResolution; kinectHandPosition[(int)GameConstants.Hand.Right].Y = ((-0.5f * kinectData.Skeleton.Joints[JointType.HandRight].Position.Y) + 0.5f + 0.3f * idlePersonHeight) * GameConstants.VerticalGameResolution; CheckCurrentInputOnButton(); handSprite[(int)GameConstants.Hand.Left, handTextureType[(int)GameConstants.Hand.Left]].rectangle.X = (int)kinectHandPosition[(int)GameConstants.Hand.Left].X; handSprite[(int)GameConstants.Hand.Left, handTextureType[(int)GameConstants.Hand.Left]].rectangle.Y = (int)kinectHandPosition[(int)GameConstants.Hand.Left].Y; handSprite[(int)GameConstants.Hand.Right, handTextureType[(int)GameConstants.Hand.Right]].rectangle.X = (int)kinectHandPosition[(int)GameConstants.Hand.Right].X; handSprite[(int)GameConstants.Hand.Right, handTextureType[(int)GameConstants.Hand.Right]].rectangle.Y = (int)kinectHandPosition[(int)GameConstants.Hand.Right].Y; } }