Beispiel #1
0
        public static void RunSimulation()
        {
            int currentIteration = 0;
            int maxIteration     = 60000;

            RT.Canvas canvas = new RT.Canvas(1000, 500);

            RT.Projectile projectile = new RT.Projectile(new RT.Point(0.0f, 0.0f, 0.0f),
                                                         new RT.Vector(25.0f, 50.0f, 0.0f));
            RT.Environment environment = new RT.Environment(new RT.Vector(0.0f, -3.0f, 0.0f),
                                                            new RT.Vector(0.0f, 0.0f, 0.0f));

            while (projectile.position.y >= 0.0f && currentIteration < maxIteration)
            {
                Tick(projectile, environment);
                currentIteration++;
                //Draw to canvas
                int x = (int)projectile.position.x;
                int y = (int)projectile.position.y;
                canvas.SetPixel(x, y, RT.Color.green);
            }

            if (currentIteration == maxIteration)
            {
                Console.WriteLine("Error, max iteration count exceeded.");
            }

            Console.WriteLine("--Simulation Results--");
            Console.WriteLine("Projectile: " + projectile.ToString());
            Console.WriteLine("Environment: " + environment.ToString());
            RT.Save.SaveCanvas(canvas);
        }
Beispiel #2
0
 public static void Tick(RT.Projectile proj, RT.Environment env)
 {
     proj.position = proj.position + proj.velocity;
     Console.WriteLine(proj.position);
     proj.velocity = proj.velocity + env.gravity + env.wind;
 }