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 / problem with mouseclick()

Author
Message
Sickly
15
Years of Service
User Offline
Joined: 14th Jul 2009
Location: Does it matter?
Posted: 18th Jan 2010 03:48
The other day, I wrote my first program, that I thought was complete. It is a simple dice roller program for dungeons and dragons. The way it works is when you click on an image of a die, it generates a random number IE: a 12 sided die would roll 1 to 12 (obviously). The problem is, I am using mouse clicks, and you can hold the mouse button down, and watch the numbers keep rolling. Is it possible to make it display only the first number the program comes across when the mouse is clicked? here is the code I used.



The darkest minds, are often the brightest.
Xyus
15
Years of Service
User Offline
Joined: 5th Sep 2009
Location:
Posted: 18th Jan 2010 04:31 Edited at: 18th Jan 2010 05:56
You can have it check whether a number has been selected by having a flag variable set to one after the dice is rolled with the conditional statement requiring zero to pass, (I know that wasn't all too clear so here is an example: )



(You can set it back to zero somewhere else, like when pressing the spacebar, or whatever your particular needs(when turn starts, etc))

That's the easy route.

Make sure to use a different flag variable for each dice.
Sickly
15
Years of Service
User Offline
Joined: 14th Jul 2009
Location: Does it matter?
Posted: 18th Jan 2010 05:51 Edited at: 18th Jan 2010 06:15
hmm. I see. I have an idea to go with that, to reset the firstroll back to 0 with out doing anything. i think...

Ha! Thanks. Got it working perfect now. and I set it up so you could use the same variable in each if statement.



Thanks man.

The darkest minds, are often the brightest.
Xyus
15
Years of Service
User Offline
Joined: 5th Sep 2009
Location:
Posted: 18th Jan 2010 06:19 Edited at: 18th Jan 2010 06:25
You're welcome. Glad to help.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jan 2010 01:26
You can also do a loop that won't end till the mouse button is let go.



Sickly
15
Years of Service
User Offline
Joined: 14th Jul 2009
Location: Does it matter?
Posted: 19th Jan 2010 19:23
yea. I like the way I set it up with mouseclick()=0. here is what I changed it to.



I like this way, because I can use the same variable for each dice image with out actually having to do anything to clear it aside letting go of the mouse, which the user will do. Thanks for all the help though seriously guys. I am pretty stoked to have written my first complete program. I would like to make a new tool for my D&D games, but I need the DarkINK DLL to make it work. I want to create a character sheet editor(generator) so I can print my own. Not really something I "need" but I would like to try and create it none the less.

The darkest minds, are often the brightest.

Login to post a reply

Server time is: 2024-09-28 14:27:49
Your offset time is: 2024-09-28 14:27:49