Questions tagged [pyglet]

Pyglet is a cross-platform windowing and multimedia library for Python which provides interface to the platform's OpenGL library.

Pyglet is a cross-platform windowing and multimedia library for Python which provides interface to the platform's OpenGL library.

Pyglet has built-in support for mouse and keyboard events, and can load several multimedia file formats (optionally via AVbin). OpenAL, DirectSound or ALSA can be used for audio playback, with 3D positional audio support.

Pyglet is divided into several interdependent modules such as pyglet.gl, pyglet.graphics, pyglet.image, pyglet.media, pyglet.text, and pyglet.window.

919 questions
0
votes
2 answers

How to find what direction the player is in from an enemy?

I have managed to get the enemy ai moving towards the player using this code (python and pyglet): (dx, dy) = ((player.x - self.x)/math.sqrt((player.x - self.x) ** 2 + (player.y - self.y) ** 2),(player.y - self.y)/math.sqrt((player.x -…
user1237200
  • 149
  • 4
  • 13
0
votes
1 answer

Label in pyglet not drawing in batch

I am attempting to use a batch in pyglet to draw labels. Currently this batch is used for drawing every entity that I create, and everything draws just fine. I can add hundreds of Sprites to it and they will all be drawn, but not any labels that I…
Freezerburn
  • 1,013
  • 3
  • 11
  • 29
0
votes
1 answer

Python (w/ pyglet) memory leak

In a very large project I'm searching for a memory leak. Here my progress so far: Using a class counter, import gc from collections import Counter def count(): return Counter(type(o).__name__ for o in gc.get_objects()) I see that for each…
Berserker
  • 1,112
  • 10
  • 26
0
votes
1 answer

Pyglet: How to let sprite instances of same class share coordinates?

How do you make this code work: Just have pyglet installed and change assassin1.png,assassin2.png and assassin3.png with the name of images stored in the directory where you saved this code to a file. import pyglet def sprite_type(type_ =…
Bentley4
  • 10,678
  • 25
  • 83
  • 134
0
votes
1 answer

How is this method called? (Pyglet)

The following code is an alternative to the usual style (using decorators) pyglet makes use of. Can anyone explain how the on_draw() method is called here? import pyglet class HelloWorldWindow(pyglet.window.Window): def __init__(self): …
Bentley4
  • 10,678
  • 25
  • 83
  • 134
0
votes
1 answer

Pyglet: Sprite.draw() and Batch.draw() don't work, but Image.blit does

In pyglet, which I'm learning, Image.blit() works, but Sprite.draw() doesn't, nor Batch.draw(), even in this simple code: import pyglet win = pyglet.window.Window() img = pyglet.resource.image('test.png') spr =…
L01man
  • 1,521
  • 10
  • 27
0
votes
2 answers

Moving many sprites the same distance at the same time with pyglet

I know how to draw them at the same time using batches but I was wondering if there was a way to move a whole batch at once. Do I need to move all sprites individually? So far I have been doing it like this: tile2…
user1237200
  • 149
  • 4
  • 13
0
votes
1 answer

How to make random unlimited terrain in a pyglet side scroller?

I am trying to make a side scroller game using pyglet and I have managed to draw a background, a character and some terrain. (I am pretty new to GUI stuff) The problem is that when the player moves the character, the terrain is meant to generate…
user1237200
  • 149
  • 4
  • 13
0
votes
4 answers

How to use pause method in pyglet package

I am writing code for music player using pyglet package in python. I could play a song successfully. But i cannot pause the song after calling pyglet.app.run(). If i call pyglet.app.run() after calling pause i can not play the song. How can i manage…
chom
  • 265
  • 1
  • 5
  • 16
-1
votes
1 answer

Pyglet can read mp3 files in a Python Mac application (.app) created with PyInstaller, but only when I run the application from the command line

I am creating a program using Python 3.10.8 (Miniconda distribution) that relies on pyglet version 1.5.27. One feature of my program involves loading audio files into pyglet using this function: pyglet.media.load("{path_to_audio_file}") Recently, I…
-1
votes
1 answer

I'm completely new to pyglet and a python noob, but I'm trying to "spawn" food for my "dot" at set intervals. What am I missing here?

from random import randint import pyglet from pyglet import shapes, clock from time import sleep window = pyglet.window.Window(960, 540) batch = pyglet.graphics.Batch() ... dot = shapes.Circle(dot_rng_pos_x, dot_rng_pos_y, 5, color=rng_color,…
Elphie
  • 1
-1
votes
1 answer

I'm trying to make snake with pyglet but I can't get the snake to turn correctly

I've been trying to code the snake game with pyglet and I have everything worked out except for one problem, and that problem is that I can't figure out how to have the snake actually turn instead of just rotate 90 degrees. My current code makes the…
-1
votes
1 answer

How can I get the name of the current source playing in pyglet?

I don't know how to get the name of the current source playing in pyglet, I put different sources in a playlist and the playlist is playing one of the sources randomly, here's my code: player = pyglet.media.Player() music1 = pyglet.media.load('A…
Thewhyap
  • 49
  • 10
-1
votes
1 answer

Pyglet label text not displaying in python 3.9

Output Tried same code in 3.7 and the label can be displayed but not in python 3.9 I tried run same code in 3.7 and the label can be displayed. Version of pyglet is 1.5.16. Tried to add "win.flip()" but still no luck. import pyglet import…
Daniel Wu
  • 31
  • 5
-1
votes
1 answer

I want to display five numbers in the new window using pyglet

I've been trying to display five numbers from 0 to 4 every second each. import pyglet import time window = pyglet.window.Window() @window.event def on_draw(): for n in range(0,5): window.clear() label =…