예제 #1
0
        public Player() : base(EntityTypes.Player)
        {
            LoadAnimations("PlayerAnimations.json");
            PlayAnimation("Idle");

            playerData = new PlayerData();

            Body                    = PhysicsFactory.CreateRectangle(PlayerWidth, PlayerHeight, Units.Pixels, BodyType.Dynamic, this);
            Body.Friction           = 0;
            Body.ManuallyControlled = true;
            Body.MaximumSpeed       = new Vector2(PhysicsConvert.ToMeters(playerData.MaxSpeed), float.PositiveInfinity);

            idle = true;

            MessageSystem.Subscribe(MessageTypes.Keyboard, this);
            MessageSystem.Subscribe(MessageTypes.Mouse, this);
        }
예제 #2
0
        private void CreateBodies(Edge[][] edges)
        {
            bodies = new Body[edges.Length];

            for (int i = 0; i < edges.Length; i++)
            {
                Body   body      = PhysicsFactory.CreateBody(this);
                Edge[] edgeArray = edges[i];

                foreach (Edge edge in edgeArray)
                {
                    PhysicsFactory.AttachEdge(body, edge, Units.Meters, edge);
                }

                body.CollisionCategories = (Category)PhysicsGroups.World;
                bodies[i] = body;
            }
        }
예제 #3
0
        public override void Initialize(Camera camera)
        {
            World world = new World(new Vector2(0, Gravity));

            PhysicsFactory.Initialize(world);

            scene       = new Scene();
            accumulator = new PhysicsAccumulator(world);

            Enemy archer = new Archer();

            archer.Position = new Vector2(-200);

            Player player = new Player();

            player.Position = new Vector2(200);

            scene.Add(0, player);
            scene.Add(0, archer);
        }
예제 #4
0
파일: Game.cs 프로젝트: lede701/SharpEngine
        public virtual void InitializeGame()
        {
            // Setup world global object


            // Initialize GTraphics Manager
            _gm = new GraphicsManager(this);
            _sm = SceneManager.Instance;
            Scene top = new Scene();

            _sm.Add(top);

            // Start the game loop thread
            _gameLoop = ThreadManager.CreateThread(GameLoop);
            _gameLoop.Start();


            AssetsPath = Application.ExecutablePath + "\\Content";
            if (!Directory.Exists(AssetsPath))
            {
                // Break directory into it parts
                List <String> path = new List <String>(Application.ExecutablePath.Split('\\'));
                path.Remove(path.Last());
                // Go back a directory until we find content
                do
                {
                    path.Remove(path.Last());
                    AssetsPath = String.Format("{0}\\Content", String.Join("\\", path));
                } while (!Directory.Exists(AssetsPath) && path.Count > 0);
            }

            _physicsWorld   = new PhysicsWorld(World.WorldSize);
            _physicsFactory = new PhysicsFactory(_physicsWorld);
            if (!SingleThread)
            {
                // Start the Physics loop now that the world is created
                _physicsLoop = ThreadManager.CreateThread(PhysicsLoop);
                _physicsLoop.Start();
            }
        }
예제 #5
0
 public EntityFactory(GameWorld world)
 {
     m_world          = world;
     m_physicsFactory = new PhysicsFactory();
 }
예제 #6
0
        public void FromName_DifferentLetterCases_ShouldReturnExpectedPhysics(string name, Type expected)
        {
            var sut = new PhysicsFactory().FromName(name);

            sut.Should().BeOfType(expected);
        }