private static void Main(string[] args) { var start = new Point(0, 1, 0); Tuple velocity = new Vector(1, 1.8, 0).Normalize(); velocity *= 11.25; var gravity = new Vector(0, -0.1, 0); var wind = new Vector(-0.01, 0, 0); var environment = new ProjectileEnvironment(gravity, wind); var projectile = new Projectile.Lib.Projectile(start, velocity); var canvas = new Canvas(900, 550); while (projectile.Position.Y > 0) { var x = (int)projectile.Position.X; var y = (int)(canvas.Height - projectile.Position.Y); canvas[x, y] = Colors.Green; projectile = RenderCycle.Tick(environment, projectile); } var formatter = new PPMImageFormatter(); var image = (PPMImage)formatter.CreateImage(canvas); File.WriteAllText("projectile.ppm", image.Content); Process.Start("explorer", "projectile.ppm"); System.Console.WriteLine("Done"); System.Console.ReadLine(); }
public Canvas Tick(int x, int y) { var environment = new ProjectileEnvironment(_gravity, _wind); var projectile = new Projectile.Lib.Projectile(_start, _velocity); var canvas = new Canvas(x, y); while (projectile.Position.Y > 0) { var X = (int)projectile.Position.X; var Y = (int)(canvas.Height - projectile.Position.Y); canvas[X, Y] = Colors.Green; projectile = RenderCycle.Tick(environment, projectile); } return(canvas); }
private static void Main(string[] args) { var environment = new ProjectileEnvironment(new Vector(0, -0.1, 0), new Vector(-0.01, 0, 0)); var projectile = new Lib.Projectile(new Point(0, 1, 0), new Vector(10, 15, 0).Normalize()); while (projectile.Position.Y > 0) { ConsoleHelpers.Log(projectile); projectile = RenderCycle.Tick(environment, projectile); } ConsoleHelpers.Log(projectile); System.Console.WriteLine("Done"); System.Console.ReadLine(); }