; English forum: http://www.purebasic.fr/english/viewtopic.php?t=7956&highlight= ; Author: Psychophanta (updated for PB 4.00 by Andre) ; Date: 18. October 2003 ; OS: Windows ; Demo: Yes ; Problem: DisplayPalette(1) gibt einen "#Palette object not intialized." Fehler aus, obwohl ; vorher LoadPalette erfolgreich geladen wurde. ; Question: Is there a way to use a screen with an unique screen buffer? ; I need to show a sprite as mouse pointer at the same time, ; I want to see plotted static pixels on screen. If InitMouse()=0 Or InitSprite()=0 Or InitKeyboard()=0 Or InitPalette() = 0 MessageRequester("Error", "Can't open DirectX", 0) End EndIf DefType .f #bitplanes=8 ; =====> 256 colors #RX=800:#RY=600 #b=15 If OpenScreen(#RX,#RY,#bitplanes,"circl")=0:ReleaseMouse(1):End:EndIf If LoadPalette(1,"..\Gfx\pfeil.bmp") ;"Sprite.bmp"); <--- your mouse pointer sprite Else Debug "Sprite couldn't be loaded." EndIf DisplayPalette(1) LoadSprite(0,"Sprite.bmp",0) MouseLocate(#RX/2,#RY/2) ExamineMouse():x=MouseX():y=MouseY() GrabSprite(1,x,y,32,32,0) FlipBuffers() GrabSprite(2,x,y,32,32,0) FlipBuffers() Xr=61:Yr=0 d=1/35;<-speed k=Sqr(1+Pow(d,2)) c=Sqr(2+Pow(d,2)+1/Pow(d,2)) Repeat ExamineMouse() Gosub r1 ExamineKeyboard() Until KeyboardPushed(#PB_Key_Escape) ReleaseMouse(1):FreeSprite(2):FreeSprite(1):FreeSprite(0):FreePalette(1):CloseScreen() End r1: x_r=Xr:y_r=Yr x_a=-y_r*d:y_a=x_r*d xold=x:yold=y x=MouseX():y=MouseY() GrabSprite(1,x,y,32,32,0);save background DisplayTransparentSprite(0,x,y);draw our mouse pointer just here StartDrawing(ScreenOutput());<--Draw on first buffer Plot(x+x_r,y+y_r,$c8faff) StopDrawing() FlipBuffers();<--swap to second buffer DisplaySprite(2,xold,yold);<--restore the old background GrabSprite(2,x,y,32,32,0);<--and save the new one StartDrawing(ScreenOutput());<--Draw on the second buffer Plot(x+x_r,y+y_r,$c8faff) StopDrawing() Xr=(x_a+x_r)/k:Yr=(y_a+y_r)/k ExamineMouse() Return ; IDE Options = PureBasic v4.02 (Windows - x86) ; Folding = -