Home > Software engineering >  How to make a PictureBox to move the mouse to click the place to go
How to make a PictureBox to move the mouse to click the place to go

Time:09-24

One small white computer class to learn a little bit of VB fur, homework is to design a simple test to play blame game,

[I've attack way is:
Four attack props to follow, press Q, to control four attack props translational Timer1 run in four directions at the same time, another control items follow the protagonist Timer2 stop, props Timer2 operation after a certain distance away from the role, Timer1 stop,
And a Timer to determine whether to attack the
(judgement, monsters, items Left, Top, add and subtract Heigh, the size of the Width relationship, causing period of attack effect)] bs can be slightly
please
Want to try another way of attack, is to press the mouse, an attack props from leading position to move to the click direction, move to the right after a certain distance (this I have thought, with coordinates and image size Pythagorean theorem to calculate distance can line, there should be other methods), when the position without any attack props attack cannot be launched, prop position and small strange coincidence during continuous deduction small blame HP (more), with small blame by the flying direction make some distance (beat)

No instructions to learn how to get the mouse position, textbook to find relevant,

Launch is still in the leading position of props this functionality, I have thought of using judgment props, props or judgment control flying out of the Timer is running, but I don't know is more than one Timer control multiple items, or a Timer to solve? If according to order a prop 123 a judge of what will clear logic to write boring? Simple point method can have? This individual really haven't got a clue, come here to seek a great god grant instruction, thank you!

Hope the program with a prompt reply to explain, I too small white...

CodePudding user response:

https://www.baidu.com/s? Wd=VB6%20 little game

CodePudding user response:

Your "game" is displayed in the window, or display in PictureBox?

Whether the Form or PictureBox,
The MouseDown (), MouseUp (), MouseMove () event, there are corresponding position coordinates of the mouse,
With this grid, you should can handle!

Pay attention to the coordinate unit, VB6 the default unit is the "mix", a simple conversion, is 1 pixel=15 twips
"Legitimate", then X/Screen TwipsPerPixelX and Y/Screen. TwipsPerPixelY,
You can also modify the display in the design of the graphics of the default unit of measure,
All calculations/show, of course, you also can be in twips,

CodePudding user response:

If you want to get the mouse in the coordinates of the "within" screen, with API function GetCursorPos (),
But from the window, the coordinates of screen coordinates to you also have to recalculate, positioning,
  • Related