Code
If InitSprite() = 0
MessageRequester("Error", "Can't open screen & sprite enviroNment!", 0)
End
EndIf
If OpenWindow(0, 0, 0, 220, 160, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ButtonGadget(0, 170, 135, 45, 20, "Quit")
EndIf
If OpenWindowedScreen(WindowID(0), 0, 0, 160, 160, 0, 0, 0)
CreateSprite(0, 20, 20)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
EndIf
direction = 2
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget
If EventGadget() = 0
End
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
DisplaySprite(0, x, x)
x + direction
If x > 140 : direction = -2 : EndIf
If x < 0 : direction = 2 : EndIf
Delay(1)
ForEver
Code
InitSprite()
InitKeyboard()
If OpenScreen(640, 480, 32, "Test") = 0
End
EndIf
If CreateSprite(0, 64, 64)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 64, 64, $FF00FF)
Box(5, 5, 54, 54, $FF009B)
StopDrawing()
EndIf
direction = 2
Repeat
FlipBuffers()
If IsScreenActive()
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
Break
EndIf
EndIf
ClearScreen(RGB(0, 0, 0))
DisplaySprite(0, x, x)
x + direction
If x > 420 : direction = -2 : EndIf
If x < 0 : direction = 2 : EndIf
Else
Delay(50)
EndIf
ForEver
EndIf
CloseScreen()