xxxxxxxxxx
16
// MovingImage (c) 2015, 2021 kouichi.matsuda@gmail.com
let img; // (1) 画像を管理する変数
let x = 0, y = 0; // 画像の描画位置
function preload() {
img = loadImage("sky.png"); // (2) 画像の読み込み
}
function setup() {
createCanvas(img.width * 2, img.height * 2); // (3) 画像と同じサイズのcanvasを用意する
}
function draw() {
background(255);
image(img, x, y); // (4) 画像を表示
x++; y++; // 画像の表示位置を変更する
}