2019-07-13 22:17:56

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?

2019-07-13 22:19:21

pygame.org

Paul

2019-07-13 22:43:24

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

2019-07-14 08:32:57

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.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2019-07-14 11:05:58

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.

Have a lovely day.

2019-07-14 18:38:11

@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()

Paul

2019-07-14 18:56:22

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.

Have a lovely day.

2019-07-14 19:35:45

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?

2019-07-14 20:06:37

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

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2019-07-14 23:24:29 (edited by amerikranian 2019-07-14 23:26:33)

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.

2019-07-15 09:40:22

@ 10 good idea, that's  what i do

Have a lovely day.

2019-07-15 23:24:58

python script.py > output.txt 2>&1 is even better and pipes errorneous output as well when under Windows smile. When under Linux, python script.py >& output.txt works fine as well.
Best Regards.
Hijacker

2019-07-16 04:28:00

Interesting, I may have to give that a shot.

2019-07-21 15:54:23

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

2019-07-21 17:22:51

@10, thanks! I never knew about that.