Questions tagged as 'pygame'

1
answer

How do I pause a song in python?

I can make the program play the music, but the whole window is not functional and only works again when the music stops, ie creating a button with def to pause the button only becomes "clickable" when the whole song stop. from tkinter import *...
asked by 17.05.2018 / 11:43
0
answers

Absurd performance difference between pygame.surfarray.array3d and array2d

Using pygame.surfarray to handle an image as an array, manipulating any element in a array3d is more than 5 times slower than manipulating a array2d element. / p> See this benchmark: from datetime import * import pygam...
asked by 27.09.2018 / 01:06
0
answers

How can I update the text position when I change the button position?

I have a class button that is a sprite and has a text attribute that is also a sprite. I wanted to know how to change the position of the text when I change the position of the button rect? import pygame class Botao(pygame.sprite.Sprite):...
asked by 12.11.2017 / 13:02
0
answers

Is there a single way to use images in pygame?

I read in the documentation that there is the image.load method to read images, however it returns an object of type Surface which is not always the most appropriate, so I was wondering if there is a way to return an object of type...
asked by 15.10.2017 / 17:41
0
answers

"No module named pygame.base" - pygame and pypy

After several attempts and errors, I was able to install pygame 1.9.2a0 in pypy3, downloading the current version via mercurial and installing via / path / pypy3 setup.py But at the moment of giving import, I get the following error: Traceb...
asked by 15.03.2015 / 18:35
1
answer

Which class should the text class inherit?

When using pygame it is very common that user classes inherit from pygame classes, for example a class of characters usually vaqi extend the class pygame.sprite.Sprite. But is a text class could inherit from which pygame class?     
asked by 25.10.2017 / 01:51
5
answers

music does not play

I have the following code in python #*-coding:utf-8;-* import pygame pygame.init() pygame.mixer.music.load('ex1.mp3') pygame.mixer.music.play() pygame.event.wait() In case, it should play a song when it is run in pycharm, however, it perfor...
asked by 01.04.2018 / 20:50
2
answers

How to inherit a pygame class?

When I run this code (this is the current integer code, ie only 3 lines): import pygame class sp(pygame.sprite): pass I get:    TypeError: module () takes at most 2 arguments (3 given) I would like to inherit this class to create...
asked by 17.09.2018 / 03:42
1
answer

How to keep the sonic inside the screen ?, n coming out from the sides

import pygame as pg pg.init() display_width = 1000 display_height = 600 color_black =(0,0,0) color_white = (255,255,255) color_red = (255,0,0) #tamanho da imagem sonic_width = 71 window = pg.display.set_mode((display_width,display_height))...
asked by 20.05.2018 / 06:27
1
answer

Help with a simple game

Well, I'm trying to make a "ball" follow the playing rectangle, however it does not seem to be happening as the "ball" kind of blurs the screen when I move the player. I already tried to solve the problem and found nothing. Previously I had t...
asked by 27.11.2016 / 20:31