public CpuGuyDecorator(Guy.Guy guy, SpriteFont font) { Guy = guy; _font = font; _controlPatterns = new CircularArray <CpuKeyboardControls>( CpuKeyboardControlsFactory.RunningCelebration(), CpuKeyboardControlsFactory.RunBackAndForth(), CpuKeyboardControlsFactory.Cannonball(), CpuKeyboardControlsFactory.JumpAndSquat()); KeyboardEventRegistry.OnKeyDown(Keys.Left, OnLeft); KeyboardEventRegistry.OnKeyDown(Keys.Right, OnRight); }
private static void keepGuyOnCamera(Guy.Guy guy, Camera camera) { //Make the level wrap around, horizontally. var cameraRect = camera.GetVisibleArea(); if (guy.Physics.Right < cameraRect.Left) { guy.Physics.Position.X = cameraRect.Right; } if (guy.Physics.Left > cameraRect.Right + 1) { //Wrap from the right to the left. guy.Physics.Position.X = cameraRect.Left - guy.Physics.Width; } }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); // var cb = Window.ClientBounds; _guy = GuyFactory.Create( GraphicsDevice, Content, new DebugLogger(), new Vector2(0, 0)); // _font = Content.Load <SpriteFont>("Consolas"); _cpuGuyDecorator = new CpuGuyDecorator(_guy, _font); }