Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.core.PApplet;
- public class run extends PApplet {
- public static void main(String[] args) {
- PApplet.main("run");
- }
- public void settings() {
- size(1000, 1000);
- }
- public void setup() {
- background(255);
- mapa();
- }
- public void draw() {
- }
- public void mapa() {
- int rdmorientacion = 0;
- int x = 0;
- int y = 0;
- boolean cumplido = false;
- int mapa[][] = new int[1000][1000];
- for (int i = 0; i < mapa.length; i++) {
- for (int j = 0; j < mapa[0].length; j++) {
- mapa[i][j] = 0;
- }
- }
- x = 500;
- y = 500;
- for (int i = 0; i < 100000; i++) {
- cumplido = false;
- while (cumplido == false) {
- rdmorientacion = (int) (Math.random() * 4) + 0;
- if (x + 1 < 1000 && x - 1 > 1 && y - 1 > 1 && y + 1 < 1000) {
- if (mapa[x][y] != 1) {
- mapa[x][y] = 1;
- cumplido = true;
- if (rdmorientacion == 0) { // up
- y--;
- }
- if (rdmorientacion == 1) { // left
- x--;
- }
- if (rdmorientacion == 2) { // right
- x++;
- }
- if (rdmorientacion == 3) {
- y++;
- }
- } else {
- if (rdmorientacion == 0) { // up
- y--;
- }
- if (rdmorientacion == 1) { // left
- x--;
- }
- if (rdmorientacion == 2) { // right
- x++;
- }
- if (rdmorientacion == 3) {
- y++;
- }
- }
- } else {
- x = 500;
- y = 500;
- }
- }
- }
- for (int i = 0; i < mapa.length; i++) {
- for (int j = 0; j < mapa[0].length; j++) {
- if (mapa[i][j] == 1) {
- fill(0);
- ellipse(i, j, 10, 10);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement