Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Map
- {
- private int[][] mapx;
- private int cols;
- private int rows;
- public Map ()
- {
- cols = 20;
- rows = 20;
- mapx = new int[cols][rows];
- for(int i = 0; i < mapx.length; ++i)
- {
- for (int j = 0; i < mapx.length; ++j)
- {
- mapx[i][j] = (int) random (0, 3) * 100;
- }
- }
- }
- public void Show_Map ()
- {
- for(int i = 0; i < mapx.length; ++i)
- {
- for (int j = 0; i < mapx.length; ++j)
- {
- if (mapx[i][j] == 100)
- {
- fill (255, 0, 0);
- rect (i * 10, j * 10, 10, 10);
- }
- if (mapx[i][j] == 200)
- {
- fill (0, 255, 0);
- rect (i * 10, j * 10, 10, 10);
- }
- if (mapx[i][j] == 300)
- {
- fill (0, 0, 255);
- rect (i * 10, j * 10, 10, 10);
- }
- }
- }
- }
- }
- Map map1 = new Map ();
- void setup ()
- {
- size (300, 300, P2D);
- }
- void draw ()
- {
- background (255);
- map1.Show_Map ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement