xxxxxxxxxx
34
let integral;
let pos, vel;
function preload() {
integral = loadImage("intagral.png");
pos = createVector(50, 50);
vel = createVector(3, 3);
}
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
image(integral, pos.x, pos.y, 150, 306);
pos.add(vel);
if (pos.x < 0) {
pos.x = 0;
vel.x *= -1;
}
if (pos.x > width - 150) {
pos.x = width - 150;
vel.x *= -1;
}
if (pos.y < 0) {
pos.y = 0;
vel.y *= -1;
}
if (pos.y > height - 306) {
pos.y = height - 306;
vel.y *= -1;
}
}