Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Test_Game
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- /* int[][] map = new int[][]
- {
- new int[] { 0,0,0,0,0,0 },
- new int[] { 0,0,0,0,0,0 },
- new int[] { 0,0,0,0,0,0 },
- new int[] { 0,0,0,0,0,0 },
- new int[] { 0,0,0,0,0,0 },
- new int[] { 0,0,0,0,0,0 }
- };
- */
- // CREATE MAP
- int size = new int();
- size = 64;
- int[,] map = new int[size, size];
- int crow = new int();
- int cpos = new int();
- crow = 0;
- cpos = 0;
- for (int i = 0; i < size * size; i++)
- {
- Random rnd = new Random();
- int type = rnd.Next(0, 2);
- map[cpos,crow] = type;
- cpos++;
- if (cpos == size)
- {
- cpos = 0;
- crow++;
- }
- }
- int row = new int();
- int pos = new int();
- int curx = new int();
- int cury = new int();
- Boolean temp = new Boolean();
- temp = false;
- row = 0;
- pos = 0;
- curx = 0;
- cury = 0;
- for (int i = 0; i < map.Length; i++)
- {
- if (map[row, pos] == 0)
- {
- PictureBox tile = new PictureBox();
- tile.Size = new System.Drawing.Size(64, 64);
- if (temp == false)
- {
- tile.BackColor = Color.Magenta;
- temp = true;
- }
- else
- {
- tile.BackColor = Color.Black;
- temp = false;
- }
- tile.Visible = true;
- tile.Location = new Point(curx, cury);
- this.Controls.Add(tile);
- curx = curx + 64;
- }
- if (map[row, pos] == 1)
- {
- PictureBox tile = new PictureBox();
- tile.Size = new System.Drawing.Size(64, 64);
- if (temp == false)
- {
- tile.BackColor = Color.Magenta;
- temp = true;
- }
- else
- {
- tile.BackColor = Color.Blue;
- temp = false;
- }
- tile.Visible = true;
- tile.Location = new Point(curx, cury);
- this.Controls.Add(tile);
- curx = curx + 64;
- }
- pos++;
- if (pos == size)
- {
- pos = 0;
- curx = 0;
- row++;
- cury = cury + 64;
- if (temp == true)
- {
- temp = false;
- } else
- {
- temp = true;
- }
- }
- }
- /* CREATE A PICTUREBOX
- PictureBox Player = new PictureBox();
- Player.Size = new System.Drawing.Size(64, 64);
- Player.BackColor = Color.Red;
- Player.Visible = true;
- Player.Location = new Point((this.Width / 2) - Player.Width / 2,(this.Height / 2) - Player.Height / 2);
- this.Controls.Add(Player);
- */
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement