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.

Newcomers DBPro Corner / Print Mouse Position Question

Author
Message
Game Guy
16
Years of Service
User Offline
Joined: 9th Oct 2008
Location:
Posted: 13th May 2009 01:35
Hi. I was working with images and stuff and I realized I needed a tool that told me where the X and Y was of the mouse. I then told myself that I should make it because it would be good practice.

Here is my code:


I made it so the mouse would dissapear and it would tell you the spot of the place you just clicked. But every time it tells me the position is 0 , 0 ,0 . What is the problem?

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 13th May 2009 02:42
First, it should be:



That way, you will assign a value for the 3 variables.

Second, when you do that, Mousexposition - the z one, they will always be what you assigned them at the beginning.



That will do what you want, also, please indent your code.
If you do not know how, look at this.
http://forum.thegamecreators.com/?m=forum_view&t=138230&b=10

Game Guy
16
Years of Service
User Offline
Joined: 9th Oct 2008
Location:
Posted: 13th May 2009 03:01
Omg! Thank you so much. That explained it very well.

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 13th May 2009 03:04
No prob.

I would advise working through some of these tutorials:

http://forum.thegamecreators.com/?m=forum_view&t=115633&b=7

Definitely TDK's, that is how I learned most of what I know. =P

Game Guy
16
Years of Service
User Offline
Joined: 9th Oct 2008
Location:
Posted: 13th May 2009 03:26
Yea you helped A LOT. Its working great now. Didn't think it would be that simple though

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size
Game Guy
16
Years of Service
User Offline
Joined: 9th Oct 2008
Location:
Posted: 14th May 2009 02:23
So I don't even need the:

mousex() = this#
mousey() = that#

?

Proud Leader of the DarkBASIC club. Inspired by TGC & Celestial Coding
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 14th May 2009 02:54 Edited at: 14th May 2009 02:54
*

Also, you could use those, but just put them at the beginning of the loop, like:



LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 14th May 2009 16:19
Also, the mouse commands return an integer, so there is no need to assign a float variable to it. Use mousexposition instead of mousexposition# (same for y and z mouse coordinates).

LB

bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 14th May 2009 17:11
does it matter? i guess, if you had like 10.000 variables and you increase fps perforamnce by 0.0001 by making a variable integer instead of float...

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 14th May 2009 19:52
It is poor programming practice to use a float when an integer is required IMO, even though the speed difference is neglible. Why even have integers at all, if floats should be used for everything? If having clean code doesn't matter to you, then go ahead and do it up.

bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 14th May 2009 21:32
Clean code does matter to me! but it doesn't make much difference, thats all

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 17th May 2009 18:41
Quote: "but it doesn't make much difference, thats all"


For small programs, it does not matter. But when programs get large, with hundreds to thousands of variables, that is one fast way to use up all the RAM in a machine.

Login to post a reply

Server time is: 2024-11-24 06:22:13
Your offset time is: 2024-11-24 06:22:13