Last active
January 25, 2018 10:49
-
-
Save dz0/b9e06491a0a1644e499569f717909696 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final int cols = 3; | |
| final int rows = 3; | |
| //int[][] M = new int[cols][rows]; | |
| /* | |
| { | |
| {0, 0, 0 } , | |
| {0, 0, 0 } , | |
| {0, 0, 0 } | |
| } | |
| */ | |
| void setup() { | |
| size(300, 300); // turi atitikti rows*100, cols*100 | |
| // apsimetam, kad keli langeliai jau pažymėti | |
| //M[0][0] = 1; | |
| //M[1][2] = 1; | |
| /* bus: | |
| { | |
| {1, 0, 0 } , | |
| {0, 0, 1 } , | |
| {0, 0, 0 } | |
| } | |
| */ | |
| } | |
| void draw() { | |
| // Two nested loops allow us to visit every spot in a 2D array. | |
| // For every column I, visit every row J. | |
| fill(255); | |
| for (int i = 0; i < cols; i++) { | |
| for (int j = 0; j < rows; j++) { | |
| fill(255); | |
| rect(i*100, j*100, 100, 100); | |
| fill(0); // juoda spalva | |
| //if(M[j][i]==1) // jei langelis pažymėtas | |
| // text( "X", i*100+40, j*100+40); | |
| } | |
| } | |
| fill(0, 200, 0); | |
| int mouse_col = mouseX/100; | |
| int mouse_row = mouseY/100; | |
| rect(mouse_col*100, mouse_row*100, 100, 100); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment