Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 28.08 KB | None | 0 0
  1. using System.Windows.Forms;
  2. using System.Drawing;
  3. using System;
  4.  
  5. namespace Reversi
  6. {
  7.     static class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             Application.Run(new Scherm());
  12.         }
  13.  
  14.         class Scherm : Form
  15.         {
  16.             /*  Declaraties     */
  17.             Button startknop;
  18.             Button helpknop;
  19.             Button randomknop;
  20.             Label roodlabel;
  21.             Label blauwlabel;
  22.             Label schermtext;
  23.             Label statuslabel;
  24.             TextBox schermbox;  
  25.             Button plusx;
  26.             Button plusy;
  27.             Button minx;
  28.             Button miny;
  29.  
  30.             /*  Globale Variabelen  */
  31.             // Statics
  32.             static Random random = new Random();
  33.  
  34.             // Constants
  35.             int schermgroottex = 6, schermgroottey = 6, vakgrootte = 40;
  36.  
  37.             // Ints
  38.             int aantal = 4, aantalrood = 0, aantalblauw = 0, kleur = 1; // 0 = leeg, 1 = blauw, 2 = rood
  39.             int mouseX, mouseY, schermgrootte2, maxaantal, geldigezetten = 0;
  40.  
  41.             // Arrays
  42.             int[,] spelbord;
  43.             int[] geldigx;
  44.             int[] geldigy;
  45.  
  46.             // Bools
  47.             bool rest = false, help = false;
  48.             /*  Einde Variabelen  */
  49.  
  50.             public Scherm()
  51.             {
  52.                 schermgrootte2 = schermgroottex;
  53.                 maxaantal = schermgroottex * schermgroottey;
  54.  
  55.                 /*  Objecten aanmaken     */
  56.                 this.startknop = new Button();
  57.                 this.helpknop = new Button();
  58.                 this.randomknop = new Button();
  59.                 this.roodlabel = new Label();
  60.                 this.blauwlabel = new Label();
  61.                 this.statuslabel = new Label();
  62.                 this.schermbox = new TextBox();
  63.                 this.schermtext = new Label();
  64.                 this.plusx = new Button();
  65.                 this.minx = new Button();
  66.                 this.plusy = new Button();
  67.                 this.miny = new Button();
  68.  
  69.                 /*  Eigenschappen van objecten    */
  70.                 // plusxknop
  71.                 this.plusx.Location = new Point(295, 68);
  72.                 this.plusx.Name = "plusx";
  73.                 this.plusx.Size = new Size(20, 20);
  74.                 this.plusx.Text = "+";
  75.  
  76.                 // plusyknop
  77.                 this.plusy.Location = new Point(295, 90);
  78.                 this.plusy.Name = "plusy";
  79.                 this.plusy.Size = new Size(20, 20);
  80.                 this.plusy.Text = "+";
  81.  
  82.                 // minxknop
  83.                 this.minx.Location = new Point(245, 68);
  84.                 this.minx.Name = "minx";
  85.                 this.minx.Size = new Size(20, 20);
  86.                 this.minx.Text = "-";
  87.  
  88.                 // minxknop
  89.                 this.miny.Location = new Point(245, 90);
  90.                 this.miny.Name = "miny";
  91.                 this.miny.Size = new Size(20, 20);
  92.                 this.miny.Text = "-";
  93.  
  94.                 // randomknop
  95.                 this.randomknop.Location = new Point(350, 65);
  96.                 this.randomknop.Name = "randomknop";
  97.                 this.randomknop.Size = new Size(80, 25);
  98.                 this.randomknop.Text = "Random zet";
  99.  
  100.                 // schermbox
  101.                 this.schermbox.Location = new Point(270, 68);
  102.                 this.schermbox.Name = "schermgrootte2";
  103.                 this.schermbox.Size = new Size(20, 29);
  104.                 this.schermbox.TabIndex = 0;
  105.                 this.schermbox.Text = "6";
  106.  
  107.                 // schermtext
  108.                 this.schermtext.AutoSize = true;
  109.                 this.schermtext.Location = new Point(200, 70);
  110.                 this.schermtext.Name = "roodlabel";
  111.                 this.schermtext.Size = new Size(40, 13);
  112.                 this.schermtext.TabIndex = 2;
  113.                 this.schermtext.Text = "Grootte";
  114.                 this.schermtext.BackColor = Color.Khaki;
  115.  
  116.                 // startknop
  117.                 this.startknop.Location = new Point(12, 12);
  118.                 this.startknop.Name = "startknop";
  119.                 this.startknop.Size = new Size(78, 29);
  120.                 this.startknop.Text = "Nieuw spel";
  121.  
  122.                 // helpknop
  123.                 this.helpknop.Location = new Point(96, 12);
  124.                 this.helpknop.Name = "helpknop";
  125.                 this.helpknop.Size = new Size(78, 29);
  126.                 this.helpknop.TabIndex = 1;
  127.                 this.helpknop.Text = "Halp!";
  128.  
  129.                 // roodlabel
  130.                 this.roodlabel.AutoSize = true;
  131.                 this.roodlabel.Location = new Point(392, 20);
  132.                 this.roodlabel.Name = "roodlabel";
  133.                 this.roodlabel.Size = new Size(40, 13);
  134.                 this.roodlabel.TabIndex = 2;
  135.                 this.roodlabel.Text = "2  Stenen";
  136.                 this.roodlabel.BackColor = Color.Khaki;
  137.  
  138.                 // blauwlabel
  139.                 this.blauwlabel.AutoSize = true;
  140.                 this.blauwlabel.Location = new Point(266, 19);
  141.                 this.blauwlabel.Name = "blauwlabel";
  142.                 this.blauwlabel.Size = new Size(40, 13);
  143.                 this.blauwlabel.TabIndex = 3;
  144.                 this.blauwlabel.Text = "2  Stenen";
  145.                 this.blauwlabel.BackColor = Color.Khaki;
  146.  
  147.                 // statuslabel
  148.                 this.statuslabel.AutoSize = true;
  149.                 this.statuslabel.Location = new Point(13, 72);
  150.                 this.statuslabel.Name = "statuslabel";
  151.                 this.statuslabel.Size = new Size(35, 13);
  152.                 this.statuslabel.TabIndex = 4;
  153.                 this.statuslabel.Text = "Blauw is nu aan zet.";
  154.                 this.statuslabel.BackColor = Color.Khaki;
  155.  
  156.                 // Het formulier
  157.                 this.Controls.Add(this.statuslabel);
  158.                 this.Controls.Add(this.blauwlabel);
  159.                 this.Controls.Add(this.roodlabel);
  160.                 this.Controls.Add(this.helpknop);
  161.                 this.Controls.Add(this.startknop);
  162.                 this.Controls.Add(this.schermbox);
  163.                 this.Controls.Add(this.schermtext);
  164.                 this.Controls.Add(this.randomknop);
  165.                 this.Controls.Add(this.plusx);
  166.                 this.Controls.Add(this.minx);
  167.                 this.Controls.Add(this.plusy);
  168.                 this.Controls.Add(this.miny);
  169.                 this.Text = "Reversi door Conrad en Inigo";
  170.  
  171.                 // Als je op enter drukt, activeer dan de startknop.
  172.                 this.AcceptButton = startknop;
  173.  
  174.                 // Fix voor de clientsize, als het bord groter is dan het scherm, pas dan het scherm aan.
  175.                 clientgrootte();
  176.  
  177.                 if (int.Parse(this.schermbox.Text) > 4)
  178.                     schermgrootte2 = int.Parse(this.schermbox.Text);
  179.                 else
  180.                 {
  181.                     this.schermbox.Text = 4.ToString();
  182.                     schermgrootte2 = 4;
  183.                 }
  184.                 maxaantal = schermgroottex * schermgroottey;
  185.  
  186.                 // Events
  187.                 this.Paint += this.tekenScherm;
  188.                 this.MouseClick += this.klik;
  189.                 this.startknop.Click += this.nieuwspel;
  190.                 this.helpknop.Click += this.helpklik;
  191.                 this.randomknop.Click += this.randomklik;
  192.                 this.plusx.Click += this.plusxklik;
  193.                 this.minx.Click += this.minxklik;
  194.                 this.plusy.Click += this.plusyklik;
  195.                 this.miny.Click += this.minyklik;
  196.  
  197.                 // Arrays
  198.                 this.spelbord = new int[schermgrootte2, schermgrootte2];
  199.                 this.geldigx = new int[maxaantal];
  200.                 this.geldigy = new int[maxaantal];
  201.  
  202.                 int tellertje;
  203.                 int tellertje2;
  204.  
  205.                 //initialiseren van het bord, alles op 0 zetten (= geen stenen) behalve die eerste 4 stenen.
  206.                 for (tellertje = 0; tellertje < schermgrootte2; tellertje++)
  207.                 {
  208.                     for (tellertje2 = 0; tellertje2 < schermgrootte2; tellertje2++)
  209.                     {
  210.                         if (tellertje == (schermgrootte2 / 2) - 1 && tellertje2 == (schermgrootte2 / 2) - 1)
  211.                             spelbord[tellertje, tellertje2] = 1;
  212.                         else if (tellertje == (schermgrootte2 / 2) && tellertje2 == (schermgrootte2 / 2))
  213.                             spelbord[tellertje, tellertje2] = 1;
  214.                         else if (tellertje == (schermgrootte2 / 2) - 1 && tellertje2 == (schermgrootte2 / 2))
  215.                             spelbord[tellertje, tellertje2] = 2;
  216.                         else if (tellertje == (schermgrootte2 / 2) && tellertje2 == (schermgrootte2 / 2) - 1)
  217.                             spelbord[tellertje, tellertje2] = 2;
  218.                         else spelbord[tellertje, tellertje2] = 0;
  219.                     }
  220.                 }
  221.             }
  222.  
  223.             public void plusxklik(object o, EventArgs e)
  224.             {
  225.                 schermgroottex++;
  226.                 this.schermbox.Text = schermgroottex.ToString();
  227.                 nieuwspel(o, e);      
  228.             }
  229.  
  230.             public void minxklik(object o, EventArgs e)
  231.             {
  232.                 schermgroottex--;
  233.                 this.schermbox.Text = schermgroottex.ToString();
  234.                 nieuwspel(o, e);
  235.             }
  236.  
  237.             public void plusyklik(object o, EventArgs e)
  238.             {
  239.                 schermgroottey++;
  240.                 this.schermbox.Text = schermgroottey.ToString();
  241.                 nieuwspel(o, e);
  242.             }
  243.  
  244.             public void minyklik(object o, EventArgs e)
  245.             {
  246.                 schermgroottey--;
  247.                 this.schermbox.Text = schermgroottey.ToString();
  248.                 nieuwspel(o, e);
  249.             }
  250.  
  251.             public void clientgrootte()
  252.             {
  253.                 if (int.Parse(this.schermbox.Text) > 4)
  254.                     schermgrootte2 = int.Parse(this.schermbox.Text);
  255.                 else
  256.                 {
  257.                     this.schermbox.Text = 4.ToString();
  258.                     schermgrootte2 = 4;
  259.                 }
  260.                 if (schermgrootte2 >= 8 && schermgrootte2 <= 10)
  261.                 {
  262.                     this.ClientSize = new Size(450, 450 + (schermgrootte2 - 8) * vakgrootte);
  263.                 }
  264.                 else if (schermgrootte2 >= 11)
  265.                 {
  266.                     this.ClientSize = new Size(370 + (schermgrootte2 - 8) * vakgrootte, 450 + (schermgrootte2 - 8) * vakgrootte);
  267.                 }
  268.                 else
  269.                 {
  270.                     this.ClientSize = new Size(450, 115 + (schermgrootte2 * vakgrootte));
  271.                 }
  272.             }
  273.  
  274.             // Klik op de random knop voor een willekeurige (geldige) zet
  275.             public void randomklik(object o, EventArgs e)
  276.             {
  277.                 int willekeurig = random.Next(0, geldigezetten);
  278.                 doezet(geldigx[willekeurig], geldigy[willekeurig]);
  279.             }
  280.  
  281.             // Gooit de bool "help" om als er op de hulpknop gedrukt wordt, en roept Invalidate aan.
  282.             public void helpklik(object o, EventArgs e)
  283.             {
  284.                 if (help == true)
  285.                 {
  286.                     help = false;
  287.                     Invalidate();
  288.                 }
  289.                 else if (help == false)
  290.                 {
  291.                     help = true;
  292.                     Invalidate();
  293.                 }
  294.             }
  295.  
  296.             // Reset alle waarden zodat het weer een nieuw spel is, en zet de eerste vier stenen weer neer.
  297.             public void nieuwspel(object o, EventArgs e)
  298.             {
  299.                 if (int.Parse(this.schermbox.Text) > 4)
  300.                     schermgrootte2 = int.Parse(this.schermbox.Text);
  301.                 else
  302.                 {
  303.                     this.schermbox.Text = 4.ToString();
  304.                     schermgrootte2 = 4;
  305.                 }
  306.                 //maxaantal = schermgrootte2 * schermgrootte2;
  307.                 this.spelbord = new int[schermgrootte2, schermgrootte2];
  308.                 clientgrootte();
  309.  
  310.                 int t = 0; int t2 = 0;
  311.                 kleur = 1; this.statuslabel.Text = "Blauw is nu aan zet.";
  312.                 aantalrood = 0;
  313.                 aantalblauw = 0;
  314.                 help = false;
  315.  
  316.                 aantal = 4;
  317.                 for (t = 0; t < schermgrootte2; t++)
  318.                 {
  319.                     for (t2 = 0; t2 < schermgrootte2; t2++)
  320.                     {
  321.                         if (t == (schermgrootte2 / 2) - 1 && t2 == (schermgrootte2 / 2) - 1)
  322.                             spelbord[t, t2] = 1;
  323.                         else if (t == (schermgrootte2 / 2) && t2 == (schermgrootte2 / 2))
  324.                             spelbord[t, t2] = 1;
  325.                         else if (t == (schermgrootte2 / 2) - 1 && t2 == (schermgrootte2 / 2))
  326.                             spelbord[t, t2] = 2;
  327.                         else if (t == (schermgrootte2 / 2) && t2 == (schermgrootte2 / 2) - 1)
  328.                             spelbord[t, t2] = 2;
  329.                         else spelbord[t, t2] = 0;
  330.                     }
  331.                 }
  332.                 Invalidate();
  333.             }
  334.  
  335.             // Bouwt het scherm op met de vakjes, de gekleurde rondjes, en (indien aangegeven) de hulpcirkeltjes.
  336.             public void tekenScherm(object o, PaintEventArgs e)
  337.             {
  338.                 volgendeZet();
  339.                 Graphics gr = e.Graphics;
  340.                 gr.FillRectangle(Brushes.Khaki, 0, 0, this.ClientSize.Width, this.ClientSize.Height);
  341.                 int x = 15, y = 100, teller, teller2;
  342.                 tekenRondje(gr, 345, 5, 2);
  343.                 tekenRondje(gr, 220, 5, 1);
  344.  
  345.                 //Bijhouden van hoeveel stenen van iedere kleur zich op het bord bevinden.
  346.                 stenenTellen();
  347.  
  348.                 geldigezetten = 0;
  349.                 for (teller = 0; teller < schermgrootte2; teller++)
  350.                 {
  351.                     tekenvakje(gr, x, y);
  352.                     for (teller2 = 0; teller2 < schermgrootte2; teller2++)
  353.                     {
  354.                         tekenvakje(gr, x, y);
  355.                         tekenRondje(gr, x, y, spelbord[teller, teller2]);
  356.                         if (help)
  357.                         {
  358.                             tekenHelpvakje(gr, x, y, teller, teller2, spelbord[teller, teller2]);
  359.                         }
  360.                         else if (!help)
  361.                         {
  362.                             doeRandom(gr, x, y, teller, teller2, spelbord[teller, teller2]);
  363.                         }
  364.                         y = y + vakgrootte;
  365.                     }
  366.                     x = x + vakgrootte;
  367.                     y = 100;
  368.                 }
  369.             }
  370.  
  371.             // Voorkomt het flitsen bij klikken / nieuw game / help aan/uit
  372.             override protected void OnPaintBackground(PaintEventArgs e)
  373.             {
  374.             }
  375.  
  376.             // Tekent in de vakken waar de huidige kleur kan zetten (alleen als help knop geklikt is, help == true)
  377.             public void tekenHelpvakje(Graphics gr, int x, int y, int teller, int teller2, int kleuraanzet)
  378.             {
  379.                 if (kleuraanzet == 0 && checkspot(teller, teller2, kleur, false) == true)
  380.                 {
  381.                     gr.DrawEllipse(Pens.Gray, x, y, vakgrootte, vakgrootte);
  382.                     geldigeZet(x, y);
  383.                 }
  384.             }
  385.  
  386.             // Druk op deze knop voor een willekeurige (maar geldige!) zet.
  387.             public void doeRandom(Graphics gr, int x, int y, int teller, int teller2, int kleuraanzet)
  388.             {
  389.                 if (kleuraanzet == 0 && checkspot(teller, teller2, kleur, false) == true)
  390.                 {
  391.                     geldigeZet(x, y);
  392.                 }
  393.             }
  394.  
  395.             // Sla de x en de y posities van alle geldige zetten op.
  396.             public void geldigeZet(int x, int y)
  397.             {
  398.                 geldigx[geldigezetten] = x;
  399.                 geldigy[geldigezetten] = y;
  400.                 geldigezetten++;
  401.             }
  402.  
  403.             // Telt de stenen en zet de juiste getallen in de labels.
  404.             public void stenenTellen()
  405.             {
  406.                 aantalrood = 0;
  407.                 aantalblauw = 0;
  408.                 int teller, teller2;
  409.  
  410.                 for (teller = 0; teller < schermgrootte2; teller++)
  411.                 {
  412.                     for (teller2 = 0; teller2 < schermgrootte2; teller2++)
  413.                     {
  414.                         if (spelbord[teller, teller2] == 1) aantalblauw++;
  415.                         else if (spelbord[teller, teller2] == 2) aantalrood++;
  416.                     }
  417.                 }
  418.                 this.blauwlabel.Text = aantalblauw + " Stenen";
  419.                 this.roodlabel.Text = aantalrood + " Stenen";
  420.             }
  421.  
  422.             public void volgendeZet()
  423.             {
  424.                 checkzetten(); // Checkt of de huidige kleur wel kan zetten.
  425.                 if (aantal == maxaantal) // Het spel is afgelopen als het bord vol is.
  426.                 {
  427.                     eindigspel();
  428.                 }
  429.                 else if (rest == false) // Is het bord niet vol, dan actie ondernemen als de huidige kleur niet kan zetten.
  430.                 {
  431.                     switch (kleur)
  432.                     {
  433.                         case 1: kleur = 2;
  434.                             checkzetten();
  435.                             if (rest == true)
  436.                                 this.statuslabel.Text = "Rood is nu aan zet";
  437.                             else
  438.                                 eindigspel();
  439.                             break;
  440.  
  441.                         case 2: kleur = 1;
  442.                             checkzetten();
  443.                             if (rest == true)
  444.                                 this.statuslabel.Text = "Blauw is nu aan zet";
  445.                             else
  446.                                 eindigspel();
  447.                             break;
  448.                     }
  449.                 }
  450.             }
  451.  
  452.  
  453.  
  454.             // Stenen van iedere kleur op het bord tellen.
  455.             public void eindigspel()
  456.             {
  457.                 if (aantalblauw == aantalrood)
  458.                     this.statuslabel.Text = "Gelijkspel!";
  459.                 if (aantalblauw > aantalrood)
  460.                     this.statuslabel.Text = "Blauw wint!";
  461.                 if (aantalblauw < aantalrood)
  462.                     this.statuslabel.Text = "Rood wint!";
  463.             }
  464.  
  465.  
  466.  
  467.             // Checkt of de huidige kleur kan zetten.
  468.             public void checkzetten()
  469.             {
  470.                 rest = false;
  471.                 int teller = 0; int teller2 = 0;
  472.                 for (teller = 0; teller < schermgrootte2; teller++)
  473.                 {
  474.                     for (teller2 = 0; teller2 < schermgrootte2; teller2++)
  475.                     {
  476.                         if (spelbord[teller, teller2] == 0)
  477.                             checkspot(teller, teller2, kleur, false);
  478.                     }
  479.                 }
  480.  
  481.             }
  482.  
  483.  
  484.             // Tekent een vakje van het speelbord.
  485.             public void tekenvakje(Graphics gr, int x, int y)
  486.             {
  487.                 gr.FillRectangle(Brushes.Khaki, x, y, vakgrootte, vakgrootte);
  488.                 gr.DrawRectangle(Pens.Black, x, y, vakgrootte, vakgrootte);
  489.             }
  490.  
  491.  
  492.             // Klikevent methode.
  493.             public void klik(object o, MouseEventArgs e)
  494.             {
  495.                 // Doe een zet als er in een vakje geklikt wordt.
  496.                 if (e.X >= 15 && e.Y >= 100 && e.X <= (15 + vakgrootte * schermgroottex - 1) && e.Y <= (100 + vakgrootte * schermgroottey - 1))
  497.                 {
  498.                     doezet(e.X, e.Y);
  499.                 }
  500.             }
  501.  
  502.             // Alle acties die uitgevoerd moeten worden als ergens geklikt wordt.
  503.             public void doezet(int x, int y)
  504.             {
  505.                 if (aantal < maxaantal)
  506.                 {
  507.                     mouseX = ((x - 15) / vakgrootte * vakgrootte);
  508.                     mouseY = ((y - 100) / vakgrootte * vakgrootte);
  509.                     if (spelbord[(mouseX) / vakgrootte, (mouseY) / vakgrootte] == 0 && checkspot((mouseX / vakgrootte), (mouseY / vakgrootte), kleur, true) == true)
  510.                     {
  511.                         if (kleur == 1)
  512.                         {
  513.                             spelbord[mouseX / vakgrootte, mouseY / vakgrootte] = kleur;
  514.                             kleur = 2;
  515.                             this.statuslabel.Text = "Rood is nu aan zet";
  516.                         }
  517.                         else if (kleur == 2)
  518.                         {
  519.                             spelbord[mouseX / vakgrootte, mouseY / vakgrootte] = kleur;
  520.                             kleur = 1;
  521.                             this.statuslabel.Text = "Blauw is nu aan zet";
  522.                         }
  523.                         aantal++;
  524.                         Invalidate();
  525.                     }
  526.                 }
  527.             }
  528.  
  529.             // Bekijkt of op het geklikte vakje een steen gezet mag worden, zo ja, verander alle stenen volgens de spelregels.
  530.             public bool checkspot(int mousex, int mousey, int kleuraanzet, bool verander)
  531.             {
  532.                 bool res = false;
  533.  
  534.                 // Check boven
  535.                 int t;
  536.                 // Kijk eerst of er stenen van de andere kleur naast staan, zo ja, hoeveel = t.
  537.                 for (t = 1; t < mousey && (spelbord[mousex, mousey - t] != 0 && spelbord[mousex, mousey - t] != kleuraanzet); t++)
  538.                 {
  539.  
  540.                 }
  541.                 // Staat er aan het eind van die rij een steen van eigen kleur? Zo ja, maak alle stenen ertussen eigen kleur.
  542.                 if ((mousey - t) >= 0 && spelbord[mousex, mousey - t] == kleuraanzet && t > 1)
  543.                 {
  544.                     res = true;
  545.                     if (verander)
  546.                     {
  547.                         int t2;
  548.                         for (t2 = 1; t2 < t; t2++)
  549.                         {
  550.                             // Verander de steen
  551.                             spelbord[mousex, mousey - t2] = kleuraanzet;
  552.                         }
  553.                     }
  554.                 }
  555.  
  556.                 if (res == true)
  557.                     rest = true;
  558.  
  559.                 // Check rechts
  560.  
  561.                 for (t = 1; t < schermgrootte2 - mousex && (spelbord[mousex + t, mousey] != 0 && spelbord[mousex + t, mousey] != kleuraanzet); t++)
  562.                 {
  563.  
  564.                 }
  565.                 if ((mousex + t) <= (schermgrootte2 - 1) && spelbord[mousex + t, mousey] == kleuraanzet && t > 1)
  566.                 {
  567.                     res = true;
  568.                     if (verander)
  569.                     {
  570.                         int t2;
  571.                         for (t2 = 1; t2 < t; t2++)
  572.                         {
  573.                             spelbord[mousex + t2, mousey] = kleuraanzet;
  574.                         }
  575.                     }
  576.                 }
  577.                 if (res == true)
  578.                     rest = true;
  579.  
  580.                 // Check links
  581.  
  582.                 for (t = 1; t < mousex && (spelbord[mousex - t, mousey] != 0 && spelbord[mousex - t, mousey] != kleuraanzet); t++)
  583.                 {
  584.  
  585.                 }
  586.                 if ((mousex - t) >= 0 && spelbord[mousex - t, mousey] == kleuraanzet && t > 1)
  587.                 {
  588.                     res = true;
  589.                     if (verander)
  590.                     {
  591.                         int t2;
  592.                         for (t2 = 1; t2 < t; t2++)
  593.                         {
  594.                             spelbord[mousex - t2, mousey] = kleuraanzet;
  595.                         }
  596.                     }
  597.                 }
  598.                 if (res == true)
  599.                     rest = true;
  600.  
  601.                 // Check onder
  602.  
  603.                 for (t = 1; t < schermgrootte2 - mousey && (spelbord[mousex, mousey + t] != 0 && spelbord[mousex, mousey + t] != kleuraanzet); t++)
  604.                 {
  605.  
  606.                 }
  607.                 if ((mousey + t) <= (schermgrootte2 - 1) && spelbord[mousex, mousey + t] == kleuraanzet && t > 1)
  608.                 {
  609.                     res = true;
  610.                     if (verander)
  611.                     {
  612.                         int t2;
  613.                         for (t2 = 1; t2 < t; t2++)
  614.                         {
  615.                             spelbord[mousex, mousey + t2] = kleuraanzet;
  616.                         }
  617.                     }
  618.                 }
  619.                 if (res == true)
  620.                     rest = true;
  621.  
  622.                 // Check rechtsboven
  623.  
  624.                 for (t = 1; t < mousey && t < schermgrootte2 - mousex && (spelbord[mousex + t, mousey - t] != 0 && spelbord[mousex + t, mousey - t] != kleuraanzet); t++)
  625.                 {
  626.  
  627.                 }
  628.                 if ((mousey - t) >= 0 && (mousex + t) <= (schermgrootte2 - 1) && spelbord[mousex + t, mousey - t] == kleuraanzet && t > 1)
  629.                 {
  630.                     res = true;
  631.                     if (verander)
  632.                     {
  633.                         int t2;
  634.                         for (t2 = 1; t2 < t; t2++)
  635.                         {
  636.                             spelbord[mousex + t2, mousey - t2] = kleuraanzet;
  637.                         }
  638.                     }
  639.                 }
  640.                 if (res == true)
  641.                     rest = true;
  642.  
  643.                 // Check linksboven
  644.  
  645.                 for (t = 1; t < mousey && t < mousex && (spelbord[mousex - t, mousey - t] != 0 && spelbord[mousex - t, mousey - t] != kleuraanzet); t++)
  646.                 {
  647.  
  648.                 }
  649.                 if ((mousey - t) >= 0 && (mousex - t) >= 0 && spelbord[mousex - t, mousey - t] == kleuraanzet && t > 1)
  650.                 {
  651.                     res = true;
  652.                     if (verander)
  653.                     {
  654.                         int t2;
  655.                         for (t2 = 1; t2 < t; t2++)
  656.                         {
  657.                             spelbord[mousex - t2, mousey - t2] = kleuraanzet;
  658.                         }
  659.                     }
  660.                 }
  661.                 if (res == true)
  662.                     rest = true;
  663.  
  664.                 // Check linksonder
  665.  
  666.                 for (t = 1; t < schermgrootte2 - mousey && t < mousex && (spelbord[mousex - t, mousey + t] != 0 && spelbord[mousex - t, mousey + t] != kleuraanzet); t++)
  667.                 {
  668.  
  669.                 }
  670.                 if ((mousex - t) >= 0 && mousey + t <= (schermgrootte2 - 1) && spelbord[mousex - t, mousey + t] == kleuraanzet && t > 1)
  671.                 {
  672.                     res = true;
  673.                     if (verander)
  674.                     {
  675.                         int t2;
  676.                         for (t2 = 1; t2 < t; t2++)
  677.                         {
  678.                             spelbord[mousex - t2, mousey + t2] = kleuraanzet;
  679.                         }
  680.                     }
  681.                 }
  682.                 if (res == true)
  683.                     rest = true;
  684.  
  685.                 // Check rechtsonder
  686.  
  687.                 for (t = 1; t < schermgrootte2 - mousey && t < schermgrootte2 - mousex && (spelbord[mousex + t, mousey + t] != 0 && spelbord[mousex + t, mousey + t] != kleuraanzet); t++)
  688.                 {
  689.  
  690.                 }
  691.                 if ((mousex + t) <= (schermgrootte2 - 1) && (mousey + t) <= (schermgrootte2 - 1) && spelbord[mousex + t, mousey + t] == kleuraanzet && t > 1)
  692.                 {
  693.                     res = true;
  694.                     if (verander)
  695.                     {
  696.                         int t2;
  697.                         for (t2 = 1; t2 < t; t2++)
  698.                         {
  699.                             spelbord[mousex + t2, mousey + t2] = kleuraanzet;
  700.                         }
  701.                     }
  702.                 }
  703.  
  704.                 if (res == true)
  705.                     rest = true;
  706.  
  707.                 // Return aan het eind
  708.                 return res;
  709.             }
  710.  
  711.             // Tekent de steen
  712.             public void tekenRondje(Graphics gr, int x, int y, int kleurwaarde)
  713.             {
  714.                 if (kleurwaarde == 1)
  715.                     gr.FillEllipse(Brushes.Blue, x, y, vakgrootte, vakgrootte);
  716.                 else if (kleurwaarde == 2)
  717.                     gr.FillEllipse(Brushes.Red, x, y, vakgrootte, vakgrootte);
  718.             }
  719.  
  720.         }
  721.     }
  722. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement