Ejemplo n.º 1
0
 public static void Start()
 {
     Tortoise.Show();
     Tortoise.SetSpeed(10);
     CreateColorPalette();
     DrawPentagon();
 }
Ejemplo n.º 2
0
        private static void CreateMonsters()   // Just because i want random kind of monsters, in different lvls i go through this loop. And the settings gives them random lvls and names.
        {
            for (int i = 0; i < 15; i++)
            {
                Dragon dragon = new Dragon();
                fireMonsters.Add(dragon);

                Demon demon = new Demon();
                fireMonsters.Add(demon);

                Tortoise tortoise = new Tortoise();
                waterMonsters.Add(tortoise);

                SwampTroll troll = new SwampTroll();
                waterMonsters.Add(troll);

                Crocodile croc = new Crocodile();
                waterMonsters.Add(croc);

                RabiesBear bear = new RabiesBear();
                grassMonsters.Add(bear);

                Wasp wasp = new Wasp();
                grassMonsters.Add(wasp);

                Scarab scarab = new Scarab();
                grassMonsters.Add(scarab);
            }

            DragonLord dL = new DragonLord();  // but only one dragon lord.

            fireMonsters.Add(dL);
        }
Ejemplo n.º 3
0
        public static void Main2()
        {
            Tortoise.Show();
            Tortoise.SetSpeed(10);
            Tortoise.InstantSpeed(false);
            //var sides = MessageBox.AskForInput("Hány oldal legyen?"); // int - integer - egész szám
            var sides = 25;

            //Tortoise.SetPenColor(Colors.GetRandomColor());
            for (int i = 0; i < sides; i = i + 1)
            {
                var color = Colors.GetRandomColor();
                Tortoise.SetPenColor(color); // string - szöveg
                Tortoise.SetPenWidth(i * 2);
                Tortoise.Move(i * 1.5);
                Tortoise.Turn(-3 * 360.0 / sides);

                //string s1 = 'a'.ToString();
                //char c1 = 'a';

                //string sdf = "" + 3;
                // 360.0 / 13;
                // 360.0 / 13.0;


                //new Random().Next();

                // 360  /13 => int    / int => 27
                // 360.0/13 => double / int => 27.69...

                // 360   - int
                // 360.0 - double
            }
        }
Ejemplo n.º 4
0
 public void Test1()
 {
     Console.WriteLine("****** Basic Tests");
     Assert.AreEqual(new int[] { 0, 32, 18 }, Tortoise.Race(720, 850, 70));
     Assert.AreEqual(new int[] { 3, 21, 49 }, Tortoise.Race(80, 91, 37));
     Assert.AreEqual(new int[] { 2, 0, 0 }, Tortoise.Race(80, 100, 40));
 }
Ejemplo n.º 5
0
        public static void Start()
        {
            Tortoise.Show();
            Tortoise.SetSpeed(10);
            ColorWheel.AddColor(Colors.BlueViolet);
            ColorWheel.AddColor(Colors.Violet);
            ColorWheel.AddColor(Colors.Purple);

            for (int i = 0; i < 75; i++)
            {
                try
                {
                    //var aaa = 100 / i;

                    var nextColor = ColorWheel.GetNextColor();
                    Tortoise.SetPenColor(nextColor);

                    Tortoise.Move((i + 1) * 5);
                    Tortoise.Turn(360.0 / 3);
                }
                catch (Exception re)
                {
                    MessageBox.ShowMessage("Hold up: " + re);
                }
            }
        }
Ejemplo n.º 6
0
        private static void movingthetortoise100pixels()
        {
            var start = Tortoise.GetY();

            Tortoise.Move(100);
            Homework.CheckAnswer(Tortoise.GetY(), equals, start - 100);
        }
Ejemplo n.º 7
0
        public static void Start()
        {
            Tortoise.Show();
            Tortoise.Hide();
            Tortoise.SetX(225);
            Tortoise.SetY(150);

            Tortoise.SetSpeed(10);
            ColorWheel.AddColor(Colors.Crimson);
            ColorWheel.AddColor(Colors.DarkRed);
            ColorWheel.AddColor(Colors.FireBrick);
            for (int i = 0; i < 6; i++)
            {
                Tortoise.SetPenColor(ColorWheel.GetNextColor());
                Tortoise.Move((i + 1) * 4);
                Tortoise.Turn(-360.0 / 6);
                for (int j = 0; j < 15; j++)
                {
                    Tortoise.SetPenWidth(17);
                    Tortoise.Move((j + 1) * 8);
                    Tortoise.Turn(360.0 / 5);
                }

                //--Tortoise.getBackgroundWindow().setBackground(PenColors.Yellows.PeachPuff);
            }

            Tortoise.SetX(300);
            Tortoise.SetY(200);
            for (int i = 0; i < 5; i++)
            {
                Tortoise.SetPenColor("Black");
                Tortoise.Move(25);
                Tortoise.Turn(360.0 / 5);
            }
        }
Ejemplo n.º 8
0
        public Enemy SpawnEnemy(EnemyType newType, Vector2 position)
        {
            Enemy newEnemy = null;

            switch (newType)
            {
            case (EnemyType.Slicer):
                newEnemy = new Slicer(manager.thisScene, position);
                break;

            case (EnemyType.Tortoise):
                newEnemy = new Tortoise(manager.thisScene, position);
                break;

            case (EnemyType.Dragonfly):
                newEnemy = new Dragonfly(manager.thisScene, position);
                break;

            case (EnemyType.Komodo):
                newEnemy = new Komodo(manager.thisScene, position);
                break;

            case (EnemyType.Phantom):
                newEnemy = new Phantom(manager.thisScene, position);
                break;

            default:
                break;
            }

            return(newEnemy);
        }
Ejemplo n.º 9
0
        private static void thetortoiseturns15twice()
        {
            var ans = 15;

            Tortoise.Turn(ans);
            Tortoise.Turn(ans);
            Homework.CheckAnswer(Tortoise.GetAngle(), equals, 30);
        }
Ejemplo n.º 10
0
        public static void Start()
        {
            Tortoise.Show();
            Tortoise.SetSpeed(10);
            var currentBranchLength = 60;

            DrawBranch(currentBranchLength);
        }
Ejemplo n.º 11
0
 private static void AdjustColor_WithIfs(int currentBranchLength)
 {
     if (currentBranchLength == 60)
     {
         Tortoise.SetPenColor(Colors.SaddleBrown);
     }
     //...
 }
Ejemplo n.º 12
0
 private static void DrawTriangle(int length)
 {
     for (int i = 0; i < 3; i++)
     {
         Tortoise.Turn(360.0 / 3);
         Tortoise.Move(length);
     }
 }
Ejemplo n.º 13
0
 private static void DrawOctagonWithOverlap()
 {
     for (int i = 0; i < 8 + 1; i++)
     {
         Tortoise.Move(110);
         Tortoise.Turn(360.0 / 8);
     }
 }
Ejemplo n.º 14
0
        private static void thetortoiseturns15twice()
        {
            var ans = ___;

            Tortoise.Turn(ans);
            Tortoise.Turn(ans);
            Homework.CheckAnswer(30, equals, Tortoise.GetAngle());
        }
Ejemplo n.º 15
0
 private static void MoveToTheSquareStart(double length)
 {
     Tortoise.PenUp();
     Tortoise.Move(length / 2);
     Tortoise.Turn(-90);
     Tortoise.Move(length / 2);
     Tortoise.Turn(180);
     Tortoise.PenDown();
 }
Ejemplo n.º 16
0
 private static void DrawBranch(int currentBranchLength)
 {
     if (currentBranchLength > 0)
     {
         AdjustColor(currentBranchLength);
         Tortoise.Move(currentBranchLength);
         DrawLowerBranches(currentBranchLength);
     }
 }
Ejemplo n.º 17
0
        private static void movingthetortoise100pixels()
        {
            var start = Tortoise.GetY();    //240

            Tortoise.Move(100);             //
            var end = Tortoise.GetY();

            Homework.CheckAnswer(start - 100, equals, Tortoise.GetY());
        }
Ejemplo n.º 18
0
 private static void setUpPyramidLand()
 {
     Tortoise.Show();
     Tortoise.SetSpeed(10);
     //Tortoise.GetBackgroundWindow().setBackground(Colors.AliceBlue);
     Tortoise.SetPenColor(Colors.DarkGoldenrod);
     Tortoise.SetPenWidth(2);
     Tortoise.Hide();
 }
Ejemplo n.º 19
0
        public static void Start()
        {
            Tortoise.Show();
            Tortoise.SetPenColor(Colors.Gold);
            Tortoise.SetSpeed(10);
            double length = 100.0;

            MakeASquare(length);
        }
Ejemplo n.º 20
0
 private static void DrawLowerBranches(int currentBranchLength)
 {
     Tortoise.Turn(30);
     DrawShorterBranch(currentBranchLength);
     Tortoise.Turn(-60);
     DrawShorterBranch(currentBranchLength);
     Tortoise.Turn(30);
     AdjustColor(currentBranchLength);
     Tortoise.Move(-currentBranchLength);
 }
Ejemplo n.º 21
0
 public static void WeaveOneLayer(double lineLength, double zoom)
 {
     lineLength = lineLength + zoom;
     for (int i = 0; i < 6; i++)
     {
         DrawTriangle(lineLength);
         Tortoise.Turn(360.0 / 6);
         //lineLength = lineLength + zoom;
     }
 }
Ejemplo n.º 22
0
        public static void DrawTriangle(double lineLength)
        {
            Console.WriteLine(lineLength);

            for (int i = 0; i < 3; i++)
            {
                Tortoise.Move(lineLength);
                Tortoise.Turn(360.0 / 3);
            }
        }
Ejemplo n.º 23
0
 private static void DrawOctogon()
 {
     for (int i = 0; i < 8; i++)
     {
         var nextColor = ColorWheel.GetNextColor();
         Tortoise.SetPenColor(nextColor);
         Tortoise.Move(50);
         Tortoise.Turn(360.0 / 8);
     }
 }
Ejemplo n.º 24
0
 public static void main(string[] args)
 {
     Tortoise.Show();
     Tortoise.SetSpeed(10);
     Tortoise.SetX(200);
     drawHouse(40);
     drawHouse(120);
     drawHouse(90);
     drawHouse(20);
 }
Ejemplo n.º 25
0
 private static void MoveBackToCenter(double length)
 {
     Tortoise.PenUp();
     Tortoise.Turn(90);
     Tortoise.Move(length / 2);
     Tortoise.Turn(90);
     Tortoise.Move(length / 2);
     Tortoise.Turn(180);
     Tortoise.PenDown();
 }
Ejemplo n.º 26
0
 public static void Main2()
 {
     Tortoise.Show();
     Tortoise.SetSpeed(10);
     for (int i = 0; i < 4; i++)
     {
         DrawSquare();
         Tortoise.Turn(90);
     }
 }
Ejemplo n.º 27
0
        private void button2_Click(object sender, EventArgs e)
        {
            Rabbit   rabbit   = new Rabbit();
            Tortoise tortoise = new Tortoise();
            Thread   t1       = new Thread(() => rabbit.Run(this.richTextBox1));
            Thread   t2       = new Thread(() => tortoise.Run(this.richTextBox2));

            t1.Start();
            t2.Start();
        }
Ejemplo n.º 28
0
        private static void AdjustPen()
        {
            Tortoise.SetPenColor(ColorWheel.GetNextColor());
            var width = Tortoise.GetPenWidth();

            Tortoise.SetPenWidth(width + 1);
            if (Tortoise.GetPenWidth() > 4)
            {
                Tortoise.SetPenWidth(1);
            }
        }
Ejemplo n.º 29
0
 private static void DrawHouse(int heigthOfHouse)
 {
     Tortoise.Move(heigthOfHouse);
     Tortoise.Turn(90);
     Tortoise.Move(30);
     Tortoise.Turn(90);
     Tortoise.Move(heigthOfHouse);
     Tortoise.Turn(-90);
     Tortoise.Move(20);
     Tortoise.Turn(-90);
 }
Ejemplo n.º 30
0
 private static void DrawPentagon()
 {
     for (int i = 0; i < 200; i++)
     {
         AdjustPen();
         var length = i;
         Tortoise.Move(length);
         Tortoise.Turn(360.0 / 5);
         Tortoise.Turn(1);
     }
 }
Ejemplo n.º 31
0
    static void Main(string[] args)
    {
        // Whether we should use the unsafe, Direct interface to MPI.
        // When false, use the normal MPI.NET interface.
        bool useDirectInterface = false;

        using (MPI.Environment env = new MPI.Environment(ref args))
        {
            if (args.Length > 0 && args[0] == "/direct")
            {
                useDirectInterface = true;
                System.Console.WriteLine("Using direct MPI interface.");
                System.Console.WriteLine("Bzzt.  Can't do that here.  Goodbye");
                return;
            }
            else
                System.Console.WriteLine("Using MPI.NET interface.");

            comm = MPI.Communicator.world;
            if (comm.Size != 2)
            {
                if (comm.Rank == 0)
                    System.Console.WriteLine("Only two processes allowed.  Rerun with -np 2");
                return;
            }
            else
            {
                self = comm.Rank;
                other = (comm.Rank + 1) % 2;
            }

            System.Console.WriteLine(comm.Rank + ": " + MPI.Environment.ProcessorName);

            bwdata = new Data[nSamp];

            testLatency();
            testSyncTime();
            comm.Broadcast(ref latency, 0);

            if (self == 0)
            {
                System.Console.WriteLine("Latency: {0:F9}", latency);
                System.Console.WriteLine("Sync Time: {0:F9}", synctime);
                System.Console.WriteLine("Now starting main loop");
            }

            int i, j, n, nq;
            int inc = 1, len;
            int start = 0, end = 1024 * 1024 * 1024;
            int bufflen = start, bufalign = 16 * 1024;
            double tlast = latency;

            for (n = nq = 0, len = start; tlast < stopTime && len <= end; len += inc, nq++)
            {
                if (nq > 2 && (nq % 2 != 0)) inc *= 2;
                int ipert, pert;
                for (ipert = 0, pert = (inc > PERT + 1) ? -PERT : 0;
                     pert <= PERT;
                     ipert++, n++, pert += (inc > PERT + 1) ? PERT : PERT + 1)
                {
                    int nRepeat = bufflen == 0 ?
                                  latencyReps :
                                  (int)Math.Max((RUNTM / ((double)bufflen / (bufflen - inc + 1.0) * tlast)),
                                                TRIALS);
                    comm.Broadcast(ref nRepeat, 0);

                    bufflen = len + pert;
                    Tortoise[] sendBuffer = new Tortoise[bufflen]; // Align the data?  Some day.  Maybe.
                    Tortoise[] recvBuffer = new Tortoise[bufflen];
                    for (i = 0; i < bufflen; i++) {
                        sendBuffer[i] = new Tortoise();
                        sendBuffer[i].contents = 0;
                    }
                    if (self == 0)
                        System.Console.Write("{0,3:D}: {1,9:D} bytes {2,7:D} times ---> ", n, bufflen, nRepeat);

                    bwdata[n].t = 1e99;
                    double t1 = 0, t2 = 0;
                    
                    for (i = 0; i < TRIALS; i++)
                    {
                        sync();
                        double t0 = when();
                        if (useDirectInterface)
                        {
                        }
                        else
                        {
                            for (j = 0; j < nRepeat; j++)
                            {
                                if (self == 0)
                                {
                                    comm.Send(sendBuffer, other, 142);
                                    comm.Receive(ref recvBuffer, other, 242);
                                }
                                else
                                {
                                    comm.Receive(ref recvBuffer, other, 142);
                                    comm.Send(sendBuffer, other, 242);
                                }
                            }
                        }
                        double t = (when() - t0) / (2.0 * nRepeat);
                        t2 += t*t;
                        t1 += t;
                        bwdata[n].t = Math.Min(bwdata[n].t, t);
                        bwdata[n].variance = t2 / TRIALS - t1 / TRIALS * t1 / TRIALS;
                        tlast = bwdata[n].t;
                        bwdata[n].bits = bufflen * sizeof(byte)*8;
                        bwdata[n].bps = bwdata[n].bits / (bwdata[n].t * 1024 * 1024);
                        bwdata[n].repeat = nRepeat;
                    }
                    if (self == 0)
                        System.Console.WriteLine("{0,9:F2} Mbps in {1:F9} sec", bwdata[n].bps, tlast);
                }
            }
        }
    }