processingで動いてるのを避けるものを作りたくて色々やってみたのですがダメでした。初心者なのですが指南の程をお願いします。 int spotsNum = 900; float area=10; float coef=20; float q, w; Spot[] spots = new Spot[spotsNum]; void setup(){ fullScreen(); smooth(); noStroke(); for (int i = 0; i < spots.length; i++){ float x = width/spots.length * i; float speed = random(1,8); color col = color(random(20),random(220),random(300)); spots[i] = new Spot( new PVector(x,30),width/spots.length,speed,col); } } void draw(){ float pInv=0;//距離に応じた係数を保持する変数 float dx=q-mouseX; float dy=w-mouseY; float d=sqrt(dx*dx+dy*dy); fill(0,12); rect(0,0,width,height); for(int i=0; i < spots.length; i++){ spots[i].move(); spots[i].display(); } if (d<area) { pInv=(area-d)/area; float mx=dx/d*pInv*coef; float my=dy/d*pInv*coef; q+=mx; if(q<spotsNum)q=spotsNum; if(q>width-spotsNum)q=width-spotsNum; w+=my; if(w<spotsNum)w=spotsNum; if(w>height-spotsNum)w=height-spotsNum; } noFill(); stroke(255); circle(mouseX,mouseY,area*2); noStroke(); fill(0, 20*pInv, 250); circle(q, w, 2*spotsNum); } class Spot{ PVector pos; float diameter; float speed; color col; int direction = 2; //方向 //コンストラクタ Spot(PVector _pos, float _diameter, float _speed, color _col){ pos = _pos; diameter = _diameter; speed = _speed; col = _col; } void move(){ pos.y += speed * direction; if(pos.y < height/spots.length || pos.y > height-height/spots.length){ direction *= -1; } } void display(){ fill(col); ellipse(pos.x, pos.y, diameter, diameter); } }
Java