First remove from the original image the white horizontal line on the right side, because if not, it was seen in the last sprites of each row.
But I was surprised that the legs of each bug remained on the screen when changing the sprite, superimposed on each new image.
I have solved it by painting a black rectangle the size of the sprite (line 23).
Code: [Local Link Removed for Guests]
vga.delete
vga.init 2
vga.fill black
' 619x264 px image with 21 sprites in 3 rows and 7 columns:
vga.spriteSheet "/img/bugs1.bmp"
row = 3 ' number of sprites in each colum
col = 7 ' number of sprites in each row
w = 88 ' sprite width in pixels
h = 87 ' sprite height in pixels
x0 = 0 ' top left x coordinate of the first sprite
y0 = 0 ' top left y coordinate of the first sprite
tH = 1 ' horizontal separation between sprites in pixels
tV = 1 ' vertical separation between sprites in pixels
pause 5000
' DEMO:
x=275 : y=150
while 1
for icon = 0 to (row*col)-1
vga.rect x, y, w, h, black, 1
displayIcon icon, x, y
pause 1000
next icon
wend
END
' --------------------------------
SUB displayIcon(icon, x, y)
xi = (w+tH) * (icon MOD col)
yi = (h+tV) * int(icon/col)
' wlog xi, yi
vga.sprite x, y, w, h, xi, yi
vga.show
END SUB