Click to See Complete Forum and Search --> : New Sim-Like game
xnomeda
May 24th, 2000, 11:02 AM
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
gfurner
May 24th, 2000, 06:56 PM
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
Fox
May 24th, 2000, 09:54 PM
It's right the other way around:
Image1.move x, y
r0ach
May 24th, 2000, 10:09 PM
It would be more "game-like" to use the center of the image as opposed to the corners:
Image1.Move X - (Image1.Width / 2), Y - (Image1.Height / 2)
Fox
May 25th, 2000, 01:03 AM
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 :)
xnomeda
May 25th, 2000, 03:32 AM
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
Fox
May 25th, 2000, 03:43 AM
You're to experienced to see the simple functions ;)
Well, put my code into the Form_MouseDown event, them it will work :)
Fox
May 25th, 2000, 03:44 AM
(or better take r0ach's code ;))
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.