Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace GameEngine
- {
- public class Opdracht2 : AbstractGame
- {
- int count = 0;
- Rectanglef[] Rectangle_Array = new Rectanglef[15];
- Random Kunst = new Random();
- private Rectanglef[] RandomSquare = new Rectanglef[15];
- private bool Rectangle = false;
- private int Kunst_Color1;
- private int Kunst_Color2;
- private int Kunst_Color3;
- private int Art_Pos;
- private int Art_Pos2;
- private int Art_Size;
- private int Art_Size2;
- private List<int[]> colorList;
- private List<Rectanglef[]> Rectangle_List;
- public override void GameStart()
- {
- for (int i = 0; i < RandomSquare.Length; i++)
- {
- Art_Size = Kunst.Next(0, 100);
- Art_Size2 = Kunst.Next(0, 100);
- Art_Pos = Kunst.Next(310, 410);
- Art_Pos2 = Kunst.Next(60, 300);
- RandomSquare[i] = new Rectanglef(Art_Pos, Art_Pos2, Art_Size, Art_Size2);
- }
- Rectangle_Array[0] = RandomSquare[0];
- Rectangle_Array[2] = RandomSquare[1];
- Rectangle_Array[3] = RandomSquare[2];
- Rectangle_Array[4] = RandomSquare[3];
- Rectangle_Array[5] = RandomSquare[4];
- Rectangle_Array[6] = RandomSquare[5];
- Rectangle_Array[7] = RandomSquare[6];
- Rectangle_Array[8] = RandomSquare[7];
- Rectangle_Array[9] = RandomSquare[8];
- Rectangle_Array[10] = RandomSquare[9];
- Rectangle_Array[11] = RandomSquare[10];
- Rectangle_Array[12] = RandomSquare[11];
- Rectangle_Array[13] = RandomSquare[12];
- Rectangle_Array[14] = RandomSquare[13];
- }
- //This is the function that creates the 15 random rectangles
- private void CreateRandomRectangleList()
- {
- Rectangle_List = new List<Rectanglef[]>();
- for (int i = 0; i < Rectangle_Array.Length; i++)
- {
- CreateRandomRectangle();
- Rectangle_List.Add(new Rectanglef[i]);
- }
- }
- //This is the function that creates the 15 random colors
- private void CreateRandomColorList()
- {
- colorList = new List<int[]>();
- for(int i = 0; i < Rectangle_Array.Length; i++)
- {
- CreateRandomColor();
- colorList.Add(new int[] { Kunst_Color1, Kunst_Color2, Kunst_Color3 });
- }
- }
- //This is the function that generates the random numbers for the rectangles
- private void CreateRandomRectangle()
- {
- Art_Size = Kunst.Next(0, 100);
- Art_Size2 = Kunst.Next(0, 100);
- Art_Pos = Kunst.Next(310, 410);
- Art_Pos2 = Kunst.Next(60, 300);
- }
- //This is the function that generates the random numbers for the colors
- private void CreateRandomColor()
- {
- Kunst_Color1 = Kunst.Next(0, 255);
- Kunst_Color2 = Kunst.Next(0, 255);
- Kunst_Color3 = Kunst.Next(0, 255);
- }
- public override void GameEnd()
- {
- }
- public override void Update()
- {
- //Interactief Vierkant Code
- if (GAME_ENGINE.GetKeyDown(Key.Add) && count < 4)
- {
- count++;
- }
- if (GAME_ENGINE.GetKeyDown(Key.Subtract) && count > 0)
- {
- count--;
- }
- //Abstracte Kunst Code
- if (GAME_ENGINE.GetKeyUp(Key.Back))
- {
- CreateRandomColorList();
- Rectangle = true;
- }
- }
- public override void Paint()
- {
- GAME_ENGINE.SetColor(Color.Black);
- //Draw Name and Class
- GAME_ENGINE.DrawString("Stijn van der Neut \n1GD2", 10, 10, 200, 200);
- //Draw Rectangles
- GAME_ENGINE.DrawString("1.", 10, 50, 50, 50);
- int size_x = 40;
- int size_y = 40;
- for (int i = 0; i < 5; i++)
- {
- GAME_ENGINE.DrawRectangle(30 + (size_x / 2 * i), 50 + (size_y / 2 * i), 200 - (size_x * i), 200 - (size_y * i));
- }
- //Draw Interactive Rectangles
- int sizeX = 40;
- int sizeY = 40;
- for (int i = 0; i < count; i++)
- {
- GAME_ENGINE.DrawLine(30 + (sizeX / 2 * i), 260 + (sizeY / 2 * i), 225 - (sizeX / 2 * i), 260 + (sizeY / 2 * i));
- GAME_ENGINE.DrawLine(225 - (sizeX / 2 * i), 260 + (sizeY / 2 * i), 225 - (sizeX / 2 * i), 425 - (sizeY / 2 * i));
- GAME_ENGINE.DrawLine(50 + (sizeX / 2 * i), 425 - (sizeY / 2 * i), 225 - (sizeX / 2 * i), 425 - (sizeY / 2 * i));
- GAME_ENGINE.DrawLine(50 + (sizeX / 2 * i), 425 - (sizeX / 2 * i), 50 + (sizeX / 2 * i), 280 + (sizeX / 2 * i));
- }
- //Draw Abstract Art
- GAME_ENGINE.DrawString("3.", 250, 50, 50, 50);
- GAME_ENGINE.FillRectangle(300, 50, 300, 300);
- GAME_ENGINE.SetColor(Color.White);
- GAME_ENGINE.FillRectangle(305, 55, 290, 290);
- if (Rectangle == true)
- {
- for (int i = 0; i < Rectangle_Array.Length; i++)
- {
- GAME_ENGINE.SetColor(colorList[i][0], colorList[i][1], colorList[i][2]);
- GAME_ENGINE.FillRectangle(Rectangle_Array[i]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement