Pyglet

Pyglet is a library for the Python programming language that provides an object-oriented application programming interface for the creation of games and other multimedia applications.[1][2] pyglet runs on Microsoft Windows, macOS, and Linux; it is released under the BSD Licence. pyglet was first created by Alex Holkner.

Features

Pyglet is written entirely in Python. Images, video, and sound files in a range of formats can be done natively but can also be expanded with the libav and ffmpeg libraries. It requires no external dependencies.[3]

Text display and formatting

  • Rich text formatting (bold, italic, underline, color change, background color, indent, lists) (pyglet.text.formats)
  • Built-in layouts to support editable text
  • Carets (pyglet.text.caret.Caret)
  • HTML support (pyglet.text.layout.IncrementalTextLayout)

Image and sprite work

  • Fast image processing and rendering
  • Built-in sprites (pyglet.sprite)
  • Animated images (*.gif)

Graphics

  • OpenGL shaders supported
  • Simple built-in shapes (rectangles, circles, triangles) (pyglet.shapes)
  • Batched rendering (pyglet.graphics.Batch)
  • 3D model rendering

Events and file system

  • Resource management (pyglet.resource)
  • Clock for processing events and time (pyglet.clock.Clock)
  • Window events (pyglet.window.Window)
  • Event dispatching (pyglet.event.EventDispatcher)
  • Context management

Sprites, text layouts, and text functions are implemented. Multi-level lists are supported and can be created using HTML. Different sections of the displayed document can have distinct styles. A built-in caret provides support for text editing, resembling many features of a UI text input caret.

Example

from pyglet.window import Window
from pyglet.app import run

window = Window(caption="Hello world!", width=640, height=480)

run()

In this example, lines 1-2 import the pyglet module's necessary components. Line 4 creates a window, and line 6 calls pyglet to run its event loop. Optionally an update rate (in frames per second) can be specified in a rate parameter.

See also

References

  1. ^ Briggs, Anthony (2012-02-12). Hello! Python. Simon and Schuster. ISBN 978-1-63835-152-8.
  2. ^ Paz, Alejandro Rodas de; Howse, Joseph (2015-09-28). Python Game Programming By Example. Packt Publishing Ltd. ISBN 978-1-78528-391-8.
  3. ^ Choudhury, Ambika (2020-06-12). "Top Python Frameworks For Game Development". Analytics India Magazine. Retrieved 2024-04-12.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.