QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: FilipeEstima on September 27, 2020, 11:16:18 pm
-
I have zero experience with capturing mouse movements with QB64. I'm thinking about a way to insert some random elements in an array and since computers can't generate true random numbers, I figured maybe I could use input made by mouse movements to help. What are the instructions I need to use for that?
-
_TITLE "Mouse x, y is column, row for a character in screen 0" LOCATE 1, 1:
PRINT "Mouse:"; mx; my
' print current location
I look forward to seeing mouse movements converted to random numbers, very interesting!
-
Thanks bplus, I will give a try!
-
Here's an idea:
_TITLE "Mouse x, y is column, row for a character in screen 0"
sum = 0
LOCATE 1, 1:
PRINT "Mouse:"; mx; my
' print current location
sum = sum + mx*my
omx = mx
omy = my
When you start the program with the same mouse position every time, the number will be the same. But as you move the mouse around over a long run time you should get less predictable results. Can't comment on stats encryption or 'entropy' whatever, just an idea.
-
Why not a RANDOMIZE (TIMER * (1 + _MOUSEX) * (1 + _MOUSEY))? I’d imagine that’d be a little difficult to ever predict exactly what seed might be used to generate your seed number.
(And note the +1 to both mousex and mousey... This is to prevent us multiplying by 0, giving skewed, multiply repetitive results.)