private void AddInput() { Input = new InputManager(); Input.AddAxis("UpDown", Keys.S, Keys.W); Input.AddAxis("LeftRight", Keys.D, Keys.A); Input.Owner = this; }
public SmileyWalkDude() : base() { // get the animation texture _smileyWalkTexture = ContentLoader.Content.Load<Texture2D>(Assets.SMILEY_WALK); // make the animator Animation standing = new Animation(_smileyWalkTexture, 300, 4, 4, 2); Animation walking = new Animation(_smileyWalkTexture, 300, 4, 4, 16, true); anim = new Animator(standing); anim.AddAnimation(AnimationNames.WALKING, walking); anim.DrawOrder = 5; AddComponent(anim); // make the body body = new Body(); body.Resistance = 0.9f; AddComponent(body); // make the collider collider = new BoxCollider(new Point(anim.Width * 5, anim.Height * 5)); collider.WireFrame = WireFrames.BoxWireFrame(collider.Bounds); AddComponent(collider); collider.CollisionStart += UpdateMessage; collider.CollisionEnd += UpdateMessage; // make the input input = new InputManager(); input.AddAxis(InputNames.X_AXIS, Keys.D, Keys.A); input.AddAxis(InputNames.Y_AXIS, Keys.S, Keys.W); AddComponent(input); }
private void SetUpWorldObjects() { // get user input object Input = new InputManager(); Input.AddBinding(PAUSE, Keys.Escape); Input.AddBinding(TOGGLE_OFFSET, Keys.T); Add(Input); // create the center marker CenterMarker = new Sprite(ContentLoader.Content.Load<Texture2D>("ItemGlimer")); CenterMarker.Center(); CenterMarker.Scale = new Vector2(0.1f, 0.1f); CenterMarker.Position = new Vector2(1920 / 2, 1080 / 2); CenterMarker.Color = Color.Red; Add(CenterMarker); // create the center colliders centerCircleCollider = new CircleCollider(100); centerCircleCollider.WireFrame = WireFrames.CircleWireFrame(centerCircleCollider.Bounds); centerCircleCollider.Position = new Vector2(1920 / 2, 1080 / 2); Add(centerCircleCollider); centerBoxCollider = new BoxCollider(new Point(200, 200)); centerBoxCollider.WireFrame = WireFrames.BoxWireFrame(centerBoxCollider.Bounds); centerBoxCollider.Position = new Vector2(1920 / 2, 1080 / 2); centerBoxCollider.Center(); //Add(centerBoxCollider); // create the screen size marker ScreenSizeMarker = new Sprite(ContentLoader.Content.Load<Texture2D>("ItemGlimer")); ScreenSizeMarker.Center(); ScreenSizeMarker.Scale = new Vector2(0.1f, 0.1f); ScreenSizeMarker.Position = new Vector2(1920, 1080); ScreenSizeMarker.Color = Color.Red; Add(ScreenSizeMarker); // create smiley smiley = new SmileyWalkDude(); smiley.Position = new Vector2(1920 / 4, 1080 / 4); Add(smiley); // create the instruction text instructions = new InstructionText("Move the Character off of the screen to continue."); instructions.Position = new Vector2(200, 50); instructions.DrawOrder = 1; Add(instructions); // create the outerBounds Point size = new Point(1920 - 10, 1080 - 10); outerBounds = new Corral(size, smiley); outerBounds.Position = new Vector2(5, 5); Add(outerBounds); }