-
A greeting,
Well, im trying to make SimGame knockoff
I know how to find the coordinates of the mouse, but I need to know how to place an image where the mouse is when the user clicks on the form.
Im sure this is a pretty simple question, but any help will be greatly appreciated.
Thanks alot in advance
Xanth
-
form1_click()
x-mouse-coordinate (or what ever you called it)= image1.left
y-mouse-coordinate (or what ever you called it) = image1.top
end sub
Hope that helps
-
It's right the other way around:
-
It would be more "game-like" to use the center of the image as opposed to the corners:
Code:
Image1.Move X - (Image1.Width / 2), Y - (Image1.Height / 2)
-
I think that all is a bad idea to use real coordinates for a sim game... Would be much easier to handle if you use a 2D array, just think about drawing the houses (or whatever)... but however r0ach is right, better take the center :)
-
Well, Im not sure about making a 2d array, im not really that advanced into VB yet, or I would give it a try
But, about the other things, i tried them all, and the image just kept jumping around in the upper left hand corner of the form, this is the code I have to get the mouse coords..
Option Explicit
Type POINTAPI 'Declare types
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long 'Declare API
Perhaps I need to do some math to the coords once I get them? Or would I need to use a different call?
Thanks for all of your help guys, I really appreciate it..
Xanth
-
You're to experienced to see the simple functions ;)
Well, put my code into the Form_MouseDown event, them it will work :)
-
(or better take r0ach's code ;))