地形作成ゲーム The game which makes the shape of the ground

processingで作った地形を作って遊ぶゲームです。
木、土、葉っぱ、水、岩を置いたり消したりできます。
左クリックで土や草や水を置くことができます。
右クリックで土や木、水などを掘ったり取ったりできます。
人の操作は、ASDWキーで、←↓→↑を操作します。
人が持つブロックは、◀▶で選択します。

This was made by processing. The game with which the shape of the land is made.
This game is able to put or get a wood,a ground, a leaf, water and a rock.
When you left-click, it’s possible to put a block of a ground, grass and water.
When you right-click, it’s possible to get a ground, a wood and a water.
The way to move a main character is “ASDW” key, and you can change the direction “←↓→↑”.
The block the main character holds in his hand is chosen in “◀▶” key.

shift+Dキーを押すと、どれだけの負荷がかかっているかの情報を見ることができます。いろんなボタンが表示されますが、Dキーでボタンを消せば、ゲームに集中できます。

Pressing “shift + D” key will display information on load on the PC. Various buttons are displayed, but you can concentrate on the game by pressing the “D” key and deleting the display.

動画↓

zipダウンロードは、こちら

 

ソースコードは、こちら↓

地形 ground

int[][] veryerror = {
  //50x5
  {1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, }, 
  {1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, }, 
  {1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, }, 
  {1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, }, 
  {0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, }, 
};
float framerate = frameRate;
int seed = int(random(2147483647));
int fileerror;
boolean debug;
void ik(PImage data, float x, float y, float k, boolean h) {
  PGraphics pg = createGraphics(data.width, data.height);
  if (h) {
    k = -k;
    pg.beginDraw();
    pg.scale(-1, 1);
    pg.image(data, -data.width, 0);
    pg.endDraw();
    data = pg.get();
  }
  x -= (data.width/2);
  y -= (data.height/2);
  pushMatrix();
  translate(x + (data.width/2), y + (data.height/2));
  rotate(radians(k));
  image(data, 0-data.width/2, 0-data.height/2);  
  popMatrix();
  rotate(0);
}
boolean[] Key = new boolean[128];
PFont font;
String fontpass = "data/font32.vlw";
void setup() {
  if (loadBytes(fontpass) == null) {
    fileerror = 2;
  } else {
    font = loadFont(fontpass);
    textFont(font);
  }
  ;
  size(720, 512);
  //45x32
  noStroke();
  noSmooth();
  bgsetting(1);
  if (load() != 1)fileerror++; //gazouworo-do
  println(fileerror);
  if (fileerror > 0)noLoop();
  if (fileerror == 1) {
    textSize(32);
    background(0);
    fill(255, 255, 255);
    text("画像ファイルが見当たらねぇんだけど、", 3, 32);
    text("no image file", 3, 64);
    textSize(16);
    text("これらのファイルが見つかりません", 3, 128-16);
    text(errorfilelist, 3, 128);
    textSize(16);
  }
  if (fileerror >= 2) {
    background(0, 0, 0);
    for (int i = 0; i < 50; i++) {
      for (int f = 0; f < 5; f++) {
        if (veryerror[f][i] == 1) {
          fill(255);
          rect((i+0.5)*14.4, (f+15)*14.4, 14.4, 14.4);
        }
      }
    }
  }
  if (fileerror == 0) {
    seise(0);
  }
}
boolean guie = true;
int mla = 0;
void keisoku(String a, int y) {
  if (debug) {
    String in = a;
    int scx = (millis()-mla);
    mla = millis();
    fill(0);
    textSize(16);
    text(in, 0, (y+1)*18);
    text(" Time", 64, (y+1)*18);
    fill(0);
    rect((120)-1, (y*18)-1+2, (scx*2)+2, 16+2);
    fill(255);
    rect(120, y*18+2, scx*2, 16);
  }
}
void draw() {
  if (frameCount%30 == 0) {
    framerate = frameRate;
  }
  if (fileerror == 0) {
    ;
    background(bgcolor);
    bg();
    keisoku("ハイケイ ", 0);
    scale(1);
    pld();
    fill(0);
    textSize(16);
    keisoku("プレイヤー", 1);
    mdraw();
    keisoku("マップ", 2);
    if (frameCount < 5) {
      for (int i = 0; i < 100; i++) {
        mm();
      }
    }
    if (frameCount%4 == 0)mm();
    keisoku("エンザン", 3);
    if (Key['N'])guie = false;
    if (Key['n'])guie = true;
    if (guie)gdraw();
    keisoku("ジーユーアイ", 4);
    ;
    if (Key['D']) {
      debug = true;
    }
    if (Key['d']) {
      debug = false;
    }
  }
}

key

void keyPressed() {
  int t = key;
  //println(int(keyCode));
  if (t < 128) {
    Key[t] = true;
  }
  if (t > 256) {
    t = keyCode;
    if (t < 128) {
      Key[t] = true;
    }
  }
}
void keyReleased() {
  int t = key;
  if (t < 128) {
    Key[t] = false;
  }
  if (t > 256) {
    t = keyCode;
    if (t < 128) {
      Key[t] = false;
    }
  }
}

bg

PGraphics bger;
PImage kumo0, kumo1, kumos0, kumos1;
float s;
int kky = 256, kkys = -16;
void bgsetting(int ba) {
  kumo0 = loadImage("tex/kr.png");
  kumo1 = loadImage("tex/kl.png");
  kumos0 = loadImage("tex/krs.png");
  kumos1 = loadImage("tex/kls.png");
  background(bgcolor);
  bger = createGraphics(720+32, 512);
  bger.noSmooth();
  noiseDetail(1);
  for (int i = 0; i < ba; i++) {
    bger.beginDraw(); 
    bger.noStroke();
    bger.fill(bgcolor);
    bger.rect(719, 0, 1, 512);
    bger.fill(255);
    bger.rect(719, kky+16, 1, 512-kky);
    if (frameCount%50 == 0) {
      if (noise(s)*2 > (float)int(((float)kky/512)*100)/100) {
        kkys = 1;
      } else {
        kkys = -1;
      }
    }
    kky += kkys;
    //println((float)int(((float)y/512)*20)/20);
    s += 0.05;
    bger.image(bger.get(1, 0, 719, 512), 0, 0);
    bger.endDraw();
  }
}
boolean fai = false;
int okk;
void bg() {
  background(bgcolor);
  noiseDetail(2);
  if (frameCount%2 == 1) {
    bger.beginDraw(); 
    okk = kkys;
    if (frameCount%32 == 1) {
      bger.noStroke();
      bger.fill(bgcolor);
      bger.rect(736, 0, 16, 512);
      bger.fill(255);
      bger.rect(736, kky+16, 16, 512-kky);
      if (kkys > 0) {
        bger.image(kumo1, 736, kky);
        bger.tint(bgcolor);
        bger.image(kumos1, 736-16, kky-18);
        bger.noTint();
      } else {
        bger.image(kumo0, 736, kky);
        bger.tint(bgcolor);
        bger.image(kumos0, 736-16, kky-18);
        bger.noTint();
      }
      kkys = okk;
      if (noise(s)/2 > (float)int(((float)kky/512)*64)/64) {
        kkys = 16;
      } else {
        kkys = -16;
      }
      //println((float)int(((float)y/512)*20)/20);
      s += 0.15/2;
      if (int(okk) == int(kkys))kky += kkys;
    }
    bger.image(bger.get(1, 0, 751, 512), 0, 0);
    bger.endDraw();
  }
  image(bger, 0, 0);
  fill(bgcolor);
  rect(0, 256, 720, 256);
}

gui

PImage sloti;
boolean c = false;
float ssa = 0;
int[] iteml = {
  1, 
  2, 
  3, 
  0, 
  4, 
  7, 
  8, 
};
int sl = 3;
int[] sitem = new int[iteml.length];
int[] tsitem = new int[iteml.length];
boolean tm, tm2;
void gdraw() {
  int l = iteml.length;
  for (int i = 0; i < l; i++) {
    int ss = 0;
    if (tsitem[i] != sitem[i]) {
      ss = -1;
    }
    if (sitem[i] > 1024)sitem[i] = 1024;
    tint(255, 128);
    image(sloti, 360+((i-((float)l/2))*48), 0);
    noTint();
    if (i == sl)image(sloti, 360+((i-((float)l/2))*48), 0);
    tint(0, 128);
    image(blocks[iteml[i]], 360+((i-((float)l/2))*48)+8+1, 8+1, 32, 32);
    tint(255);
    if (sitem[i] > 0)noTint();
    image(blocks[iteml[i]], 360+((i-((float)l/2))*48)+7, 7, 32, 32);
    fill(64);
    if (ss < 0) {
      blendMode(ADD);
      rect(360+((i-((float)l/2))*48)+7, 7, 32, 32);
      blendMode(BLEND);
    }
    textSize(16);
    if (sitem[i] > 0)tex(str(sitem[i]), 360+((i-((float)l/2))*48)+43-(textWidth(str(sitem[i]))), 35, 230);
    if (sitem[i] < 0)sitem[i] = 0;
    //チート
    if (frameCount < 10) {
      if (iteml[i] != 0)sitem[i] = 16;
    }
    tsitem[i] = sitem[i];
    //チート終わり
  }
  if (Key[RIGHT]) {
    if (!tm) {
      sl++;
      if (sl >= l)sl = 0;
      tm = true;
    }
  } else {
    tm = false;
  }
  if (Key[LEFT]) {
    if (!tm2) {
      sl--;
      if (sl < 0)sl = l-1;
      tm2 = true;
    }
  } else {
    tm2 = false;
  }
  ;
  if (debug) {
    c = false;
    if (bot("ON", 662, 0, ken == 1))ken = 1;
    if (bot("OFF", 662-60, 0, ken == 0))ken = 0;
    if (bot("チート", 662, 60, c)) {
      //c = true;
      for (int i = 0; i < l; i++) {
        sitem[i] = 9999;
      }
    }
    if (bot("デバック", 662-60, 60, c)) {
      for (int i = 0; i < 450; i++) {
        for (int f = 0; f < 31; f++) {
          map[i][f] = 0;
        }
      }
    }
    /*
  if (bot("-", 662-60, 95, c)) {
     ssa -= 0.002;
     seise(ssa);
     for(int i = 0; i < 30; i++){
     mm(); 
     }
     }
     if (bot("+", 662, 95, c)) {
     ssa += 0.002;
     seise(ssa);
     for(int i = 0; i < 30; i++){
     mm(); 
     }
     }
     */
    textSize(16);
    tex("キーボード操作", 602, 47, 240);
    ;
    fill(0);
  }
  //rect((float)sx/10, 0, 1, 1);
}
;
;
boolean bot(String t, float x, float y, boolean f) {
  int w = 50;
  int h = 40-8;
  //w = int(textWidth(t)+16)-8;
  x += 2;
  y += 2;
  ;
  w -= 2;
  h -= 2;
  x += 2;
  y += 2;
  boolean a = false;
  if (x <= mouseX && x+w >= mouseX) {
    if (y <= mouseY && y+h >= mouseY) {
      a = true;
    }
  }
  w += 2;
  h += 2;
  x -= 2;
  y -= 2;
  int ofx = 0;
  int ofy = -4;
  ;
  w -= 2;
  h -= 2;
  x += 3;
  y += 4;
  ;
  fill(0, 64);
  rect(x, y, w, h);
  if (f)rect(x, y, w, h);
  fill(255);
  text(t, x+(w/2)-(textWidth(t)/2)+ofx, h+2+y-7+ofy);
  if (!mousePressed)a = false;
  return a;
}

img

PImage pla, plb, plu;
PImage[] blocks = new PImage[256];
String m;
String errorfilelist = "";
PImage loadimage(String in) {
  PImage out = loadImage(in);
  if (out == null) {
    fileerror = 1;
    errorfilelist += in+"\n";
  }
  return out;
}
int load() {
  int ok = 1;
  pla = loadimage("tex/asi.png");
  plb = loadimage("tex/body.png");
  plu = loadimage("tex/ude.png");
  blocks[0] = loadimage("tex/air.png");
  blocks[1] = loadimage("tex/tuti.png");
  blocks[2] = loadimage("tex/kusa.png");
  blocks[3] = loadimage("tex/isi.png");
  blocks[4] = loadimage("tex/mizuk.png");
  blocks[5] = loadimage("tex/mizu.png");
  blocks[6] = loadimage("tex/mizu2.png");
  blocks[7] = loadimage("tex/woodf.png");
  blocks[8] = loadimage("tex/ha.png");
  blocks[9] = loadimage("tex/point.png");
  for(int i = 128; i < 128+64; i++){
    blocks[i] = loadimage("tex/speq.png").get((i-128)*16,0,16,16);
  }
  PImage nulli = loadimage("tex/null.png");
  for (int i = 0; i < 256; i++) {
    if (blocks[i] == null)blocks[i] = nulli;
  }
  sloti = loadimage("tex/slota.png");
  return ok;
}
void tex(String in, float x, float y) {
  x += 2;
  y += 7;
  fill(0);
  for (int i = -2; i < 3; i++) {
    for (int f = -2; f < 3; f++) {
      text(in, x+i, y+f);
    }
  }
  fill(255);
  text(in, x, y);
}
void tex(String in, float x, float y, float t) {
  x += 2;
  y += 7;
  fill(0, t/16);
  for (int i = -2; i < 3; i++) {
    for (int f = -2; f < 3; f++) {
      text(in, x+i, y+f);
    }
  }
  fill(255, t);
  text(in, x, y);
}
PImage mt(PImage data, PImage data2, boolean f) {
  PGraphics pg = createGraphics(data.width, data.height);
  pg.beginDraw();
  pg.image(data, 0, 0);
  if(!f)pg.tint(255,128);
  pg.image(data2, 10, 48);
  pg.endDraw();
  return pg;
}

map

int[][] map = new int[450][32];
boolean[][] mapa = new boolean[450][32];
color bgcolor = color(224, 240, 255);
int sx = 203*16+320;
void seise(float tw) {
  //seed = 1470879616;
  for (int i = 0; i < 450; i++) {
    for (int f = 0; f < 32; f++) {
      map[i][f] = 0;
      mapa[i][f] = false;
      if (random(0.0, 1.0) > 0)mapa[i][f] = true;
    }
  }
  noiseDetail(5);
  noiseSeed(seed);
  randomSeed(seed);
  println("seed = "+seed);
  float n = 0;
  float na = 0;
  int t = 0;
  int ot = 0;
  int bck = 0;
  for (int i = 0; i < 450; i++) {
    float k = (((noise(n, tw)-0.5)*2)*16)+16;
    n += 0.03;
    na += 0.07;
    ;
    ot = t;
    t = int(k);
    boolean af = false;
    if (noise(na, tw) < 0.1)af = true;
    for (int f = t; f < 32; f++) {
      if (t <= 16) {
        map[i][f] = 2;
      } else {
        map[i][f] = 1;
      }
    }
    for (int f = t+1; f < 32; f++) {
      map[i][f] = 1;
    }
    if (af) {
      for (int f = t; f < noise(10, 16, tw); f++) {
        map[i][f] = 3;
      }
    }
    if (t > 17) {
      map[i][t] = 3;
      if (t+1 < 32)map[i][t+1] = 3;
    } else {
      if (random(100) < 12 && i%7 == 0) {
        map[i][t+1] = 1;
        map[i][t] = 1;
        if (t > 1)map[i][t-1] = 7;
        if (t > 2)map[i][t-2] = 7;
        if (t > 3)map[i][t-3] = 7;
        //if (t > 3 && i > 2)map[i-2][t-3] = 8;
        //if (t > 3 && i > 1)map[i-1][t-3] = 8;
        //if (t > 3 && i < 450-2)map[i+2][t-3] = 8;
        //if (t > 3 && i < 450-1)map[i+1][t-3] = 8;
        ;
        if (t > 4 && i > 2)map[i-2][t-4] = 8;
        if (t > 4 && i > 1)map[i-1][t-4] = 8;
        if (t > 4)map[i][t-4] = 7;
        if (t > 4 && i < 450-2)map[i+2][t-4] = 8;
        if (t > 4 && i < 450-1)map[i+1][t-4] = 8;
        ;
        if (t > 5 && i > 2)map[i-2][t-5] = 8;
        if (t > 5 && i > 1)map[i-1][t-5] = 8;
        if (t > 5)map[i][t-5] = 7;
        if (t > 5 && i < 450-2)map[i+2][t-5] = 8;
        if (t > 5 && i < 450-1)map[i+1][t-5] = 8;
        ;
        if (t > 6 && i > 2)map[i-2][t-6] = 8;
        if (t > 6 && i > 1)map[i-1][t-6] = 8;
        if (t > 6)map[i][t-6] = 8;
        if (t > 6 && i < 450-2)map[i+2][t-6] = 8;
        if (t > 6 && i < 450-1)map[i+1][t-6] = 8;
        ;
        if (t > 7 && i > 7)map[i-1][t-7] = 8;
        if (t > 7)map[i][t-7] = 8;
        if (t > 7 && i < 450-1)map[i+1][t-7] = 8;
        ;
      }
    }
    for (int f = int(noise((float)i/10)*5)+24; f < 32; f++) {
      if (map[i][f] != 0)map[i][f] = 3;
    }
    for (int f = 0; f < 32; f++) {
      if (noise((float)i/24, (float)f/24) < 0.3) {
        if (map[i][f] == 1 || map[i][f] == 2 || map[i][f] == 3) {
          map[i][f] = 0;
          bck++;
        }
      }
    }
    if (map[i][16] == 0)map[i][16] = 4;
    if (random(100) < 2 && t > 0)map[i][t-1] = 4;
  }
  for (int i = 0; i < 450; i++) {
    for (int f = 0; f < 32; f++) {
      if (i <= 0 || i > 430)map[i][f] = 9;
    }
  }
  println(bck+"ブロックをぶっ壊しました");
}
float fa = 0;
void mm() {
  int t = sx/16;
  if (t > 448-50)t = 448-50;
  if (sx >= (448-50)*16) {
    sx = ((448-50)*16)-1;
    plx -= 1;
    plxs = 0;
  }
  //fa -= 0.5;
  if (fa < 0)fa = 0;
  for (int x = -1; x < 450; x++) {
    fa -= 1;
    if (fa < 0)fa = 0;
    for (int y = 0; y < 32; y++) {
      int xt = x;
      if (xt < 0)xt = 0;
      if (xt >= 450)xt = 449;
      int a = map[xt][y];
      if (fa <= 0) {
        if (map[xt][y] == 1 || map[xt][y] == 2 || map[xt][y] == 3 || map[xt][y] == 7) {
          if (y < 32-1) {
            if (map[xt][y+1] == 0 || map[xt][y+1] == 4) {
              if (xt > 1 && xt < 449) {
                if (map[xt-1][y] == 0 || map[xt+1][y] == 0) {
                  map[xt][y+1] = map[xt][y];
                  map[xt][y] = 0;
                  fa = 1;
                }
              }
            }
          }
        }
      }
      if (y > 1 && map[xt][y] == 2) {
        if (map[xt][y-1] != 0 && map[xt][y-1] != 4) {
          map[xt][y] = 1;
        }
      }
      if (y > 0 && map[xt][y] == 4 && map[xt][y-1] == 0)a = 5;
      ;
      if (fa <= 0) {
        ;
        if (y+1 < 32) {
          if (map[xt][y] == 4 || map[xt][y] == 5) {
            if (map[xt][y+1] > 0 && map[xt][y+1] < 4) {
              if (xt < 449) {
                if (map[xt+1][y] == 0) {
                  map[xt+1][y] = 4;
                  fa = 3;
                }
              }
              if (xt > 000) {
                if (map[xt-1][y] == 0) {
                  map[xt-1][y] = 4;
                  fa = 2;
                }
              }
              //if(y > 1)map[xt][y-1] = 0;
            }
            if (map[xt][y+1] == 0) {
              map[xt][y+1] = 4;
              //if(y > 1)map[xt][y] = 0;
              fa = 1;
            }
          }
        }
        ;
      }
    }
  }
}
void mdraw() {
  ;
  int t = sx/16;
  for (int x = -1; x < 46; x++) {
    int f = 0;
    for (int y = 0; y < 32; y++) {
      int xt = x+t;
      if (xt < 0)xt = 0;
      int a = map[xt][y];
      if (y > 0 && map[xt][y] == 4 && map[xt][y-1] == 0)a = 5;
      blendMode(BLEND);
      noTint();

      if (a != 0 && a != 4 && a != 8 && a != 7) {
        f++;
      }
      tint(255-(f*3));
      if (a >= 4 && a <= 6) {
        blendMode(MULTIPLY);
        tint(255, 80);
      }
      if (a != 0) {
        image(blocks[a], (x*16)-(sx%16), y*16);
      }
      if (a == 5) {
        blendMode(ADD);
        tint(255);
        image(blocks[128+(((frameCount+(x*30*30))%(64*30))/30)], (x*16)-(sx%16), y*16);
      }
      ;
    }
    ;
  }
  blendMode(BLEND);
  noTint();
  image(blocks[9], (mx*16)+(sx%16), (my*16));
  //sx = int(sx/16)*16;
}

player

int ken = 1;
float plx = 3248+(720), ply = 64, plxs, plys, plr, plar, plrr, pls = 10;
float plm = 54;
float pff = 1;
boolean je = false;
boolean pae = false;
float grav = 1;
float jp = 1;
boolean dow = false;
int bta;
int mx,my;
void pld() {
  ;
  pae = true;
  //if (sx%16 == 0)pae = true;
  ;
  //プレイヤー描画
  tint(220, 200, 180);
  int up = 0;
  int ap = 0;
  if (plxs < 0)up = 6;
  if (plxs < 0)ap = -3;
  ply -= plb.height;
  plx -= plb.width/2;
  plx -= sx;
  int tem = 0;
  plm = 52;
  pff = 1;
  if (dow) {
    tem = 18;
    plm = 75;
    pff = 0.5;
  }
  float fa = 0;
  /*
  if(frameCount%2 == 0){
   fa -= 0.5; 
   }else{
   fa += 0.5;
   }
   */
  bta = (tem+bta*10)/11;
  //println(dow);
  ik(pla, plx+17+ap, ply+32+fa, (-int(plar/3)*3)+plrr, plxs < 0);//後ろ足
  ik(plu, plx+12+up, ply+20+bta+fa, (-int(plr/3)*3)+plrr+2, plxs < 0);//後ろ腕
  noTint();
  ik(pla, plx+17+ap, ply+32+fa, (+int(plar/3)*3)+plrr, plxs < 0);//前足
  ik(plb, int(plx+15.5+0.5), int(ply+32+bta+0.5), (0+plrr), plxs < 0);//体
  int baa = iteml[sl];
  PImage hand = mt(plu, blocks[baa], sitem[sl] > 0);
  ik(hand, plx+12+up+fa, ply+21+bta, (+int(plr/3)*3)+plrr, plxs < 0);//前腕
  ply += plb.height;
  plx += plb.width/2;
  plx += sx;
  plr = -sin(pls)*25*pff;
  plar = sin(pls)*20*pff;
  //プレイヤー描画終了 
  int t = sx/16;
  //プレイヤー操作
  ;
  /*
  if (Key[LEFT ])plxs += -0.1;
   if (Key[RIGHT])plxs += +0.1;
   */
  ;
  int xa = mouseY - pmouseY;
  if (ken == 1) {
    if (Key['a'])plxs += -0.1;
    if (Key['d'])plxs += +0.1;
    if (je)if (Key['w'])plys = -2.1*2*jp;
    if (Key['s']) {
      dow = true;
    } else {
      dow = false;
    }
  } else {
    if (mouseX < plx-sx-16)plxs += -0.1;
    if (mouseX > plx-sx+16)plxs += +0.1;
    if (je)if (xa < -4)plys = -2.1*2*jp;
    if (je)if (xa < -16)plys += -1*2*jp;
  }
  //println(sx%16);
  mx = int(round((mouseX-(sx%16))/16));
  my = (mouseY)/16;
  if (mousePressed) {
    if (my > 31)my = 31;
    if (my < 0)my = 0;
    if (mouseButton == RIGHT) {
      for (int i = 0; i < iteml.length; i++) {
        if (map[mx+t][my] == iteml[i] && map[mx+t][my] != 0)sitem[i]++;
      }
      map[mx+t][my] = 0;
    }
    if (mouseButton == LEFT) {
      int b = iteml[sl];
      if (sitem[sl] > 0 && map[mx+t][my] == 0 || map[mx+t][my] == 4 || map[mx+t][my] == 5) {
        if (b != 0) {
          map[mx+t][my] = b;
          sitem[sl]--;
        }
      }
    }
  }
  ;
  //if (je)if (Key[UP])plys = -2;
  plys += 0.2/2*grav;
  if (ply > 512)plys = -0.1;
  plxs /= plm/50;
  //
  float aplxs = plxs;
  if (aplxs < 0)aplxs = -aplxs;
  pls += aplxs/13;
  if (pls > TWO_PI)pls = 0;
  pff += 0.1;
  if (aplxs < 0.2)pff -= 0.2;
  if (pff > 1)pff = 1;
  if (pff < 0)pff = 0;
  ;
  //println(pls);
  //プレイヤー操作終了
  ;
  if (t > 449-45)t = 449-45;
  //問題の当たり判定プログラム
  int px = int(plx/16);
  int py = int(ply/16);
  if (py >= 32)py = 31-1;
  if (px >= 450-1)px = 449-1;
  if (px < 1)px = 1;
  if (py < 1)py = 1;
  textSize(32);
  int ff = map[px][py];
  //tex(" "+str(int(ff)), 0, 24);
  grav = 1;
  je = false;
  if (ff > 0 && ff < 4 || ff > 6) {
    plys = -0.01;
    ply = py*16;
    je = true;
  }
  /*
  if(Key[SHIFT]){
    grav = 0.05;
    je = true;
  }
  */
  ff = map[px-1][py-1];
  if (ff == 0 && py > 2)ff = map[px-1][py-2];
  if (!dow)if (ff == 0 && py > 3)ff = map[px-1][py-3];
  if (ff >= 4 && ff <= 6)ff = 0;
  if (ff > 0) {
    plx += 2;
    plxs = -0.01;
  }
  ff = map[px+1][py-1];
  if (ff == 0 && py > 2)ff = map[px+1][py-2];
  if (!dow)if (ff == 0 && py > 3)ff = map[px+1][py-3];
  if (ff >= 4 && ff <= 6)ff = 0;
  if (ff > 0) {
    plx -= 2;
    plxs = +0.01;
  }
  ;
  if (py > 1)ff = map[px][py-1];
  jp = 1;
  if (ff >= 4 && ff <= 6) {
    ff = 0;
    grav = 0.4;
    je = true;
    jp = 0.2;
  }
  ;
  if (py > 4) {    
    ff = map[px][py-4];
    if (ff > 0 && ff < 4 || ff > 6) {
      plys = .5;
    }
  }
  ;
  if (px-t >= 45-4)sx += 4;
  if (px-t <= 4)sx -= 4;
  //加速度
  if (pae) {
    plx += plxs;
    ply += plys;
  }
  if (sx < 0)sx = 0;
  sx = ((round(sx/16)*16)+sx*15)/16;
  //println(px);
}

遊んでみてください。

Let’s play this game!

 

 

コメントを残す