Replies: 1 comment
-
Default fonts are discussed in #1017 and #1325 :) As discussed in #1790, the consensus seems to be that system fonts are a good way to go, but we need to think about how exactly we want to do that. A simple API to play a sound is new and valuable though: can you make an issue for it? There's an |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When copy-pasting the code for Breakout, It wasn't immediately obvious where the fonts and sounds were in the repo, and there's no default font, so the game just skips rendering text and throws an error in console when no fonts can be loaded. Macroquad has a default font, so I think we should have one too.
As for sound, a built-in sound to test with would be fine, but I'd prefer a play_frequency(hertz,duration) method so that you can do math to the hertz directly and make interesting effects without needing to import anything. A OS-agnostic https://docs.python.org/3/library/winsound.html winsound-alike should? be fairly easy to implement.
https://www.seventhstring.com/resources/notefrequencies.html using this chart or similar and either code like this:
Not sure why code fences aren't working!
`#python 3
import time
import winsound
def note(name):
octave = int(name[-1])
PITCHES = "c,c#,d,d#,e,f,f#,g,g#,a,a#,b".split(",")
pitch = PITCHES.index(name[:-1].lower())
return int(440 * 2 ** ((octave - 4) + (pitch - 9) / 12.))
sequence = [("a3",8),("b3",8),("c4",256),("c#4",8),(None,1),("d#4",4),("e4",4),("f4",4),
("f#4",4),("g4",4), ("g#4",4),("a4",4),("a#4",4),("b4",4),("c5",4),]
for (notename, denominator) in sequence:
length = 1/denominator
if notename:
winsound.Beep(note(notename), int(length*1000))
else:
time.sleep(length)`
(Searching didn't bring anything up, hopefully this isn't a repeat)
Beta Was this translation helpful? Give feedback.
All reactions