pygame

how to play mp3

眉间皱痕 提交于 2019-12-21 04:31:24
问题 my problem starts here: pyttsx and gTTS module errors gTTS works well, takes text from text file, but first creates mp3 file, then if I want listen, I must call this mp3, so it is good but it would be better if I can avoid any audio files, and get just read from text file. maybe somehow I can use google voice to read from text file..? anyway main question now is other if I can use only gTTS what is the best way to play mp3 on Windows 10-64 bit, Python 3.5 ok with os: import os os.startfile("D

Pygame draw anti-aliased thick line

北战南征 提交于 2019-12-21 04:18:08
问题 I used to draw lines (given some start and end points) at pygame like this: pygame.draw.line(window, color_L1, X0, X1, 2) , where 2 was defining the thickness of the line. As, anti-aliasing is not supported by .draw , so I moved to .gfxdraw and pygame.gfxdraw.line(window, X0[0], X0[1], X1[0], X1[1], color_L1) . However, this does not allow me to define the thickness of the line. How could I have thickness and anti-aliasing together? 回答1: After many trials and errors, the optimal way to do it

Py2app: Operation not permitted

心已入冬 提交于 2019-12-21 04:10:48
问题 I want to create an application called 'dodgeball' and I have my main script (which uses pygame), and my setup.py script. I need an image named ball.bmp that I need as well. Inside my setup.py script I have the following code: from setuptools import setup APP = ['dodgeball.py'] DATA_FILES = ["ball.bmp"] OPTIONS = {'argv_emulation': True} setup( app=APP, data_files=DATA_FILES, options={'py2app': OPTIONS}, setup_requires=['py2app'], ) Whenever I try to make the application using the following

Why is pyglet so slow compared to pygame?

萝らか妹 提交于 2019-12-21 02:21:14
问题 Here is the code. 5000 bouncing spinning red squares. (16x16 png) On the pygame version I get 30 fps but 10 fps with pyglet. Isnt OpenGl supposed to be faster for this kind of thing? pygame version: import pygame, sys, random from pygame.locals import * import cProfile # Set FPS FPS = 60.0 clock = pygame.time.Clock() # Set window WINDOWWIDTH= 800 WINDOWHEIGHT = 600 pygame.init() screen = pygame.display.set_mode((WINDOWWIDTH,WINDOWHEIGHT)) screen.fill((0,0,0)) background = screen.copy()

Why is pyglet so slow compared to pygame?

百般思念 提交于 2019-12-21 02:21:07
问题 Here is the code. 5000 bouncing spinning red squares. (16x16 png) On the pygame version I get 30 fps but 10 fps with pyglet. Isnt OpenGl supposed to be faster for this kind of thing? pygame version: import pygame, sys, random from pygame.locals import * import cProfile # Set FPS FPS = 60.0 clock = pygame.time.Clock() # Set window WINDOWWIDTH= 800 WINDOWHEIGHT = 600 pygame.init() screen = pygame.display.set_mode((WINDOWWIDTH,WINDOWHEIGHT)) screen.fill((0,0,0)) background = screen.copy()

PyCharm autocomplete does not work with pygame

半世苍凉 提交于 2019-12-20 21:03:14
问题 I've just installed PyCharm Community Edition 3.4.1 and tried to make a simple pygame project in it. I found that code completion runs in a weird way. In this case: from pygame import event event. when I type event. a completion popup with event methods shows immediately. But in the second case: import pygame pygame.event. a popup contains only object methods. How can I learn the autocomplete tool to look deeper into the library? 回答1: Other than creating your own skeletons, you can't. You can

Intersection between bezier curve and a line segment

 ̄綄美尐妖づ 提交于 2019-12-20 12:34:25
问题 I am writing a game in Python (with pygame) that requires me to generate random but nice-looking "sea" for each new game. After a long search I settled on an algorithm that involves Bezier curves as defined in padlib.py. I now need to figure out when the curves generated by padlib intersect a line segment. The brute force method would be to just use the set of approximating line segments produced by padlib to find the answer. However, I suspect that a better answer can be found analytically.

py2app built app displays `ERROR: pygame.macosx import FAILED` on other machines

让人想犯罪 __ 提交于 2019-12-20 10:27:50
问题 Trying to build an app on the Mac using py2app. Got everything working fine on my machine, but when moving the app to another, it crashes and the console displays this error. ERROR: pygame.macosx import FAILED Anybody have a solution to this? 回答1: Found the problem and solution after many hours. Turns out other people have experienced similar problems and their articles were quite helpful: http://b.atcg.us/blog/2010/04/13/py2app-hell-the-first.html http://www.vijayp.ca/blog/?p=62 In case

Pygame water ripple effect

社会主义新天地 提交于 2019-12-20 09:29:17
问题 I have Googled for it but there are no ready scripts - as opposed to the same effect on Flash. I have checked the algorithm on The Water Effect Explained and also tested an implementation of the Perlin Noise, which provides a good simulation of the end of waves on a flat surface. I am looking for the same implementation found on several Flash Effects, based on mouseover/hover actions. This is targetting an interactive floor library, and I would enjoy moving away from Flash for this matter,

Pygame, Character Movement Speed

放肆的年华 提交于 2019-12-20 07:35:54
问题 I am a student at the University of Utah and am working on a project in Pygame that I am having minor trouble with. I have coded the entirety of the game, and it runs perfectly, but I would like my character to slow movement when walking over certain terrain. For example, if he/she walks over a sand tile than I would like for his/her speed to cut in half. I have not been able to figure this out on my own as I am still learning. The link to my code is below. Any help would be much appreciated!