/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("Score"); Texture2D texture = Content.Load <Texture2D>("leeks"); Texture2D bee = Content.Load <Texture2D>("beemanrun"); Texture2D wallTexture = Content.Load <Texture2D>("wall"); Texture2D grassTexture = Content.Load <Texture2D>("grass"); _player = new Player(texture); // TODO: use this.Content to load your game content here _world = new World(Content, _player); _itemDrop = new ItemDrop("heartfloat", Content); //_enemy = new Enemy(bee, 1, 4, 12,); _tileArray = _world._activeRoom; _gameOptions = new GameOptions(); _scale = _gameOptions.scale; _camera = new Camera(GraphicsDevice.Viewport); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { KeyboardState state = Keyboard.GetState(); var padState = GamePad.GetState(PlayerIndex.One); var collision = new Collision(_tileArray); var colCheck = collision.CheckCollision(_player, _world); _tileArray = _world._activeRoom; var playerMoving = _player.Input(state, padState, colCheck); // TODO: Add your update logic here _world.WorldUpdate(); score++; if (playerMoving) { _player.animatedSprite.Update(); } if (_itemDrop != null) { _itemDrop.animatedSprite.Update(); } //_enemy.animatedSprite.Update(); base.Update(gameTime); //var inDistance = checkDistance(_enemy.position, _player.position); //_enemy.Walk(_player.position, inDistance); if (_itemDrop != null) { var inDistance = checkDistance(_itemDrop.position, _player.position); var pickUp = _itemDrop.PickUp(_player, inDistance); if (pickUp) { _itemDrop = null; } } _camera.Update(_player.position); }