Page 1 of 1

Sprite bug?

Posted: Wed Nov 19, 2025 10:08 am
by SPH
PB 6.12

Incomprehensible!

Look at this short code and tell me why the sprite I'm drawing isn't always the right one!

Code: Select all

InitSprite()
InitKeyboard()

OpenScreen(1920,1080,32,"Sprite")

LoadSprite(0,"d:/amy.bmp")

DisplaySprite(0,0,0)

taille_x=36
taille_y=42


nb=1
For u=0 To 8
  For i=1 To 8
    GrabSprite(nb,i*taille_x,u*taille_y,taille_x,taille_y)
    nb+1
  Next
Next

;;;

For i=1 To nb-1
    DisplaySprite(i,20+i*taille_x,400)
Next

FlipBuffers()
Repeat
  ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)

I'm not including the sprite table because the code is easy to read without it.

Re: Sprite bug?

Posted: Wed Nov 19, 2025 12:42 pm
by SPH
It only displays the sprites from the first row!

Re: Sprite bug?

Posted: Wed Nov 19, 2025 2:21 pm
by moulder61
The For/Next loop before FlipBuffers() will run from 1 to 71 rather than 0 to 71.

nb in a previous nested loop will be 72. Could that be it?

Moulder.

Re: Sprite bug?

Posted: Thu Nov 20, 2025 12:30 pm
by SPH