Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button2_Click(object sender, EventArgs e)
- {
- //obj = ds_list_find_value( frames, frame_num );
- //set_reg( obj, 1,1,198,198, block_black )
- block[, ,] tmp = myroom.getlist();
- int _x = 3;
- int _y = 1;
- int pos = 0;
- int[] pos_x = new int[100000];
- int[] pos_y = new int[100000];
- pos_x[0] = _x;
- pos_y[0] = _y;
- int[] find = new int[100000];
- Random r = new Random();
- List<int> rand = new List<int>();
- while (true)
- {
- int found = 0;
- if (_x > 3)
- if (tmp[_x - 2, _y, 1].type != curblock.type)
- {
- find[found] = 0; found += 1;
- }
- if (_x < worldWidth - 2)
- if (tmp[_x + 2, _y, 1].type != curblock.type)
- {
- find[found] = 2; found += 1;
- }
- if (_y > 1)
- if (tmp[_x, _y - 2, 1].type != curblock.type)
- {
- find[found] = 1; found += 1;
- }
- if (_y < worldHeight - 2)
- if (tmp[_x, _y + 2, 1].type != curblock.type)
- {
- find[found] = 3; found += 1;
- }
- rand.Clear();
- if (found == 0)
- {
- pos -= 1;
- _x = pos_x[pos];
- _y = pos_y[pos];
- //if pos > 4000 show_message( pos )
- if (pos == 0) break;
- }
- else
- {
- pos += 1;
- for (int i = 0; i < found; i += 1)
- {
- rand.Add(find[i]);
- }
- //Listo.Listo.Shuffle<int>(rand);
- rand[0] = rand[r.Next() % rand.Count];
- switch (rand[0])
- {
- case 0:
- myroom[_x - 1, _y, 1] = curblock;
- myroom[_x - 1, _y, 1] = curblock;
- myroom[_x - 2, _y, 1] = curblock;
- tmp[_x - 1, _y, 1] = curblock;
- tmp[_x - 1, _y, 1] = curblock;
- tmp[_x - 2, _y, 1] = curblock;
- _x -= 2;
- pos_x[pos] = _x;
- pos_y[pos] = _y;
- break;
- case 1:
- myroom[_x, _y - 1, 1] = curblock;
- myroom[_x, _y - 2, 1] = curblock;
- tmp[_x, _y - 1, 1] = curblock;
- tmp[_x, _y - 2, 1] = curblock;
- _y -= 2;
- pos_x[pos] = _x;
- pos_y[pos] = _y;
- break;
- case 2:
- myroom[_x + 1, _y, 1] = curblock;
- myroom[_x + 2, _y, 1] = curblock;
- tmp[_x + 1, _y, 1] = curblock;
- tmp[_x + 2, _y, 1] = curblock;
- _x += 2;
- pos_x[pos] = _x;
- pos_y[pos] = _y;
- break;
- case 3:
- myroom[_x, _y + 1, 1] = curblock;
- myroom[_x, _y + 2, 1] = curblock;
- tmp[_x, _y + 1, 1] = curblock;
- tmp[_x, _y + 2, 1] = curblock;
- _y += 2;
- pos_x[pos] = _x;
- pos_y[pos] = _y;
- break;
- }
- }
- }
- myroom[1, 1, 1] = curblock;
- myroom[1, 2, 1] = curblock;
- myroom[2, 1, 1] = curblock;
- myroom[2, 2, 1] = curblock;
- myroom.flush();
- }
Advertisement
Add Comment
Please, Sign In to add comment