public StarlingGameSpriteWithCannon() { autorotate = true; var textures = new StarlingGameSpriteWithCannonTextures(new_tex_crop); onbeforefirstframe += (stage, s) => { for (int i = 0; i < 12; i++) { for (int yi = 0; yi < 12; yi++) { var rot = random.NextDouble() * Math.PI; var cannon1 = new VisualCannon(textures, this); cannon1.SetPositionAndAngle( i * 128, yi * 128, rot); } } }; }
public StarlingGameSpriteWithCannon() { autorotate = true; var textures = new StarlingGameSpriteWithCannonTextures(new_tex_crop); onbeforefirstframe += (stage, s) => { for (int i = 0; i < 12; i++) for (int yi = 0; yi < 12; yi++) { var rot = random.NextDouble() * Math.PI; var cannon1 = new VisualCannon(textures, this); cannon1.SetPositionAndAngle( i * 128, yi * 128, rot); } }; }
public PhysicalCannon(StarlingGameSpriteWithCannonTextures textures, StarlingGameSpriteWithPhysics Context) { this.CurrentInput = new KeySample(); this.driverseat = new DriverSeat(); this.Context = Context; visual = new VisualCannon(textures, Context); for (int i = 0; i < 7; i++) { this.KarmaInput0.Enqueue( new KeySample() ); } { //initialize body var bdef = new b2BodyDef(); bdef.angle = 0; bdef.fixedRotation = true; this.body = Context.ground_b2world.CreateBody(bdef); //initialize shape var fixdef = new b2FixtureDef(); var shape = new b2PolygonShape(); fixdef.shape = shape; shape.SetAsBox(2, 2); fixdef.restitution = 0.4; //positively bouncy! var fix = this.body.CreateFixture(fixdef); var fix_data = new Action<double>( jeep_forceA => { if (jeep_forceA < 1) return; Context.oncollision(this, jeep_forceA); } ); fix.SetUserData(fix_data); } { //initialize body var bdef = new b2BodyDef(); bdef.angle = 0; bdef.fixedRotation = true; this.karmabody = Context.groundkarma_b2world.CreateBody(bdef); //initialize shape var fixdef = new b2FixtureDef(); var shape = new b2PolygonShape(); fixdef.shape = shape; shape.SetAsBox(2, 2); fixdef.restitution = 0.4; //positively bouncy! this.karmabody.CreateFixture(fixdef); } Context.internalunits.Add(this); }