Advertisement
Guest User

pene

a guest
Mar 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. import processing.core.PApplet;
  2.  
  3. public class run extends PApplet {
  4. public static void main(String[] args) {
  5. PApplet.main("run");
  6. }
  7.  
  8. public void settings() {
  9. size(1000, 1000);
  10. }
  11.  
  12. public void setup() {
  13. background(255);
  14. mapa();
  15. }
  16.  
  17. public void draw() {
  18.  
  19. }
  20.  
  21. public void mapa() {
  22. int rdmorientacion = 0;
  23. int x = 0;
  24. int y = 0;
  25. boolean cumplido = false;
  26.  
  27. int mapa[][] = new int[1000][1000];
  28.  
  29. for (int i = 0; i < mapa.length; i++) {
  30. for (int j = 0; j < mapa[0].length; j++) {
  31. mapa[i][j] = 0;
  32. }
  33. }
  34.  
  35. x = 500;
  36. y = 500;
  37.  
  38. for (int i = 0; i < 100000; i++) {
  39. cumplido = false;
  40. while (cumplido == false) {
  41.  
  42. rdmorientacion = (int) (Math.random() * 4) + 0;
  43. if (x + 1 < 1000 && x - 1 > 1 && y - 1 > 1 && y + 1 < 1000) {
  44. if (mapa[x][y] != 1) {
  45.  
  46. mapa[x][y] = 1;
  47. cumplido = true;
  48.  
  49. if (rdmorientacion == 0) { // up
  50. y--;
  51. }
  52. if (rdmorientacion == 1) { // left
  53. x--;
  54. }
  55. if (rdmorientacion == 2) { // right
  56. x++;
  57. }
  58. if (rdmorientacion == 3) {
  59. y++;
  60. }
  61.  
  62. } else {
  63.  
  64. if (rdmorientacion == 0) { // up
  65. y--;
  66. }
  67. if (rdmorientacion == 1) { // left
  68. x--;
  69. }
  70. if (rdmorientacion == 2) { // right
  71. x++;
  72. }
  73. if (rdmorientacion == 3) {
  74. y++;
  75. }
  76.  
  77. }
  78. } else {
  79. x = 500;
  80. y = 500;
  81. }
  82. }
  83. }
  84.  
  85. for (int i = 0; i < mapa.length; i++) {
  86. for (int j = 0; j < mapa[0].length; j++) {
  87. if (mapa[i][j] == 1) {
  88. fill(0);
  89. ellipse(i, j, 10, 10);
  90. }
  91. }
  92. }
  93.  
  94. }
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement