@@ -22,7 +22,7 @@ def positionOnOrbit():
22
22
angle = random (TAU )
23
23
# `randint` slightly offsets the position so we don't end up with the
24
24
# visible HRects orbiting on *exact* circles.
25
- radius = chooseOrbit () + randint (0 , 22 )
25
+ radius = chooseOrbit () + randint (0 , int ( width / 23 ) )
26
26
createX = centerX + (cos (angle ) * radius ) # `angle` *must* be radians.
27
27
createY = centerY + (sin (angle ) * radius ) #
28
28
return createX , createY
@@ -31,32 +31,34 @@ def positionOnOrbit():
31
31
def chooseOrbit ():
32
32
'''
33
33
Randomly choose an orbit, based on a set of weights.
34
+ The returns can be adjusted to account for a larger / smaller sketch size.
34
35
'''
35
36
chance = random (1 )
36
37
if chance < 0.18 :
37
- return 64
38
+ return width / 8
38
39
elif chance < 0.50 :
39
- return 128
40
+ return width / 4
40
41
elif chance < 0.78 :
41
- return 208
42
+ return width / 2.46
42
43
elif chance < 1.0 :
43
- return 288
44
+ return width / 1.7777
44
45
45
46
46
47
def applyRotation (obj , speed , tolerance ):
47
48
'''
48
- Attach an HRotate to the given object, with speed `speed`.
49
+ Attach an HRotate to the given object, calling `avoidZero` to set the
50
+ speed (angular speed in degrees per draw()).
49
51
'''
50
52
HRotate (obj , avoidZero (speed , tolerance ))
51
53
52
54
53
55
# This is specifically used to avoid zero or synchronous rotation. We want all
54
- # visible HRects to *appear* to rotate in place.
56
+ # visible HRects to *appear* to rotate " in place" .
55
57
def avoidZero (limit , tolerance ):
56
58
'''
57
- Return a random value in the range from `-limit` to `limit - 1`, excluding
58
- the inner range from `-tolerance` to ` tolerance - 1 ` (and, logically, zero
59
- as well).
59
+ Return a random value in the range from `-limit` to strictly less than
60
+ `limit`, excluding the inner range +/-` tolerance` (and, logically, zero as
61
+ well).
60
62
'''
61
63
value = random (- limit , limit )
62
64
while - tolerance < value < tolerance :
0 commit comments