public override void DrawSolidCircle(Vec2 center, float radius, Box2DX.Common.Vec2 axis, Color color) { float k_segments = 16.0f; float k_increment = 2.0f * (float)System.Math.PI / k_segments; float theta = 0.0f; GL.Color3(0.5f * color.R, 0.5f * color.G, 0.5f * color.B); GL.Disable(EnableCap.Texture2D); GL.Begin(BeginMode.TriangleFan); for (int i = 0; i < k_segments; ++i) { Vec2 v = center + radius * new Vec2((float)System.Math.Cos(theta), (float)System.Math.Sin(theta)); GL.Vertex3(v.X, v.Y, ZLayer); theta += k_increment; } GL.End(); theta = 0.0f; GL.Color4(color.R, color.G, color.B, 1.0f); GL.Begin(BeginMode.LineLoop); for (int i = 0; i < k_segments; ++i) { Vec2 v = center + radius * new Vec2((float)System.Math.Cos(theta), (float)System.Math.Sin(theta)); GL.Vertex3(v.X, v.Y, ZLayer); theta += k_increment; } GL.End(); Vec2 p = center + radius * axis; GL.Begin(BeginMode.Lines); GL.Vertex3(center.X, center.Y, ZLayer); GL.Vertex3(p.X, p.Y, 0); GL.End(); GL.Enable(EnableCap.Texture2D); }
public void addParticle(Box2DX.Common.Vec2 pos) { if (inactiveParticles.Count != 0) { Particle p = inactiveParticles.Dequeue(); p.pos = new Vector2(pos.X, pos.Y); p.life = particleLife; } }
public override void DrawSegment(Vec2 p1, Box2DX.Common.Vec2 p2, Color color) { GL.Color3(color.R, color.G, color.B); GL.Disable(EnableCap.Texture2D); GL.Begin(BeginMode.Lines); { GL.Vertex3(p1.X, p1.Y, ZLayer); GL.Vertex3(p2.X, p2.Y, ZLayer); } GL.End(); GL.Enable(EnableCap.Texture2D); }
public void OnContactRemove(Box2DX.Collision.Shape _other, Box2DX.Collision.Shape _self, ContactPoint _point) { // if (wheel == _self) { //only when the tile is left which was just hit if (_lastContact == _other) { isOnGround = false; } } }
public void OnContact(Box2DX.Collision.Shape _other, Box2DX.Collision.Shape _self, ContactPoint _point) { if (wheel == _self) { _lastContact = _other; isOnGround = true; JumptimePassed = 0; } else if(head == _self && Physics.ContactManager.g_contactManager.isLethal(_other)) { isDead = true; } }
void GetSegment(int i, ref Box2DX.Collision.Segment s) { float a = (-p.fov_deg * (-0.5f + i / (p.num_rays - 1f)) + p.dir_deg) * Helper.angle_to_rad; float sin = (float)System.Math.Sin(a), cos = (float)System.Math.Cos(a); var v0 = new Vec2(p.d0 * sin, p.d0 * cos); var v = new Vec2(p.dist * sin, p.dist * cos); s.P1 = parent_car.body.GetWorldPoint(v0) + parent_car.body.GetWorldVector(new Vec2(p.x0, p.y0)); s.P2 = s.P1 + parent_car.body.GetWorldVector(v); }
public LaserObject(Box2DX.Dynamics.World myWorld, DudeObject myDude, string sectionTexturename, int amnSections) { world = myWorld; dude = myDude; sectionTex = GameEngine.TextureList[sectionTexturename]; sectionTextureName = sectionTexturename; numSections = amnSections; sections = new Vector2[numSections]; currentSection = 0; sectionTimer = 0; lambda = 0; amDrawing = false; amErasing = false; interference = new Box2DX.Collision.Shape[3]; //interference.Initialize(); SCALE = CASSWorld.SCALE; primitiveBatch = new PrimitiveBatch(GameEngine.Instance.GraphicsDevice); //animation stuff myGameTime = 0; animateTimer = 0; animateInterval = 20; xFrame = 0; yFrame = 0; numFrames = 8; spriteWidth = 50; spriteHeight = 512; sourceRect = new Rectangle(xFrame * spriteWidth, yFrame * spriteHeight, spriteWidth, spriteHeight); origin = new Vector2(sourceRect.Width / 2, sourceRect.Height / 2); }