본문 바로가기
[ChatGPT] Sample Code 샘플 코드

[ChatGPT][Processing 프로세싱][2D RPG게임] Processing 프로그래밍 언어를 사용하는 간단한 2D RPG 타일맵의 예제 샘플

by byungwoo733 2023. 1. 23.
728x90
반응형
SMALL

Processing 프로그래밍 언어를 사용하는 간단한 2D RPG 타일맵의 예제 샘플

// Here is an example of a simple 2D RPG tilemap using the Processing programming language
PImage tileSheet;
int tileSize = 32;
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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
};

void setup() {
  size(512, 512);
  tileSheet = loadImage("tiles.png");
}

void draw() {
  for (int y = 0; y < map.length; y++) {
    for (int x = 0; x < map[y].length; x++) {
      int tile = map[y][x];
      int tileX = tile % 8;
      int tileY = tile / 8;
      image(tileSheet, x * tileSize, y * tileSize, tileSize, tileSize, tileX * tileSize, tileY * tileSize, tileSize, tileSize);
    }
  }
}
728x90
LIST

댓글