chord; number range
This commit is contained in:
parent
8a541bbddf
commit
0df4835d60
|
@ -91,7 +91,7 @@ class Input(GameChild):
|
|||
self.post_any_command(event.button, cancel)
|
||||
|
||||
def translate_axis_motion(self, event):
|
||||
if not self.suppressed:
|
||||
if not self.suppressed and not self.check_command_line("-disable-joy-axis"):
|
||||
axis = event.axis
|
||||
value = event.value
|
||||
if not value:
|
||||
|
|
14
pgfw/Note.py
14
pgfw/Note.py
|
@ -124,3 +124,17 @@ class Note(Samples):
|
|||
if channel and panning:
|
||||
channel.set_volume(*panning)
|
||||
return channel
|
||||
|
||||
|
||||
class Chord:
|
||||
|
||||
def __init__(self, *args):
|
||||
self.notes = args
|
||||
|
||||
def play(self, maxtime=0, fadeout=[None], panning=None, fade_in=[0]):
|
||||
if isinstance(fadeout, int):
|
||||
fadeout = [fadeout]
|
||||
if isinstance(fade_in, int):
|
||||
fade_in = [fade_in]
|
||||
for ii, note in enumerate(self.notes):
|
||||
note.play(maxtime, fadeout[ii % len(fadeout)], panning, fade_in[ii % len(fade_in)])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from random import randint
|
||||
from math import sin, cos, atan2, radians, sqrt
|
||||
from random import randint, random
|
||||
from math import sin, cos, atan2, radians, sqrt, pi
|
||||
|
||||
def get_step(start, end, speed):
|
||||
x0, y0 = start
|
||||
|
@ -7,6 +7,12 @@ def get_step(start, end, speed):
|
|||
angle = atan2(x1 - x0, y1 - y0)
|
||||
return speed * sin(angle), speed * cos(angle)
|
||||
|
||||
def get_angle(start, end, transpose=False):
|
||||
angle = atan2(end[1] - start[1], end[0] - start[0])
|
||||
if transpose:
|
||||
angle = -angle - pi
|
||||
return angle
|
||||
|
||||
def get_endpoint(start, angle, magnitude):
|
||||
"""clockwise, 0 is up"""
|
||||
x0, y0 = start
|
||||
|
@ -98,3 +104,11 @@ def collide_line_with_rect(rect, p0, p1):
|
|||
(rect.bottomleft, rect.topleft)):
|
||||
if get_intersection(p0, p1, *line):
|
||||
return True
|
||||
|
||||
def get_random_number_in_range(start, end):
|
||||
return random() * (end - start) + start
|
||||
|
||||
def get_value_in_range(start, end, position, reverse=False):
|
||||
if reverse:
|
||||
position = 1 - position
|
||||
return (end - start) * position + start
|
||||
|
|
Loading…
Reference in New Issue