Hello guys!
Where could I find documentation on developing audiogames using pygame?
If you do not hear, is there any documentation that is fairly focused on audio, keyboard manipulation, etc?
Pages 1
You are not logged in. Please login or register.
AudioGames.net Forum → Developers room → learning pygame?
Hello guys!
Where could I find documentation on developing audiogames using pygame?
If you do not hear, is there any documentation that is fairly focused on audio, keyboard manipulation, etc?
You won't find a full documentation dedicated to audiogames somewhere, because audiogames are simply not interesting enough to create a documentation for those. The pygame documentation features alot things like keyboard/joystick handling, audio playback and more. You'll have to think and puzzle together the things you need instead of just copy-pasting though.
Best Regards.
Hijacker
I have an example that can help get you started with the core basics, window, key input, audio, etc.
import pygame
from pygame import mixer
import sys
def Example():
#initialize pygame
pygame.init()
#initialize sound mixer
mixer.init()
#create display
window = pygame.display.set_mode([640,480])
#load sound
sound = mixer.Sound('tone5.wav')
#main update loop
while True:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
#if space is pressed, play sound
if event.key == pygame.K_SPACE:
sound.play()
#if escape is pressed, quit
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit(0)
#update window
pygame.display.update()
Example()
If you want an example using my own OpenAL wrapper instead of pygames limited mixer, feel free to ask.
hi, I am trying to learn about py game also, so i used this example.
however when running it from powershell, i just get a message welcoming me to pygame, then the program clozes, a window isn't even shone.
not really sure if i did something wrong, but i have pygame so it's not that.
@5
that was the function definition.
The function wasn't called in the main program, that's why the code doesn't execute
either type example() at the end of the file, or use something like:
if __name__ == '__main__':
example()
lol, i feel stupid now. I just saw that there was no line that called the function.
And that shows how bad at computers i am.
I have some problems.
I create a function, I put the commands of sounds and keys, but any key that I press the program closes.
What can I do?
You are probably getting an error when you press any key. You should send your code here so we can find the errors and tell you about them
A good thing that I learned is typing this into your command line or power shell.
python script.py>output.txt
This will capture any text your program outputs into a file called output.txt which will be located in the directory of your script. This is good because some tracebacks are silent, and you need to know how to review the screen to see them. That command eliminates the need.
python script.py > output.txt 2>&1 is even better and pipes errorneous output as well when under Windows . When under Linux, python script.py >& output.txt works fine as well.
Best Regards.
Hijacker
hi
if you use windows, can to get the vscode and play witc python.
you no will to need redirect the output for a file
AudioGames.net Forum → Developers room → learning pygame?
Generated in 0.036 seconds (47% PHP - 53% DB) with 10 queries