Pages

sâmbătă, 7 noiembrie 2020

PyGame : Install pygame 2.0 from GitHub on Linux.

Let's install all Fedora packages need for this python package:
[root@desk pygame]# dnf install SDL2-devel.x86_64 
...
Installed:
  SDL2-devel-2.0.12-4.fc33.x86_64                                               

Complete!
[root@desk pygame]# dnf install SDL2_ttf-devel.x86_64
...
Installed:
  SDL2_ttf-2.0.15-6.fc33.x86_64       SDL2_ttf-devel-2.0.15-6.fc33.x86_64      

Complete!
[root@desk pygame]# dnf install SDL2_image-devel.x86_64
...
Installed:
  SDL2_image-2.0.5-5.fc33.x86_64      SDL2_image-devel-2.0.5-5.fc33.x86_64     

Complete!
[root@desk pygame]# dnf install SDL2_mixer-devel.x86_64 
...
Installed:
  SDL2_mixer-2.0.4-7.fc33.x86_64      SDL2_mixer-devel-2.0.4-7.fc33.x86_64     

Complete!
[root@desk pygame]# dnf install SDL2_gfx-devel.x86_64 
...
Installed:
  SDL2_gfx-1.0.4-3.fc33.x86_64        SDL2_gfx-devel-1.0.4-3.fc33.x86_64       

Complete!
[root@desk pygame]# dnf install portmidi-devel.x86_64 
...
Installed:
  portmidi-devel-217-38.fc33.x86_64                                             

Complete!
Use this command to clone it from GitHub and install it:
[mythcat@desk ~]$ git clone https://github.com/pygame/pygame
Cloning into 'pygame'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 38509 (delta 0), reused 0 (delta 0), pack-reused 38505
Receiving objects: 100% (38509/38509), 17.78 MiB | 11.66 MiB/s, done.
Resolving deltas: 100% (29718/29718), done.
[mythcat@desk ~]$ cd pygame/
[mythcat@desk pygame]$ python3.9 setup.py install --user


WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...


Hunting dependencies...
SDL     : found 2.0.12
FONT    : found
IMAGE   : found
MIXER   : found
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: found
PORTTIME: found
FREETYPE: found 23.4.17

If you get compiler errors during install, double-check
the compiler flags in the "Setup" file.
...
copying docs/pygame_tiny.gif -> build/bdist.linux-x86_64/egg/pygame/docs
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
creating /home/mythcat/.local/lib/python3.9/site-packages/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
Extracting pygame-2.0.1.dev1-py3.9-linux-x86_64.egg to /home/mythcat/.local/lib/python3.9/site-packages
Adding pygame 2.0.1.dev1 to easy-install.pth file

Installed /home/mythcat/.local/lib/python3.9/site-packages/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
Processing dependencies for pygame==2.0.1.dev1
Finished processing dependencies for pygame==2.0.1.dev1
Let's test it:
[mythcat@desk pygame]$ ls
build	     dist  examples	    README.rst	setup.cfg  src_c   test
buildconfig  docs  pygame.egg-info  Setup	setup.py   src_py
[mythcat@desk pygame]$ python3.9
Python 3.9.0 (default, Oct  6 2020, 00:00:00) 
[GCC 10.2.1 20200826 (Red Hat 10.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 2.0.1.dev1 (SDL 2.0.12, python 3.9.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> 

PyGame : The new pygame 2.0 .

A few days ago PyGame celebrated the anniversary of this python module ...
The 28th of October 2020 is the pygame 2.0 release date because pygame turns 20 years of age.
Here's what we find for pygame on GitHub.
Here are some of the 3306 changes...
  • Support for Metal, Direct 3d, Vulkan, OpenGL 3.0+ in various profiles (core, compatibility, debug, robust, etc), OpenGL ES, and other modern hardware-accelerated video APIs across many platforms.
  • SSE2/Neon assembly image drawing. Much faster drawing routines, image loading, and alpha blending.
  • Type Hints, for code completion (and to help you make the squiggly lines disappear) in editors and IDEs.
  • Code cleanup, using lots of code robustness tools like static analyzers, and automated CI/CD. We've been able to help dozens of people new to community projects contribute. We have lots of work to go on code quality, but we're currently the highest rated Python and highest rate C large project on LGTM.
  • Many, many bug fixes including in our pygame.draw routines, pygame.math(for vectors), and pygame.mask for pixel-perfect collision detection.
  • better support for PyPy (the fast JIT based implementation of python). See our milestone
  • Are we pypy yet? No. for our progress on making PyPy the best python for games.
  • libsdl version 2 support. Technically pygame 2.0 still works with SDL 1, but we recommend SDL2 which is vastly improved over SDL1 for most use cases. Probably we will remove SDL 1 support starting pygame 2.1.
  • Touch support (multitouch, gestures, etc)
  • Audio input support (make games with your microphone!).
  • Message alert boxes (Press OK, or Cancel).
  • Better keyboard support. Proper Unicode input and IME support.
  • Much improved game controller support.
  • Better image and audio format support. Including webp, 32bit Wav files, and much more reliable mp3 support.
  • Multiple display support, and multiple window support (multi-window support is still experimental, more will come in pygame 2.1).
  • Android support through python for android (a fork of pygame subset for android). Better documentation and better support will come in future releases.
  • to make distributing your apps easier, a built-in "pyinstaller hook" and compatibility with cxfreeze.
  • binary "wheels" on many platforms and versions of python from the old python 2.7 - to the latest python 3.9 (and with pypy!).
  • lots of quality of life improvements like Surface.fill('black')instead of Surface.fill(pygame.Color(0, 0, 0)). Also, keywords are supported by many more function arguments. You can draw rounded corners on rects.
  • plenty of new examples, like, and python3 -m pygame.examples.music_drop_fade. Additionally, the example source code has been cleaned up a lot to follow a more current python style.
  • Hundreds of documentation improvements include a new Korean tutorial.
  • a special SCALED mode that takes low pixel games and automatically translates them to a larger window. Imagine your 320x200 resolution game of glorious pixel art... on modern screens that would be a very tiny window. Now with SCALED, it shows up big on a Full HD screen, or even a 4K/8K screen and the translation of mouse coordinates and up-scaling of pixels is done for you (hardware accelerated of course).