rpgつくりかけ

その場その場の思いつきで書いてみました. processingで。

その場その場の思いつきで書いてみました. processingで。

final int CHIP = 30;
int masu_x = 16;
int masu_y = 16;

int[][] map = {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
               {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
               };


String imgName[] = {"kusa.bmp", "stone3.bmp", "heroD.bmp"};//随時ココに追加しなければならない・・・.
PImage img[] = new PImage[20];//ここのサイズを指定しなければならない・・・.
//-------------------------------------------------------------------
void setup() {
  size(CHIP * masu_x, CHIP * masu_y);
  for(int i = 0; i < imgName.length; i++){
    img[i] = loadImage(imgName[i]);
  }
}

void draw() {
  for (int i = 0; i < masu_y; i++) {
    for (int k = 0; k < masu_x; k++) {
      image(img[map[i][k]], k * CHIP, i * CHIP, CHIP,CHIP);//map[y][x]であることに注意
    }
  }
}