xxxxxxxxxx
34
let gif;
let x = 0;
let y = 0;
let directionX = 2;
let directionY = 2;
function preload() {
gif = createImg("lunidin.gif", "lunidin.gif"); //??
}
function setup() {
createCanvas(500, 500);
background(220);
}
function draw() {
gif.position(x, y);
x = x + directionX;
y = y + directionY;
if (x > width) {
directionX = -2;
}
if (y > height) {
directionY = -2;
}
if (x < 0) {
directionX = 2;
}
if (y < 0) {
directionY = 2;
}
}