xxxxxxxxxx
49
let boutons;
let fond;
let img;
let img_size = 32;
let x_pos, y_pos;
let last_frame;
const frame_dur = 200;
const animation = [[0, 0], [1, 0], [0, 1], [1, 1], [0, 2]];
let frame_i;
function preload() {
img = loadImage("Piskel .png");
bouton = loadImage("Dot.png");
fond = loadImage("fond tamagoshi");
}
function setup() {
createCanvas(400, 400);
imageMode(CENTER);
x_pos = width/2;
y_pos = height-4*img_size;
last_frame = millis();
frame_i = 0;
noSmooth();
}
function draw() {
background(255);
if (millis() - last_frame >= frame_dur) {
frame_i += 1;
last_frame = millis();
if (frame_i >= animation.length) {
frame_i = 0;
}
}
image(img, x_pos, y_pos,
img_size*4, img_size*4,
img_size*animation[frame_i][0],
img_size*animation[frame_i][1],
img_size, img_size);
image(bouton, 10, 10);
}