public void Draw(RenderTarget target, RenderStates states) { Sprite.Origin = new Vector2f(Sprite.Texture.Size.X / 2, Sprite.Texture.Size.Y / 2); Sprite.Rotation = body.Rotation * 180 / (float)Math.PI; Sprite.Position = Vector2fExtensions.toVector2f(body.Position); Sprite.Draw(target, states); }
public void Draw(RenderTarget target, RenderStates states) { float _temp = statemachine.CurrentState.Animation.PixelSize; PlayerSprite.Origin = new Vector2f(_temp / 2, _temp / 2); PlayerSprite.Position = Vector2fExtensions.toVector2f(body.Position); PlayerSprite.Rotation = MathHelper.ToDegrees(body.Rotation); PlayerSprite.Draw(target, states); }
public void Execute(Player p) { Vector2 caSim = Vector2fExtensions.ToSimVector(ca.Strength); Vector2 dif = p.body.Position - caSim; dif.Normalize(); float angle = (float)(Math.Atan2(dif.X, dif.Y) * -1); p.body.Rotation = angle - (float)Math.PI / 2; }
public CollectableBullet(Vector2 position, float rotation, World world, Texture texture) { this.body = FarseerPhysics.Factories.BodyFactory.CreateCircle(world, ConvertUnits.ToSimUnits(10), 10); this.body.BodyType = BodyType.Static; this.body.IsSensor = true; this.body.Position = position; this.body.CollidesWith = Category.Cat2; Sprite = new Sprite(texture); Sprite.Origin += new SFML.System.Vector2f(texture.Size.X / 2, texture.Size.Y / 2); Sprite.Position = Vector2fExtensions.ToSf(position); Sprite.Rotation = rotation; this.body.OnCollision += Body_OnCollision; }
public void _Execute(Player p) { Vector2f dif = Vector2fExtensions.ToSf(p.body.Position); ca.Strength -= dif; Vector2 caSim = Vector2fExtensions.ToSimVector(ca.Strength); caSim -= p.body.Position; float angle = (float)(Math.Atan2(caSim.X - p.body.WorldCenter.X, caSim.Y - p.body.WorldCenter.Y) * -1); p.Rotate(angle); p.CursorPosition = ca.Strength + dif; }
public void calculatePathToSimTargetUsingAStart(Vector2 position, Manhatten <Tile, Object> aStar) { playerPosition = position; List <Point> backupPath = Path; Vector2f startVector = Vector2fExtensions.ToSf(this.body.Position); Vector2f endVector = Vector2fExtensions.ToSf(position); Point start = new Point((int)startVector.X / 32, (int)startVector.Y / 32); Point end = new Point((int)endVector.X / 32, (int)endVector.Y / 32); LinkedList <Tile> path = aStar.Search(start, end, null); Path = new List <Point>(); if (path != null) { foreach (Tile t in path) { Path.Add(new Point(t.X, t.Y)); } } else { Path = backupPath; } }