Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CoamIthra

Custom Mouse in DelphiX

This topic is 6072 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!