Page 1 of 1
Logic error
Posted: Wed Nov 19, 2025 4:02 pm
by SPH
PB 6.12 and under DirectX 11
===
Hi,
I have a logic problem in this code.
It lists the first list of sprites several times and doesn't list the others. Yet, my code is very clear...
I don't understand.
Code: Select all
InitSprite()
InitKeyboard()
OpenScreen(1080,768,32,"Sprite")
StartDrawing(ScreenOutput())
For u=0 To 5
For i=0 To 10
DrawText(i*20,u*20,Chr(65+x),RGB(Random(115),Random(115),Random(255)),RGB(Random(255),Random(255),Random(255)))
x+1
Next
Next
StopDrawing()
taille_x=20
taille_y=20
nb=1
For u=0 To 5
For i=0 To 10
GrabSprite(nb,i*taille_x,u*taille_y,taille_x,taille_y)
nb+1
Next
Next
;;;
For i=1 To nb-1
DisplaySprite(i,i*taille_x,400) ; erreur dans les numeros de sprites !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Next
FlipBuffers()
Repeat
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
Re: Sprites numbers error
Posted: Wed Nov 19, 2025 6:24 pm
by Sergey
Seems like GrabSprite y coordinate always equal zero
PB 6.30b4
Re: Sprites numbers error
Posted: Wed Nov 19, 2025 6:56 pm
by SPH
Sergey wrote: Wed Nov 19, 2025 6:24 pm
Seems like GrabSprite y coordinate always equal zero
PB 6.30b4
Exactly !
I think it's a bug
Furthermore, I don't really know why, but the sprites I created aren't the right color!
Re: Sprites numbers error
Posted: Wed Nov 19, 2025 7:11 pm
by nemerod
I'm sorry, but I don't agree. I just tested it and replied to him on the French Discord server, and the results are conclusive. Furthermore, I know someone used the same solution for a video game they created and had no problems. So, I only see corruption; the code doesn't respect or follow conventions and encourages problems.
and video if you want posted under discord too
https://cdn.discordapp.com/attachments/ ... 31f45f4d7&
after updated and improved the code
Code: Select all
InitSprite()
InitKeyboard()
screensize_x.q=800
screensize_y.q=600
OpenWindow(0,100,100,screensize_x,screensize_y,"")
OpenWindowedScreen(WindowID(0),0,0,screensize_x,screensize_y)
StartDrawing(ScreenOutput())
#taille_X=20
#taille_Y=20
temp.q=0
nb.q=-1
offset_x=0
offset_y=400
For y=0 To 15
For x=0 To 15
DrawText(x*#taille_X,y*#taille_Y,Chr(temp),RGB(x*16,y*16,128),0)
temp+1
Next
Next
StopDrawing()
temp=0
For y=0 To 15
For x=0 To 15
GrabSprite(temp,x*#taille_X,y*#taille_Y,#taille_X,#taille_Y)
temp+1
Next
Next
msg$="tien en voila un test et une demo a la con avec un string de text que sa en devien sexy et en bonus le retour a la ligne fais dans le code lui meme avec une detection si le truc va trop loin comme tu peu voir ;)"
*QUICK_EDIT=AllocateMemory($4000)
QUICK_POS.q=Len(msg$)
PokeS(*QUICK_EDIT,msg$,Len(msg$),#PB_Ascii)
Repeat:eee=WindowEvent()
Select eee
Case 0
ClearScreen($000000)
tin+1
temp=0
For y=0 To 15
For x=0 To 15
If IsSprite(temp)
DisplaySprite(temp,x*#taille_X,y*#taille_Y)
EndIf
temp+1
Next
Next
offset_x=0
offset_y=400
For a=0 To $3fff
temp=PeekA(*QUICK_EDIT+a)
If temp=$00:Break:EndIf
If temp=$0D:
offset_y+#taille_Y
offset_x=0:Continue
EndIf
If IsSprite(temp)
DisplaySprite(temp,4+offset_x+Sin(Radian((tin/3.65)+a))*3.84,offset_y+Cos(Radian((tin/1.5)+a))*5.27)
offset_x+#taille_X
If offset_x=>screensize_x
offset_y+#taille_Y
offset_x=0
EndIf
EndIf
Next
FlipBuffers():Delay(16);limite a 60fps pour faire un peu plus propre
Case $100
temp=EventwParam()
Select temp
Case #VK_ESCAPE:eee=#PB_Event_CloseWindow
Case #VK_BACK
If QUICK_POS>0
QUICK_POS-1
PokeA(*QUICK_EDIT+QUICK_POS,0)
EndIf
Case $10
Default
If QUICK_POS<$4000
PokeA(*QUICK_EDIT+QUICK_POS,temp)
QUICK_POS+1
EndIf
EndSelect
EndSelect
Until eee=#PB_Event_CloseWindow
sorry for raw reply in quick time