Beispiel #1
0
        public void PenetrationVectorSameCircleTest()
        {
            Point2 pos1 = Point2.Zero;
            Point2 pos2 = Point2.Zero;

            IShapeF shape1 = new CircleF(pos1, 2.0f);
            IShapeF shape2 = new CircleF(pos2, 2.0f);

            var actor1 = new BasicActor()
            {
                Position = pos1,
                Bounds   = shape1
            };
            var actor2 = new BasicWall()
            {
                Position = pos2,
                Bounds   = shape2
            };

            Assert.True(shape1.Intersects(shape2));
            collisionComponent.Insert(actor1);
            collisionComponent.Insert(actor2);
            collisionComponent.Update(_gameTime);
            Assert.True(Math.Abs(actor1.Position.Y - -4f) < float.Epsilon);
        }
Beispiel #2
0
        protected override void Update(GameTime gameTime)
        {
            UpdateControlledBall(gameTime, _controllableBall);

            foreach (var actor in _actors)
            {
                actor.Update(gameTime);
            }
            _collisionComponent.Update(gameTime);
            base.Update(gameTime);
        }
Beispiel #3
0
        public override void Update(GameTime gameTime)
        {
            var keyboardState = KeyboardExtended.GetState();

            if (keyboardState.WasKeyJustDown(Keys.Escape))
            {
                ScreenManager.LoadScreen(new TitleScreen(Game), new ExpandTransition(GraphicsDevice, Color.Black));
            }

            entityManager.Update(gameTime);
            collisionComponent.Update(gameTime);
        }
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            _gameObjects.ForEach(delegate(GameObject gameObject) { gameObject.Update(gameTime); });
            _collisionComponent.Update(gameTime);

            base.Update(gameTime);
        }
Beispiel #5
0
        public void Update(GameTime gameTime)
        {
            foreach (var entity in _entities.Where(e => !e.IsDestroyed))
            {
                entity.Update(gameTime);
            }
            _collisionSpace.Update(gameTime);

            foreach (var e in _entities.Where(e => e.IsDestroyed).ToList())
            {
                _entities.Remove(e);
                if (e is ICollisionActor actor)
                {
                    _collisionSpace.Remove(actor);
                }
            }
        }
Beispiel #6
0
        public void Update(GameTime gameTime)
        {
            _player.Update(gameTime);
            // Updates all ShipComponents on the screen
            foreach (IEntity entity in _entities)
            {
                if (entity is ShipComponent b)
                {
                    UpdateShipComponent(b, gameTime);
                    continue;
                }
                entity.Update(gameTime);
            }
            // Update for TileMap
            _tiledMapRenderer.Update(gameTime);
            // Update used for Collision Detection
            _collisionComponent.Update(gameTime);
            _playerInventoryHud.Update(gameTime);
            _toolboxInventoryHud.Update(gameTime);
            _healthBar.UpdateHp(_player.GetHealthPercentage());

            UpdateBreakEvent((float)gameTime.ElapsedGameTime.TotalSeconds);
            UpdateBrokenList();
        }