예제 #1
0
        protected override void AssignResources()
        {
            world = new World(Vector2.Zero);
            GameObject.World = world;

            bug = GameObject.CreateCircular(new AnimatedSprite(ResMan.Get<Texture2D>("bug2"),4,1,"walk"), new Vector2(500, 500), BodyType.Dynamic);
            Player = Character.CreatePlayer(new Vector2(500, 500));

            floatingText = new FloatText(ResMan.GetResource<SpriteFont>("default"));

            //załozenie że są zasoby
            level.AssignResources();
            Obstacles = level.Obstacles;
        }
예제 #2
0
 public void Think(Character c)
 {
     velocity = new Vector2(10, 0) * c.PhysicsBody.Mass;
 }
예제 #3
0
        public static Character CreatePlayer(Vector2 pos)
        {
            AnimatedSprite sprite = new AnimatedSprite(ResMan.Get<Texture2D>("bug2"), 4, 1, "walk");

            Character obj = new Character(sprite, pos);
            obj.PhysicsBody.CreateFixture(new CircleShape(ConvertUnits.ToSimUnits(obj.Size.X / 2), 0));
            obj.PhysicsBody.BodyType = BodyType.Dynamic;
            obj.Health = 1000;
            obj.ai = new ManualMovementStyle();
            obj.MOVEMENT_SPEED = 80;
            obj.PhysicsBody.Mass = 100;
            obj.PhysicsBody.UserData = obj;
            obj.Relations = GameObject.Relationship.Friendly;
            obj.PhysicsBody.CollisionCategories = (Category) 0x04;
            obj.PhysicsBody.CollidesWith = (Category.All);
            return obj;
        }
예제 #4
0
        public void Think(Character c)
        {
            offset = Vector2.Zero;
            force = Vector2.Zero;
            angle = 0.0f;

            if (InMan.KeyDown(Keys.Left))
                angle = MathHelper.ToRadians(-240) / Settings.FramesPerSecond;
            if (InMan.KeyDown(Keys.Right))
                angle = MathHelper.ToRadians(+240) / Settings.FramesPerSecond;

            if (InMan.KeyDown(Keys.Up))
                force = new Vector2((float)(c.MOVEMENT_SPEED * Math.Sin(c.Rotation)), (float)(-c.MOVEMENT_SPEED * Math.Cos(c.Rotation))) * c.PhysicsBody.Mass;/// Settings.FramesPerSecond;

            if (InMan.KeyPressed(Keys.Space))
            {
                //var v = c.Position +
                c.Bullets.Add(Bullet.CreateBullet(c.Position + c.GetDirectionalVector(100), c.Rotation));

            }

            //c.MoveStraight(+220);
            /*if (InMan.KeyDown(Keys.Down))
                c.MoveStraight(-220);*/
        }
예제 #5
0
        public static Character CreateBug(Vector2 pos)
        {
            AnimatedSprite sprite = new AnimatedSprite(ResMan.Get<Texture2D>("bug"), 1, 1, "none");

            Character obj = new Character(sprite, pos);
            obj.PhysicsBody.CreateFixture(new CircleShape(ConvertUnits.ToSimUnits(obj.Size.X / 2), 0));
            obj.PhysicsBody.BodyType = BodyType.Dynamic;
            obj.Health = 100;
            obj.PhysicsBody.Mass = 200;
            obj.PhysicsBody.UserData = obj;
            obj.Relations = Relationship.Enemy;
            obj.PhysicsBody.CollisionCategories = (Category) 0x04;
            obj.PhysicsBody.CollidesWith = (Category.All);
            return obj;
        }