疑似3DコインゲットGAME Pseudo 3D ” coin GAME”

Processingで作ったゲームです。
3Dに見えるように床の画像を工夫しました。
コインをゲットすると、ポイントがたまるので、コインに沿って進むように◀▶ボタンで操作します。
スペースキーでジャンプして、壁を飛び越えます。
妹が操作した動画です。⇩

It is a game made with Processing.
I devised so that the image of the floor looks like 3D.
As you earn a coin, you earn points, so use the ◀ ▶ button to move along the coin.
Jump with the space key to jump over the wall.
This is the video my sister played in this game.↓

床、コイン、壁などの画像は使用せず、大きさと形をプログラムで指定しています。

毎回、コインの並び方、壁の出るタイミングはランダムに変わります。

We do not use floor, coin, wall etc images, size and shape are specified by program.

Every time, how to arrange coins, the timing of the wall changes randomly.

Zip download of this game, here ↓

コインゲットゲームのZipダウンロードは、こちら

ソースコードです👇Source code is here ↓

import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

PFont font;

PImage shadow;

int en[] = {
0,3,6,8,9,11,12,13,14,15,16,17,18,19,20,20,21,22,23,23,24,25,25,26,26,27,28,28,29,29,30,30,31,31,32,32,33,33,34,34,34,35,35,36,36,36,37,37,38,38,38,39,39,39,40,40,40,41,41,41,42,42,42,43,43,43,44,44,44,44,45,45,45,45,46,46,46,46,47,47,47,47,48,48,48,48,49,49,49,49,49,50,50,50,50,51,51,51,51,51,51,52,52,52,52,52,52,53,53,53,53,53,53,54,54,54,54,54,54,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,58,58,58,58,58,58,58,58,58,58,58,58,57,57,57,57,57,57,57,57,57,57,56,56,56,56,56,56,56,56,55,55,55,55,55,55,55,55,54,54,54,54,54,54,54,53,53,53,53,53,52,52,52,52,52,52,51,51,51,51,51,50,50,50,50,50,50,49,49,49,49,48,48,48,48,47,47,47,47,46,46,46,46,45,45,45,45,44,44,44,44,43,43,43,42,42,42,41,41,41,40,40,40,39,39,39,38,38,38,37,37,36,36,36,35,35,34,34,34,33,33,32,32,31,31,30,30,29,29,28,28,27,26,26,25,25,24,23,23,22,21,20,20,19,18,17,16,15,14,13,12,11,9,8,6,3,
};

float sy = 128;
void setup() {
  shadow = loadImage("ana.png");
  size(1024, 1024, P2D);
  //fullScreen(P2D);
  font = loadFont("font.vlw"); 
  textFont(font, 48);
  background(255);
  strokeWeight(1);
  stroke(255);
  //smooth(2);
  //noSmooth();
  frameRate(60);
  fill(255);
  bx = 0;
  by = 0;
  bz = 1;
  surface.setLocation( (displayWidth  - width)/2,
                     (displayHeight - height)/2 );   
  frame.setResizable(true);
  frame.addComponentListener(new ComponentAdapter() {
    public void componentResized(ComponentEvent e) {
      if (e.getSource()==frame) {
        redraw();
      }
    }
  }
  );
  for (float i = 0; i < 100; i++) {
    iz[int(i)] = i/10;
    ix[int(i)] = (noise(ns)-0.5)*2*1200;
    ns += 0.01;
    iy[int(i)] = sy;
  }
}
float tz = 6;
int tg;
float ks;
float sc = 1;

int coin;
float speed = 0;
int zz;
boolean right, left, down, up, jamp, kq, ke;
float x = 0;
float y = 0;
float z = 5;
float[] ix = new float[100];
float[] iy = new float[100];
float[] iyy = new float[100];
float[] ixx = new float[100];
float[] iz = new float[100];
int[] is = new int[100];
float a = 0;
float tx = 0;
float bx, by, bz, bzs, bys, bxs;
float aa;
float ns;
float kb;
//width/height
void draw() {
  translate(0, 128-sy);
  background(255); 
  //stroke(0);
  aa = 0;
  fill(0);
  for (float i = -0.5; i < 30; i++) {
    aa += 6;
    if (aa > 255)aa = 255;
    for (float f = -sy/4; f < sy/4; f++) {
      z = i/10+0.2-a;
      x = f*30;
      rect(int(width/2+(x/z*sc)), int(height/2+(sy/z)*sc), 1/z, 1/z);
    }
  }
  noStroke();
  //rectMode(CENTER);
  //image(shadow,width/2+((bx-32)/bz*sc), height/2+((sy+16)/bz*sc), 64/bz*sc, 32/bz*sc);
  //rectMode(CORNERS);
  for (int i = 0; i < 50; i++) {
    if (bz < iz[i] && tz < iz[i]) {
      fill(255, 190, 10);
      ellipse(width/2+((ix[i]-ixx[i])/iz[i]*sc), height/2+((sy-iyy[i])/iz[i]*sc), 32/iz[i]*sc, 48/iz[i]*sc);
    }
  }

  fill(0,16);
  int wt = 0;
  float wtz = 0;
  /*
  if(tz-(0.01*sc*10) < bz && tz-(0.01*sc*10) > bz-(0.01*sc*10)){
   wtz = (0.01*sc*20);
   wt = -100;
   }
   */
  float xxx = (128-by)/78+0.75;
  for (float i = -((0.03+kb)*xxx); i < ((0.03+kb)*xxx); i += 0.005/2) {
    float yy = (en[int(ks)])*((128-by)/128+0.75);
    rect(width/2+((bx-(yy/2))/(bz-wtz+i)*sc), height/2+((((sy+wt)-((bz-wtz)/32))+29)/(bz+i)*sc), yy/(bz+i-wtz)*sc, 2.7/(bz+i-wtz)*sc);
    ks += (float)400/((((0.03+kb)*xxx)*2)/(0.005/2));
    if(ks >= 400)ks = 399;
  }
  //println(128-by);
  ks = 0;
  kb += 0.005/2/4;
  if (kb > 0.005/2)kb = 0;
  if (zz <= 0) {
    fill(255, 200, 150);
    ellipse(width/2+(bx/bz*sc), height/2+(by/bz*sc), 64/bz*sc, 64/bz*sc);
  }
  float tem = tz;

  fill(tz*60+100, tz*60+100*2, tz*60+100*3);

  for (int i = 0; i < 10; i++) {
    rect(width/2+(((-500/2)+tx)/tz*sc), height/2+((y-50)/tz*sc), 500/tz*sc, 100/tz*sc);
    tz -= 0.01*sc;
  }
  fill(tz*40+100, tz*40+100*2, tz*40+100*3);

  rect(width/2+(((-500/2)+tx)/tz*sc), height/2+((y-50)/tz*sc), 500/tz*sc, 100/tz*sc);
  tz = tem;

  for (int i = 0; i < 50; i++) {
    if (bz < iz[i] && tz > iz[i]) {
      fill(255, 190, 10);
      ellipse(width/2+((ix[i]-ixx[i])/iz[i]*sc), height/2+((sy-iyy[i])/iz[i]*sc), 32/iz[i]*sc, 48/iz[i]*sc);
    }
  }

  if (zz > 0) {
    fill(255, 200, 150);
    ellipse(width/2+(bx/bz*sc), height/2+(by/bz*sc), 64/bz*sc, 64/bz*sc);
  }
  for (int i = 0; i < 50; i++) {
    if (bz > iz[i] && tz > iz[i]) {
      fill(255, 190, 10);
      ellipse(width/2+((ix[i]-ixx[i])/iz[i]*sc), height/2+((sy-iyy[i])/iz[i]*sc), 32/iz[i]*sc, 48/iz[i]*sc);
    }
  }
  //rectMode(CORNER);
  bx += bxs;
  by += bys;
  bz += bzs;
  bys += 0.2;
  if (bz < tz) {
    zz = 1;
  } else {
    zz = 0;
  }
  if (by > sy)bys = -0.8;
  y = sy;
  if (a >= 1.0/10)a = 0;

  if (jamp) {
    if (by > 110) {
      bys += -3.5;
    }
  }
  if (left) {
    bxs -= 2;
  }
  if (right) {
    bxs += 2;
  }
  if (up) {
    bzs += 0.01;
  }
  if (down) {
    bzs -= 0.01;
  }
  bxs /= 1.25;
  bzs /= 1.4;
  tz -= 0.013*2*speed;


  translate(0, -(128-sy));

  for (int i = 0; i < 50; i++) {
    float xx = ix[i];  
    //if(xx > 0)println(xx);
    if (bz > iz[i]-0.1 && bz < iz[i]+0.1) {
      //for (int f = -90; f < 90; f++) {
      if (int(bx) < int(xx)+30 && int(bx) > int(xx)-30) {
        //if (int(by) < int(iy[i])+10 && int(by) > int(iy[i])-10) {
        if (is[i] <= 0) {
          coin++;
        }
        is[i] = 1;
        //}
        //}
      }
      //}
    }
  }
  if (tz > bz-0.2 && tz < bz+0.2) {
    if (tx > bx-(500/2) && tx < bx+(500/2)) {
      if (by > 117) {
        speed = -1;
      }
    }
  }
  for (int i = 0; i < 50; i++) {
    if (is[i] > 0) {
      iyy[i] += iyy[i]/4+1; 
      ixx[i] += ixx[i]/4+1; 
    }
    iz[i] -= 0.013*2*speed;
    if (iz[i] < -0.1) {
      ix[int(i)] = (noise(ns)-0.5)*2*400;
      ns += 0.03;
      is[i] = -1;
      iyy[i] = 0;
      ixx[i] = 0;
      iz[i] = 6;
    }
  }
  a += 0.01*2*speed;
  if (by > 110) {
    //bz -= 0.013*2/2;
  }
  if (bz < 0.3) {
    bz = 0.3;
  }
  if (tz < 0) {
    tz = 6;
    tx = random(-900, 900);
  }
  speed = (0.6 + speed*60)/61;

  //sy += 0.1;
  //if (keyPressed) {
  if (kq)sc += 0.1;
  if (ke)sc -= 0.1;
  //}
  //sc = (bz/64)+1;
  text(coin, 0, 48);
}
void keyPressed()
{
  if (key == 'q')kq = true;
  if (key == 'e')ke = true;
  if (keyCode == RIGHT || key == 'd') {
    right = true;
  }
  if (keyCode == LEFT || key == 'a') {
    left  = true;
  }
  if (keyCode == DOWN || key == 's') {
    down  = true;
  }
  if (keyCode == UP || key == 'w') {
    up    = true;
  }
  if (key == ' '|| keyCode == SHIFT)   jamp = true;
}
void keyReleased()
{
  if (key == 'q')kq = false;
  if (key == 'e')ke = false;
  if (keyCode == RIGHT || key == 'd') right = false;
  if (keyCode == LEFT || key == 'a')  left  = false;
  if (keyCode == UP || key == 'w')  up    = false;
  if (keyCode == DOWN || key == 's')    down  = false;
  if (key == ' '|| keyCode == SHIFT)   jamp = false;
}

 

Follow me!

コメントを残す