Custom Mouse in DelphiX

Started by
1 comment, last by CoamIthra 22 years, 5 months ago
I''m trying to make a shooter using Delphi and DelphiX where the player can aim using a mouse-controlled crosshairs. My problem is that I want the mouse to move over the screen independently of the framerate of my game (about 30fps). When I treated the mouse pointer like any other graphical object in the game, the refresh rate of its position (the same as the framerate) was waaaay too low. It felt like the mouse was dragging behind. So, how do I get my mouse to move faster? I''ve tried drawing the image directly to the primary surface... which worked but had the unwanted side-effect of completely screwing up my program Here''s my (pretty lame I guess) attempt: procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if DXDraw1.Candraw then begin DXDraw1.Primary.Canvas.Draw(mousex-16,mousey-16,dxdib2.dib); DXDib2.Dib.Canvas.copyrect(rect(0,0,32,32),dxdraw1.primary.canvas,rect(x-16,y-16,x+16,y+16)); DXDraw1.Primary.Canvas.Draw(x-16,y-16,self.DXDIB1.DIB); dxdraw1.primary.canvas.release; end; mousex := x; mousey := y; end; Any ideas? Je vous prie d''''agréer, madame, monsieur, l''''expression de mes sentiments distingués, Harald Maassen
Je vous prie d''agréer, madame, monsieur, l''expression de mes sentimentsdistingués, Harald Maassen
Advertisement
So whaddaya know... as soon as I post this message the damn thing decides to work normally on me... I have no idea what I did wrong the first time I tried this but now it works perfectly (apart from the mouse being awkwardly offset, which shouldn''t be too hard to fix... I hope)

grumble...

Je vous prie d''''agréer, madame, monsieur, l''''expression de mes sentiments
distingués, Harald Maassen
Je vous prie d''agréer, madame, monsieur, l''expression de mes sentimentsdistingués, Harald Maassen
And to add yet another message to this monologue: who can tell me how to get the absolute coordinates of a TWinControl?

To offset my mouse, I draw it at:

x := xpos + Form1.Left + DxDraw1.Left;
y := ypos + form1.top + dxdraw1.top;


However, dxdraw1.top = 0, while there is a menu and a titlebar above it.

I can set the form.borderstyle to BsNone to make the problem go away but I''d like to keep my menu/titlebar.

Je vous prie d''''agréer, madame, monsieur, l''''expression de mes sentiments
distingués, Harald Maassen
Je vous prie d''agréer, madame, monsieur, l''expression de mes sentimentsdistingués, Harald Maassen

This topic is closed to new replies.

Advertisement