public StarlingGameSpriteWithJeep()
        {
            this.autorotate = true;

            var textures = new StarlingGameSpriteWithJeepTextures(new_tex_crop);

            this.onbeforefirstframe += delegate
            {
                //peds.Add(imgstand);

                //var count = 12;
                var count = 8;

                for (int i = 0; i < count; i++)
                {
                    for (int yi = 0; yi < count; yi++)
                    {
                        var visual0 = new VisualJeep(textures, this);


                        visual0.SetPositionAndAngle(
                            i * 512, yi * 512,
                            random.NextDouble()
                            );
                    }
                }

                //var t0 = new Quad(32, 32, 0).AttachTo(
                //                    Content
                //    //q
                //                );
            };
        }
        public StarlingGameSpriteWithJeep()
        {
            this.autorotate = true;

            var textures = new StarlingGameSpriteWithJeepTextures(new_tex_crop);

            this.onbeforefirstframe += delegate
            {


                //peds.Add(imgstand);

                //var count = 12;
                var count = 8;

                for (int i = 0; i < count; i++)
                    for (int yi = 0; yi < count; yi++)
                    {
                        var visual0 = new VisualJeep(textures, this);


                        visual0.SetPositionAndAngle(
                            i * 512, yi * 512,
                            random.NextDouble()
                        );




                    }

                //var t0 = new Quad(32, 32, 0).AttachTo(
                //                    Content
                //    //q
                //                );

            };

        }
        public PhysicalJeep(StarlingGameSpriteWithJeepTextures textures, StarlingGameSpriteWithPhysics Context)
        {
            this.CurrentInput = new KeySample();
            this.CameraRotation = Math.PI / 2;

            this.textures = textures;
            this.driverseat = new DriverSeat();
            this.Context = Context;

            visual0 = new VisualJeep(textures, Context);

            for (int i = 0; i < 7; i++)
            {
                this.KarmaInput0.Enqueue(
                    new KeySample()
                );
            }

            Func<double, double, double[]> ff = (a, b) => { return new double[] { a, b }; };


            {
                xwheels = new[] { 
                        //top left
                        new Wheel { b2world = Context.groundkarma_b2world, x = -1.1, y = -1.2, width = 0.4, length = 0.8, revolving = true, powered = true },

                        //top right
                        new Wheel{b2world= Context.groundkarma_b2world, x =1.1,  y =-1.2,  width =0.4,  length =0.8,  revolving =true,  powered =true},


                        //back left
                        new Wheel{b2world= Context.groundkarma_b2world, x =-1.1,  y =1.2,  width =0.4,  length =0.8,  revolving =false,  powered =false},

                        //back right
                        new Wheel{b2world= Context.groundkarma_b2world, x =1.1,  y =1.2,  width =0.4,  length =0.8,  revolving =false,  powered =false},
                    };



                karmaunit4_physics = new Car(
                   b2world: Context.groundkarma_b2world,
                   width: 2,
                   length: 4,
                   position: ff(0, 0),
                   angle: 180,

                   // how fast can the jeep go?
                   power: 120,
                   max_speed: 120,

                   max_steer_angle: 33,
                    //max_steer_angle: 40,

                   wheels: xwheels
               );

            }

            {


                xwheels = new[] { 
                        //top left
                        new Wheel { b2world = Context.ground_b2world, x = -1.1, y = -1.2, width = 0.4, length = 0.8, revolving = true, powered = true },

                        //top right
                        new Wheel{b2world= Context.ground_b2world, x =1.1,  y =-1.2,  width =0.4,  length =0.8,  revolving =true,  powered =true},


                        //back left
                        new Wheel{b2world= Context.ground_b2world, x =-1.1,  y =1.2,  width =0.4,  length =0.8,  revolving =false,  powered =false},

                        //back right
                        new Wheel{b2world= Context.ground_b2world, x =1.1,  y =1.2,  width =0.4,  length =0.8,  revolving =false,  powered =false},
                    };



                unit4_physics = new Car(
                    b2world: Context.ground_b2world,
                    width: 2,
                    length: 4,
                    position: ff(0, 0),
                    angle: 180,

                    // how fast can the jeep go?
                    power: 120,
                    max_speed: 120,

                    max_steer_angle: 33,
                    //max_steer_angle: 40,

                    wheels: xwheels
                );

                var fix = unit4_physics.fix;
                var fix_data = new Action<double>(
                    jeep_forceA =>
                    {
                        if (jeep_forceA < 1)
                            return;

                        if (oncollision != null)
                            oncollision(this, jeep_forceA);
                    }
                );
                fix.SetUserData(fix_data);


                xwheels[0].setAngle += a =>
                {
                    var cm = new Matrix();
                    cm.translate(-2, -2);
                    cm.scale(2, 4);
                    cm.rotate(a.DegreesToRadians());

                    cm.translate(-18, -20);

                    visual0.tire0.transformationMatrix = cm;
                };

                xwheels[1].setAngle += a =>
                {

                    var cm = new Matrix();
                    cm.translate(-2, -2);
                    cm.scale(2, 4);
                    cm.rotate(a.DegreesToRadians());

                    cm.translate(18, -20);

                    visual0.tire1.transformationMatrix = cm;
                };
            }

            {
                //initialize body
                var def = new b2BodyDef();
                def.type = b2Body.b2_dynamicBody;
                def.linearDamping = 0.55;  //gradually reduces velocity, makes the car reduce speed slowly if neither accelerator nor brake is pressed
                def.bullet = true; //dedicates more time to collision detection - car travelling at high speeds at low framerates otherwise might teleport through obstacles.
                def.angularDamping = 0.3;

                this.damagebody = Context.damage_b2world.CreateBody(def);

                //initialize shape
                var fixdef = new b2FixtureDef();
                fixdef.density = 1.0;
                fixdef.friction = 0.3; //friction when rubbing agaisnt other shapes
                fixdef.restitution = 0.4;  //amount of force feedback when hitting something. >0 makes the car bounce off, it's fun!

                var fixdef_shape = new b2PolygonShape();

                fixdef.shape = fixdef_shape;
                fixdef_shape.SetAsBox(2 / 2, 4 / 2);
                var fix = damagebody.CreateFixture(fixdef);

            }

            Context.internalunits.Add(this);

        }