Page 1 of 1

Where is the mouse? Any tips?

Posted: Mon May 10, 2004 6:44 am
by aisman
Hello,
Where is the mouse? Any tips?

Thanks.

Code: Select all

InitMouse() 
InitSprite()
InitKeyboard() 

xscreen = 150 
yscreen = 150 

WindowID = OpenWindow(0, 30, 30, xscreen, yscreen, #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget,"") 
OpenWindowedScreen(WindowID, 0, 0, xscreen, yscreen, 0, 0, 0) 

Repeat  
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    End
  EndIf
  ExamineMouse()
  StartDrawing(ScreenOutput())   
    Circle(MouseX(),MouseY(),3,RGB(100,100,100)) 
  StopDrawing()                  
  FlipBuffers()
  Delay(10)
ForEver 

Posted: Mon May 10, 2004 7:11 am
by blueznl
you mean the mousepointer?

Posted: Mon May 10, 2004 7:14 am
by aisman
I see you understand me ;-)

Posted: Mon May 10, 2004 7:18 am
by blueznl
haven't done anything in that direction yet, but i have a feeling it's not supposed to be there, i could be wrong though

Posted: Mon May 10, 2004 8:05 am
by benny
Hmm .. maybe this helps (avoid ExamineMouse() ) :?:

Code: Select all

InitMouse() 
InitSprite() 
InitKeyboard() 

xscreen = 150 
yscreen = 150 

WindowID = OpenWindow(0, 30, 30, xscreen, yscreen, #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget,"") 
OpenWindowedScreen(WindowID, 0, 0, xscreen, yscreen, 0, 0, 0) 


Repeat  

  Select WindowEvent() 
    Case #WM_CLOSE
         End
   EndSelect
      
  ExamineKeyboard() 
  If KeyboardPushed(#PB_Key_Escape) 
    End 
  EndIf 

    GetCursorPos_(CursorPosition.POINT) 
    MouseX = CursorPosition\x - WindowX()
    MouseY = CursorPosition\y - WindowY() - 20 

  StartDrawing(ScreenOutput())    
    Circle(MouseX,MouseY,3,RGB(100,100,100)) 
  StopDrawing()                  
  FlipBuffers() 
  Delay(10) 
ForEver 

Posted: Mon May 10, 2004 11:49 pm
by aaron
You can use this:

ShowCursor_(1) ; display the mouse pointer

You'll see that it looks busy all the time though (as an hourglass)... I'll still puzzling thru this windows stuff too, but it looks like you need to check window events even if you aren't going to us them.... I call a WindowEvent() command right around the delay command also.

Updated code:

Code: Select all

InitMouse()
InitSprite()
InitKeyboard()

xscreen = 150
yscreen = 150

WindowID = OpenWindow(0, 30, 30, xscreen, yscreen, #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget,"")
OpenWindowedScreen(WindowID, 0, 0, xscreen, yscreen, 0, 0, 0)

ShowCursor_(1) ; display the mouse pointer

Repeat 
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    End
  EndIf
  ExamineMouse()
  StartDrawing(ScreenOutput())   
  Circle(MouseX(),MouseY(),3,RGB(100,100,100))
  StopDrawing()                 
  FlipBuffers()
  Delay(10) : WindowEvent()
ForEver 
I don't know if this is the right way to do it, but it's been working for me thus far.... :P