xxxxxxxxxx
let position;
let velocity;
let walker = [];
const num = 2;
let num_ashi = 0;
let ashiato = [];
function preload(){
ashiato[0] = loadImage('mark_nikukyu.png');
ashiato[1] = loadImage('mark_nikukyu2.png');
}
function setup() {
createCanvas(400, 400);
frameRate(1);
ashiato[0].resize(20,20);
ashiato[1].resize(20,20);
for(let i = 0; i < num; i++)
{
walker[i] = new Walker();
}
background(255,255,198);
}
function draw() {
for(let i = 0; i < num; i++){
walker[i].draw();
num_ashi = i;
}
}
class Walker{
constructor(){
this.position = createVector(100,100);
}
draw(){
this.velocity = createVector(random(-20,20),random(-20,20));
this.position.add(this.velocity);
noStroke();
push();
translate(this.position.x,this.position.y);
rotate(this.velocity.x*0.05,this.velocity.y*0.05);
image(ashiato[num_ashi],this.position.x,this.position.y);
pop();
}
}