pyglet

How to run OpenAI Gym .render() over a server

空扰寡人 提交于 2019-12-03 00:12:42
问题 I am running a python 2.7 script on a p2.xlarge AWS server through Jupyter (Ubuntu 14.04). I would like to be able to render my simulations. Minimal working example import gym env = gym.make('CartPole-v0') env.reset() env.render() env.render() makes (among other things) the following errors: ... HINT: make sure you have OpenGL install. On Ubuntu, you can run 'apt-get install python-opengl'. If you're running on a server, you may need a virtual frame buffer; something like this should work:

How to run OpenAI Gym .render() over a server

妖精的绣舞 提交于 2019-12-02 13:56:48
I am running a python 2.7 script on a p2.xlarge AWS server through Jupyter (Ubuntu 14.04). I would like to be able to render my simulations. Minimal working example import gym env = gym.make('CartPole-v0') env.reset() env.render() env.render() makes (among other things) the following errors: ... HINT: make sure you have OpenGL install. On Ubuntu, you can run 'apt-get install python-opengl'. If you're running on a server, you may need a virtual frame buffer; something like this should work: 'xvfb-run -s \"-screen 0 1400x900x24\" python <your_script.py>'") ... NoSuchDisplayException: Cannot

FPS with Pyglet half of monitor refresh rate

血红的双手。 提交于 2019-12-01 07:27:59
问题 I'm new to working with Pyglet and I've written a small program which moves a ball around the screen. Right now I'm having difficulty establishing a steady frame rate of 60 fps. While Pyglet is supposed to sync with my monitor's refresh rate of 60Hz, Pyglet is setting my fps to half of my refresh rate (ex. when 60Hz, 30 fps). Is there something wrong in my code that is causing this? import pyglet import physicalobject import random from pyglet.window import mouse pyglet.resource.path = ['.

How to play music continuously in pyglet

流过昼夜 提交于 2019-12-01 01:34:13
me and my friend are working on a game and we want our music to loop as long as the game is running. Help please there seems to be no function to put music on repeat In current versions of pyglet, you should use a SourceGroup , setting the loop attribute to True . You can then queue it into a Player to play it: snd = pyglet.media.load('sound.wav') looper = pyglet.media.SourceGroup(snd.audio_format, None) looper.loop = True looper.queue(snd) p = pyglet.media.Player() p.queue(looper) p.play() Not sure if there's a more compact way of doing this but it seems to work... To make a sound play in a

Playing .mp3 files with PyAudio

喜夏-厌秋 提交于 2019-11-30 15:47:30
Can pyaudio play .mp3 files? If yes, may I ask to write an example please. If no, what is the simplest way to convert .mp3 to .wav? I have tried to use PyDub, could get my .wav file, but when I try to play it with PyAudio I get following error: File "C:\Python33\lib\wave.py", line 130, in initfp raise Error('file does not start with RIFF id') wave.Error: file does not start with RIFF id With other .wav samples (which where not converted from mp3) if works well. I am using gTTS library to convert text to speech for my application. It creates short .mp3 files which I need to play then. Right now

Differences between Python game libraries Pygame and Pyglet?

可紊 提交于 2019-11-30 10:11:29
问题 I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days. How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use? Finally, would you say that one is more Pythonic than the other? 回答1: I was considering both Pygame and Pyglet for a small 2D shooter, and after looking at source code and some tutorials went with Pyglet. I was very happy with the results. Pyglet worked immediately and

basic openGL, vertex buffers and pyglet

狂风中的少年 提交于 2019-11-30 07:28:58
Edit: rotoglup found the problems in my code, adding the shaders I had removed completed the solution. See my answer below for the correct code (with shaders). Hi all ! I'm trying to learn some basics of modern OpenGL from this tutorial . I'd like to do it with python/pyglet instead of C++ though. I know pyglet can abstract much of the low level OpenGL away; I want to understand some of the basics before moving on to hiding them behind layers of abstraction though. My problem is extremely simple: the code below only draws a single point instead of the 3 I am expecting. My code is, as far as I

Differences between Python game libraries Pygame and Pyglet?

五迷三道 提交于 2019-11-29 19:05:58
I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days. How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use? Finally, would you say that one is more Pythonic than the other? I was considering both Pygame and Pyglet for a small 2D shooter, and after looking at source code and some tutorials went with Pyglet. I was very happy with the results. Pyglet worked immediately and was enjoyable to work with, and conceptually very clean. It certainly had a Pythonic feel to me: you could

How can I play audio stream without saving it into the file with pyglet?

人盡茶涼 提交于 2019-11-29 12:18:25
Now I have these libraries: requests , pyglet , pyaudio How can I play an audio stream using ones, for example, from this site without saving it into the file(using buffering)? There is a confusing information in documentation of this library about a StreamingSource class When I push the information in bytes in StreamingSource object(source.get_audio_data(DATA)) and after that I push this one into a Player(pyglet.media.Player()) it throws an exception, that says that the StreamingSource hasn't attribute duration Code: import pyglet, requests req = requests.get('http://ic7.101.ru:8000/c15_3',

Pyglet Image Rendering

浪尽此生 提交于 2019-11-29 11:08:42
I'm working on a sort of a 2D Minecraft clone for my first in depth Pyglet project and I've run across a problem. Whenever I have a decent number of blocks on screen, the frame rate drops dramatically. Here is my rendering method: I use a dictionary with the key being a tuple(which represents the coordinate for the block) and the item being a texture. I loop through the entire dictionary and render each block: for key in self.blocks: self.blocks[key].blit(key[0] * 40 + sx,key[1] * 40+ sy) P.S. sx and sy are coordinate offsets for screen scrolling I would like to know if there is a way to more