public static GameObject BuildActionProjectile( Game1 game, GameObject parent, ActionInfo actInfo, Vector2 position, Vector2 velocity, int lifetime, List<Shape> boundingBoxes) { GameObject entity = new GameObject(game); entity.SetParent(parent); Transform2DComponent transformComponent = new Transform2DComponent( entity, position, 0.0f, Vector2.One); BoundingBoxComponent bbComponent = new BoundingBoxComponent(entity, boundingBoxes, true); CurrentActionComponent caComponent = new CurrentActionComponent( entity, new ActionComponent(DirectionalAction.Left, SecondaryAction.Stand, PrimaryAction.None), new Dictionary<ActionDefinition, ActionInfo>()); LifetimeComponent lifetimeComponent = new LifetimeComponent(entity, lifetime); IsActionComponent isActionComponent = new IsActionComponent(entity, actInfo); MotionPropertiesComponent motionComponent = new MotionPropertiesComponent(entity, 1.0f); motionComponent.SetVelocity(velocity); entity.AddComponent(transformComponent); entity.AddComponent(bbComponent); entity.AddComponent(caComponent); entity.AddComponent(motionComponent); entity.AddComponent(lifetimeComponent); entity.AddComponent(isActionComponent); return entity; }
private void resolveVelocity(MotionPropertiesComponent motionComponent, int timestep) { motionComponent.AccelerationVector = motionComponent.AggregateForcesVector / motionComponent.Mass; motionComponent.AddVelocity( motionComponent.AccelerationVector * timestep / 1000.0f ); }
public static GameObject BuildDynamicEntity( Game1 game, Vector2 position, float rotation, Vector2 scale, float maxGroundSpeed, float maxAirSpeed, SpriteType spriteType, List<Shape> boundingBoxes) { GameObject entity = new GameObject(game); Transform2DComponent transformComponent = new Transform2DComponent( entity, position, rotation, scale); SpriteComponent sprite = new SpriteComponent(entity, spriteType, game); BoundingBoxComponent bbComponent = new BoundingBoxComponent(entity, boundingBoxes, true); CurrentActionComponent caComponent = new CurrentActionComponent( entity, new ActionComponent(DirectionalAction.Left, SecondaryAction.Stand, PrimaryAction.None), new Dictionary<ActionDefinition, ActionInfo>()); GravityComponent gravComponent = new GravityComponent(entity, 1.0f); MotionPropertiesComponent motionComponent = new MotionPropertiesComponent( entity, 1.0f, maxGroundSpeed, maxAirSpeed); IsPhysicalComponent isPhysicalComponent = new IsPhysicalComponent(entity, true); IsCharacterComponent isCharComponent = new IsCharacterComponent(entity); SoundComponent soundComponent = new SoundComponent(entity); entity.AddComponent(transformComponent); entity.AddComponent(sprite); entity.AddComponent(bbComponent); entity.AddComponent(caComponent); entity.AddComponent(gravComponent); entity.AddComponent(motionComponent); entity.AddComponent(isPhysicalComponent); entity.AddComponent(isCharComponent); entity.AddComponent(soundComponent); return entity; }