Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / MouseClick()???? Why wont it work!

Author
Message
SilverKnight
22
Years of Service
User Offline
Joined: 21st Sep 2003
Location:
Posted: 27th Sep 2003 02:46
Hey dudes!

I have been having trouble with MouseClick()! Im trying to get it so when i click the mouse button a charcter moves to the designated spot, but instead of being able to let go of the button and have it walk to the location, i have to hold down the mouse button or he will stop. Here is the code.


if MouseClick() = 1

GuyPos2X = Object Screen X(1)
GuyPos2Z = -Object Screen Y(1)

GuyDestX = MouseX()
GuyDestZ = -MouseY()

if GuyDestX > GuyPos2X
GuyPosX = GuyPosX + 1
endif
if GuyDestX < GuyPos2X
GuyPosX = GuyPosX - 1
endif

if GuyDestZ > GuyPos2Z
GuyPosZ = GuyPosZ + 1
endif
if GuyDestZ < GuyPos2Z
GuyPosZ = GuyPosZ - 1
endif

endif


Regards,
Rajavidya SilverKnight
CloseToPerfect
23
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 27th Sep 2003 03:58
do
if MouseClick() = 1
mouseclicked = 1
GuyPos2X = Object Screen X(1)
GuyPos2Z = -Object Screen Y(1)
GuyDestX = MouseX()
GuyDestZ = -MouseY()
endif

if mouseclicked = 1
if GuyDestX > GuyPos2X
GuyPosX = GuyPosX + 1
endif
if GuyDestX < GuyPos2X
GuyPosX = GuyPosX - 1
endif
if GuyDestZ > GuyPos2Z
GuyPosZ = GuyPosZ + 1
endif
if GuyDestZ < GuyPos2Z
GuyPosZ = GuyPosZ - 1
endif
if GuyDestX = GuyPos2x and GuyDestZ = GuyPos2Z then mouseclicked = 0
endif

loop


untested but should be close, all you need to do is store the positions when you click and run a loop until it gets where it needs to be.

CTP
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 27th Sep 2003 19:11
Just so you know... mouseclick() is working right, but since the code only runs when the mouse is being pressed down, it gives you that result .

--Mouse: Famous (Avatarless) Fighting Furball
Read It: http://www.angryflower.com/itsits.gif
Learn It: http://www.angryflower.com/bobsqu.gif

Login to post a reply

Server time is: 2026-07-25 07:01:28
Your offset time is: 2026-07-25 07:01:28