To verify your bug report I've updated your demonstration code to make an interactive bug display.
Code: Select all
InitSprite()
InitKeyboard()
EnableExplicit
Procedure handleError(value, text.s): If value = 0: MessageRequester("Error", text.s): End: EndIf: EndProcedure
Define sprite_ID, sprite_ID_1, sprite_ID_2, sprite_ID_3
Define output_width=800, output_height=800
Define window_ID=OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, output_width, output_height, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
handleError(window_ID, "Couldn't open window.")
handleError(OpenWindowedScreen(WindowID(window_ID), 0, 0, output_width, output_height), "Couldn't open WindowedScreen.")
;create sprites
sprite_ID=CreateSprite(#PB_Any, 600, 100): handleError(sprite_ID, "Couldn't create the needed sprites.")
sprite_ID_1=CreateSprite(#PB_Any, 150, 150): handleError(sprite_ID_1, "Couldn't create the needed sprites.")
sprite_ID_2=CreateSprite(#PB_Any, 100, 100): handleError(sprite_ID_2, "Couldn't create the needed sprites.")
sprite_ID_3=CreateSprite(#PB_Any, 60, 60): handleError(sprite_ID_3, "Couldn't create the needed sprites.")
StartDrawing(SpriteOutput(sprite_ID))
DrawingMode(#PB_2DDrawing_Gradient)
LinearGradient(0, 0, 600, 0)
BackColor(#Green)
Box(0, 0, 600, 100, $FF)
StopDrawing()
handleError(LoadFont(0, "", SpriteHeight(sprite_ID_1) - 10), "Couldn't load all fonts.")
handleError(LoadFont(1, "", SpriteHeight(sprite_ID_2) - 10), "Couldn't load all fonts.")
handleError(LoadFont(2, "", SpriteHeight(sprite_ID_3) - 10), "Couldn't load all fonts.")
StartDrawing(SpriteOutput(sprite_ID_1))
DrawingFont(FontID(0))
DrawText((SpriteWidth(sprite_ID_1) - TextWidth("1")) / 2, (SpriteHeight(sprite_ID_1) - TextHeight("1")) / 2, "1", #White, #Blue)
StopDrawing()
StartDrawing(SpriteOutput(sprite_ID_2))
DrawingFont(FontID(1))
DrawText((SpriteWidth(sprite_ID_2) - TextWidth("2")) / 2, (SpriteHeight(sprite_ID_2) - TextHeight("2")) / 2, "2", #White, #Red)
StopDrawing()
StartDrawing(SpriteOutput(sprite_ID_3))
DrawingFont(FontID(2))
DrawText((SpriteWidth(sprite_ID_3) - TextWidth("3")) / 2, (SpriteHeight(sprite_ID_3) - TextHeight("3")) / 2, "3", #White, #Yellow)
StopDrawing()
EnumerationBinary
#showSprite_1 ;display sprite 1
#showSprite_2 ;display sprite 2
#showSprite_3 ;display sprite 3
#showRotation ;use dynamic rotation of sprites
#showZeroRotation ;reset absolute rotation of sprites to zero
EndEnumeration
Define event, x, y, x3 = 50, y3 = 50, show = #showSprite_1, prevTextX, textX, textY
Repeat
Repeat
event = WaitWindowEvent(10)
Until event = 0 Or event = #PB_Event_CloseWindow
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape): event = #PB_Event_CloseWindow: EndIf
If KeyboardReleased(#PB_Key_1): show ! #showSprite_1: EndIf
If KeyboardReleased(#PB_Key_2): show ! #showSprite_2: EndIf
If KeyboardReleased(#PB_Key_3): show ! #showSprite_3: EndIf
If KeyboardReleased(#PB_Key_R): show ! #showRotation: EndIf
If KeyboardReleased(#PB_Key_Z): show ! #showZeroRotation: EndIf
If KeyboardPushed(#PB_Key_Up)
y3 - 1
EndIf
If KeyboardPushed(#PB_Key_Down)
y3 + 1
EndIf
If KeyboardPushed(#PB_Key_Left)
x3 - 1
EndIf
If KeyboardPushed(#PB_Key_Right)
x3 + 1
EndIf
If show & #showZeroRotation
RotateSprite(sprite_ID, 0, #PB_Absolute)
show & (%111111111111111111111111 - #showRotation - #showZeroRotation) ;disable #showRotation also
EndIf
If show & #showSprite_1
x = 50: y = 50
DisplaySprite(sprite_ID, x, y)
DisplaySprite(sprite_ID_1, x + (SpriteWidth(sprite_ID) - SpriteWidth(sprite_ID_1))/ 2, y + (SpriteHeight(sprite_ID) - SpriteHeight(sprite_ID_1)) / 2)
EndIf
If show & #showRotation
RotateSprite(sprite_ID, 1, #PB_Relative)
EndIf
If show & #showSprite_2
x = 50: y = 50
DisplaySprite(sprite_ID, x, y)
DisplaySprite(sprite_ID_2, x + (SpriteWidth(sprite_ID) - SpriteWidth(sprite_ID_2))/ 2, y + (SpriteHeight(sprite_ID) - SpriteHeight(sprite_ID_2)) / 2)
EndIf
If show & #showSprite_3
DisplaySprite(sprite_ID, x3, y3)
DisplaySprite(sprite_ID_3, x3 + (SpriteWidth(sprite_ID) - SpriteWidth(sprite_ID_3))/ 2, y3 + (SpriteHeight(sprite_ID) - SpriteHeight(sprite_ID_3)) / 2)
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(0, 0, "Sprite 3(" + x3 + ", " + y3 + ")", #Red)
StopDrawing()
EndIf
StartDrawing(ScreenOutput())
FrontColor(#White)
DrawingMode(#PB_2DDrawing_Transparent)
textY = 400: textX = 180
prevTextX = DrawText(textX - TextWidth("1, 2, 3 : "), textY, "1, 2, 3 : ")
DrawText(prevTextX + 20, textY, "Toggle display of sprite 1, 2, or 3 and it's corresponding number.")
textY + 20: prevTextX = DrawText(textX - TextWidth("R : "), textY, "R : ")
DrawText(prevTextX + 20, textY, "Toggle active rotation of sprites")
textY + 20: prevTextX = DrawText(textX - TextWidth("Z : "), textY, "Z : ")
DrawText(prevTextX + 20, textY, "Zero the absolute rotation of sprites and turn off active rotation")
textY + 20: prevTextX = DrawText(textX - TextWidth("arrows : "), textY, "arrows : ")
DrawText(prevTextX + 20, textY, "Modify sprite 3's coordinates")
textY + 20: prevTextX = DrawText(textX - TextWidth("[Esc] : "), textY, "[Esc] : ")
DrawText(prevTextX + 20, textY, "Exit program.")
textX = 20
textY + 40:DrawText(textX, textY, "Sprites 1 & 2 have a set position, while 3 is changeable. The sprites are drawn in order (1, 2, 3) and the numbers")
textY + 20:DrawText(textX, textY, "for the sprites are drawn immediately after their respective sprite and are centered on where their sprites should")
textY + 20:DrawText(textX, textY, "be displayed. If a sprite's position is not displayed correctly, the sprite can be identified by which #'s it hides.")
textY + 20:DrawText(textX, textY, "For example, sprite 3 hides sprite 1, #1, 2, And #2 While sprite 2 hides only sprite 1 And #1.")
textY + 40:DrawText(textX, textY, "To demonstrate the error involving RotateSprite(), activate only sprites 1 and 3 and zero the rotation.")
textY + 20:DrawText(textX, textY, "Move sprite 3 to about (196, 283). Notice that sprites are correctly positioned under their #'s.")
textY + 20:DrawText(textX, textY, "Press 'R' to start rotation. Notice that sprite 1's position changes.")
textY + 20:DrawText(textX, textY, "Press 'R' again to stop the rotation. Notice that now sprite 3's position also changes.")
textY + 20:DrawText(textX, textY, "You can verify which is sprite 3 by moving it. Now zero the sprite positions and both sprites positions are correct.")
StopDrawing()
Until event = #PB_Event_CloseWindow
I confirm the bug that using RotateSprite() and any angle results in displacing at least some of the later sprites out of their proper display locations. I confirmed this also with the directions in my test code for DirectX. The results were even more bizarre following the directions in my test code and using the OpenGL library SubSystem.