Advertisement
Guest User

Untitled

a guest
Oct 30th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace GameEngine
  8. {
  9.     public class Opdracht2 : AbstractGame
  10.     {
  11.         int count = 0;
  12.  
  13.         Rectanglef[] Rectangle_Array = new Rectanglef[15];
  14.  
  15.         Random Kunst = new Random();
  16.  
  17.         private Rectanglef[] RandomSquare = new Rectanglef[15];
  18.  
  19.         private bool Rectangle = false;
  20.  
  21.  
  22.         private int Kunst_Color1;
  23.         private int Kunst_Color2;
  24.         private int Kunst_Color3;
  25.  
  26.         private int Art_Pos;
  27.         private int Art_Pos2;
  28.         private int Art_Size;
  29.         private int Art_Size2;
  30.  
  31.  
  32.         private List<int[]> colorList;
  33.         private List<Rectanglef[]> Rectangle_List;
  34.  
  35.         public override void GameStart()
  36.         {
  37.  
  38.             for (int i = 0; i < RandomSquare.Length; i++)
  39.             {
  40.                 Art_Size = Kunst.Next(0, 100);
  41.                 Art_Size2 = Kunst.Next(0, 100);
  42.  
  43.                 Art_Pos = Kunst.Next(310, 410);
  44.                 Art_Pos2 = Kunst.Next(60, 300);
  45.  
  46.                 RandomSquare[i] = new Rectanglef(Art_Pos, Art_Pos2, Art_Size, Art_Size2);
  47.             }
  48.  
  49.             Rectangle_Array[0] = RandomSquare[0];
  50.             Rectangle_Array[2] = RandomSquare[1];
  51.             Rectangle_Array[3] = RandomSquare[2];
  52.             Rectangle_Array[4] = RandomSquare[3];
  53.             Rectangle_Array[5] = RandomSquare[4];
  54.             Rectangle_Array[6] = RandomSquare[5];
  55.             Rectangle_Array[7] = RandomSquare[6];
  56.             Rectangle_Array[8] = RandomSquare[7];
  57.             Rectangle_Array[9] = RandomSquare[8];
  58.             Rectangle_Array[10] = RandomSquare[9];
  59.             Rectangle_Array[11] = RandomSquare[10];
  60.             Rectangle_Array[12] = RandomSquare[11];
  61.             Rectangle_Array[13] = RandomSquare[12];
  62.             Rectangle_Array[14] = RandomSquare[13];
  63.  
  64.         }
  65.  
  66.         //This is the function that creates the 15 random rectangles
  67.         private void CreateRandomRectangleList()
  68.         {
  69.             Rectangle_List = new List<Rectanglef[]>();
  70.  
  71.             for (int i = 0; i < Rectangle_Array.Length; i++)
  72.             {
  73.                 CreateRandomRectangle();
  74.                 Rectangle_List.Add(new Rectanglef[i]);
  75.             }
  76.         }
  77.  
  78.         //This is the function that creates the 15 random colors
  79.         private void CreateRandomColorList()
  80.         {
  81.             colorList = new List<int[]>();
  82.  
  83.             for(int i = 0; i < Rectangle_Array.Length; i++)
  84.             {
  85.                 CreateRandomColor();
  86.                 colorList.Add(new int[] { Kunst_Color1, Kunst_Color2, Kunst_Color3 });
  87.             }          
  88.         }
  89.  
  90.         //This is the function that generates the random numbers for the rectangles
  91.         private void CreateRandomRectangle()
  92.         {
  93.             Art_Size = Kunst.Next(0, 100);
  94.             Art_Size2 = Kunst.Next(0, 100);
  95.  
  96.             Art_Pos = Kunst.Next(310, 410);
  97.             Art_Pos2 = Kunst.Next(60, 300);
  98.         }
  99.  
  100.         //This is the function that generates the random numbers for the colors
  101.         private void CreateRandomColor()
  102.         {
  103.             Kunst_Color1 = Kunst.Next(0, 255);
  104.             Kunst_Color2 = Kunst.Next(0, 255);
  105.             Kunst_Color3 = Kunst.Next(0, 255);
  106.  
  107.         }
  108.  
  109.         public override void GameEnd()
  110.         {
  111.            
  112.         }
  113.  
  114.         public override void Update()
  115.         {
  116.             //Interactief Vierkant Code
  117.             if (GAME_ENGINE.GetKeyDown(Key.Add) && count < 4)
  118.             {
  119.                 count++;
  120.             }
  121.             if (GAME_ENGINE.GetKeyDown(Key.Subtract) && count > 0)
  122.             {
  123.                 count--;
  124.             }
  125.  
  126.             //Abstracte Kunst Code
  127.  
  128.             if (GAME_ENGINE.GetKeyUp(Key.Back))
  129.             {
  130.                 CreateRandomColorList();
  131.                 Rectangle = true;
  132.                
  133.             }
  134.  
  135.         }
  136.  
  137.         public override void Paint()
  138.         {
  139.  
  140.             GAME_ENGINE.SetColor(Color.Black);
  141.  
  142.             //Draw Name and Class
  143.             GAME_ENGINE.DrawString("Stijn van der Neut \n1GD2", 10, 10, 200, 200);
  144.  
  145.             //Draw Rectangles
  146.             GAME_ENGINE.DrawString("1.", 10, 50, 50, 50);
  147.  
  148.             int size_x = 40;
  149.             int size_y = 40;
  150.  
  151.             for (int i = 0; i < 5; i++)
  152.             {
  153.                 GAME_ENGINE.DrawRectangle(30 + (size_x / 2 * i), 50 + (size_y / 2 * i), 200 - (size_x * i), 200 - (size_y * i));
  154.             }
  155.  
  156.             //Draw Interactive Rectangles
  157.             int sizeX = 40;
  158.             int sizeY = 40;
  159.  
  160.             for (int i = 0; i < count; i++)
  161.             {
  162.                 GAME_ENGINE.DrawLine(30 + (sizeX / 2 * i), 260 + (sizeY / 2 * i), 225 - (sizeX / 2 * i), 260 + (sizeY / 2 * i));
  163.                 GAME_ENGINE.DrawLine(225 - (sizeX / 2 * i), 260 + (sizeY / 2 * i), 225 - (sizeX / 2 * i), 425 - (sizeY / 2 * i));
  164.  
  165.                 GAME_ENGINE.DrawLine(50 + (sizeX / 2 * i), 425 - (sizeY / 2 * i), 225 - (sizeX / 2 * i), 425 - (sizeY / 2 * i));
  166.                 GAME_ENGINE.DrawLine(50 + (sizeX / 2 * i), 425 - (sizeX / 2 * i), 50 + (sizeX / 2 * i), 280 + (sizeX / 2 * i));
  167.             }
  168.  
  169.             //Draw Abstract Art
  170.             GAME_ENGINE.DrawString("3.", 250, 50, 50, 50);
  171.             GAME_ENGINE.FillRectangle(300, 50, 300, 300);
  172.             GAME_ENGINE.SetColor(Color.White);
  173.             GAME_ENGINE.FillRectangle(305, 55, 290, 290);
  174.  
  175.             if (Rectangle == true)
  176.             {
  177.                 for (int i = 0; i < Rectangle_Array.Length; i++)
  178.                 {
  179.                     GAME_ENGINE.SetColor(colorList[i][0], colorList[i][1], colorList[i][2]);
  180.                     GAME_ENGINE.FillRectangle(Rectangle_Array[i]);
  181.                 }
  182.             }
  183.  
  184.         }
  185.     }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement