![]() ![]() If x < 0 : direction = 1 : EndIf moving to the right with positive valueįlipBuffers() Inverse the buffers (the back become the front (visible). If KeyboardPushed( #PB_Key_Up) And playerY > 0 : playerY -3 : EndIf If KeyboardPushed( #PB_Key_Down) And playerY 0 : playerX -3 : EndIf If KeyboardPushed( #PB_Key_Right) And playerX 300 : direction = -1 : EndIf moving back to the left with negative value ![]() SetGadgetText(4, "Button "+ Str(Gadget)+" pressed.")ĮndSelect EndSelect Until Event = 0 Quit the event loop only when no more events are availableĮndIf do the sprite & screen management at every frame SetGadgetText(4, "Press 'F1' to ungrab keyboard and mouse") Repeat Repeat Always process all the events to flush the queue at every frameĬase #PB_Event_Gadget Do the normal application management here MouseY = ( ScreenHeight() - SpriteHeight(0)) / 2 of course it's possible to solve it in sole PB, but its a bit more complicated to handle the leaving of the screen correctly. MouseX = ( ScreenWidth() - SpriteWidth(0)) / 2 here is an example how to handle the Mouse in a WindowedScreen, which keeps movement soft while leaving the screen-area and also keeps track of GotFocus/LostFocus. LoadSprite(0, #PB_Compiler_Home + "examples/sources/Data/PureBasicLogo.bmp") If OpenWindowedScreen( WindowID(0), DesktopScaledX(10), DesktopScaledX(70), DesktopScaledX(320), DesktopScaledX(200), 0, 0, 0) TextGadget (4, 10, 40, 300, 30, "Mouse and keyboard released") If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
0 Comments
Leave a Reply. |