├── examples ├── __init__.py ├── data │ ├── blue.mpg │ ├── bomb.gif │ ├── boom.wav │ ├── brick.png │ ├── chimp.bmp │ ├── city.png │ ├── fist.bmp │ ├── punch.wav │ ├── sans.ttf │ ├── shot.gif │ ├── whiff.wav │ ├── yuv_1.pgm │ ├── alien1.gif │ ├── alien1.jpg │ ├── alien1.png │ ├── alien2.gif │ ├── alien2.png │ ├── alien3.gif │ ├── alien3.png │ ├── asprite.bmp │ ├── danger.gif │ ├── liquid.bmp │ ├── player1.gif │ ├── static.png │ ├── arraydemo.bmp │ ├── background.gif │ ├── car_door.wav │ ├── explosion1.gif │ ├── house_lo.mp3 │ ├── house_lo.ogg │ ├── house_lo.wav │ ├── midikeys.png │ ├── oldplayer.gif │ └── secosmic_lo.wav ├── macosx │ └── aliens_app_example │ │ ├── English.lproj │ │ ├── aliens.icns │ │ └── MainMenu.nib │ │ │ ├── keyedobjects.nib │ │ │ ├── JavaCompiling.plist │ │ │ ├── classes.nib │ │ │ └── info.nib │ │ ├── README.txt │ │ └── setup.py ├── .editorconfig ├── aacircle.py ├── setmodescale.py ├── sound.py ├── headless_no_windows_needed.py ├── overlay.py ├── audiocapture.py ├── moveit.py └── dropevent.py ├── src_c ├── cython │ └── pygame │ │ ├── __init__.pxd │ │ └── _sdl2 │ │ ├── __init__.pxd │ │ ├── mixer.pxd │ │ ├── sdl2.pxd │ │ ├── sdl2.pyx │ │ ├── mixer.pyx │ │ └── audio.pxd ├── _sdl2 │ └── touch.c ├── doc │ ├── gfxdraw_doc.h │ ├── README.rst │ ├── locals_doc.h │ ├── tests_doc.h │ ├── cursors_doc.h │ ├── overlay_doc.h │ ├── touch_doc.h │ ├── bufferproxy_doc.h │ ├── pixelcopy_doc.h │ ├── sndarray_doc.h │ ├── image_doc.h │ ├── scrap_doc.h │ ├── mouse_doc.h │ ├── time_doc.h │ └── key_doc.h ├── SDL_gfx │ └── SDL_gfxPrimitives_font.h ├── mask.h ├── pgbufferproxy.h ├── font.h ├── mixer.h ├── pgimport.h ├── .editorconfig ├── pgopengl.h ├── .clang-format ├── _camera.h ├── _surface.h ├── pgplatform.h ├── pgarrinter.h ├── pygame.h ├── pgcompat.c ├── include │ ├── pgplatform.h │ ├── pygame.h │ ├── pygame_mask.h │ ├── pygame_freetype.h │ ├── pygame_font.h │ ├── pygame_bufferproxy.h │ └── pygame_mixer.h ├── scale_mmx.c ├── fastevents.h ├── scrap_sdl2.c └── scrap_mac.c ├── test ├── font_tags.py ├── fastevent_tags.py ├── run_tests__tests │ ├── __init__.py │ ├── all_ok │ │ ├── __init__.py │ │ ├── zero_tests_test.py │ │ ├── no_assertions__ret_code_of_1__test.py │ │ ├── fake_2_test.py │ │ ├── fake_3_test.py │ │ ├── fake_4_test.py │ │ ├── fake_5_test.py │ │ └── fake_6_test.py │ ├── exclude │ │ ├── __init__.py │ │ ├── magic_tag_test.py │ │ ├── fake_2_test.py │ │ └── invisible_tag_test.py │ ├── timeout │ │ ├── __init__.py │ │ ├── sleep_test.py │ │ └── fake_2_test.py │ ├── everything │ │ ├── __init__.py │ │ ├── sleep_test.py │ │ ├── magic_tag_test.py │ │ ├── fake_2_test.py │ │ └── incomplete_todo_test.py │ ├── failures1 │ │ ├── __init__.py │ │ ├── fake_2_test.py │ │ ├── fake_3_test.py │ │ └── fake_4_test.py │ ├── incomplete │ │ ├── __init__.py │ │ ├── fake_2_test.py │ │ └── fake_3_test.py │ ├── print_stderr │ │ ├── __init__.py │ │ ├── fake_2_test.py │ │ ├── fake_3_test.py │ │ └── fake_4_test.py │ ├── print_stdout │ │ ├── __init__.py │ │ ├── fake_2_test.py │ │ ├── fake_4_test.py │ │ └── fake_3_test.py │ ├── incomplete_todo │ │ ├── __init__.py │ │ ├── fake_3_test.py │ │ └── fake_2_test.py │ └── infinite_loop │ │ ├── __init__.py │ │ ├── fake_2_test.py │ │ └── fake_1_test.py ├── test_test_.py ├── touch_tags.py ├── cdrom_tags.py ├── overlay_tags.py ├── fixtures │ ├── fonts │ │ ├── test_sans.ttf │ │ ├── PyGameMono.otf │ │ ├── test_fixed.otf │ │ ├── A_PyGameMono-8.png │ │ ├── u13079_PyGameMono-8.png │ │ ├── PyGameMono-8.bdf │ │ └── PyGameMono-18-75dpi.bdf │ └── xbm_cursors │ │ ├── white_sizing.xbm │ │ └── white_sizing_mask.xbm ├── image_tags.py ├── mixer_tags.py ├── imageext_tags.py ├── mixer_music_tags.py ├── camera_test.py ├── ftfont_tags.py ├── freetype_tags.py ├── sndarray_tags.py ├── surfarray_tags.py ├── util │ ├── gen_stubs_test.py │ └── svn_log_to_whatsnew.py ├── .editorconfig ├── scrap_tags.py ├── test_utils │ └── endian.py ├── ftfont_test.py ├── sysfont_test.py ├── overlay_test.py ├── touch_test.py ├── image__save_gl_surface_test.py ├── __init__.py ├── version_test.py └── key_test.py ├── docs ├── reST │ ├── ext │ │ ├── __init__.py │ │ ├── customversion.py │ │ ├── edit_on_github.py │ │ └── headers.py │ ├── ref │ │ ├── common.txt │ │ ├── code_examples │ │ │ ├── joystick_calls.png │ │ │ └── draw_module_example.png │ │ ├── locals.rst │ │ └── touch.rst │ ├── _static │ │ ├── pygame.ico │ │ ├── pygame_tiny.png │ │ ├── tooltip.css │ │ └── reset.css │ ├── tut │ │ ├── camera_hsv.jpg │ │ ├── camera_rgb.jpg │ │ ├── camera_yuv.jpg │ │ ├── chimpshot.gif │ │ ├── intro_ball.gif │ │ ├── surfarray.png │ │ ├── tom_basic.png │ │ ├── camera_green.jpg │ │ ├── camera_mask.jpg │ │ ├── intro_blade.jpg │ │ ├── tom_formulae.png │ │ ├── tom_radians.png │ │ ├── camera_average.jpg │ │ ├── camera_thresh.jpg │ │ ├── intro_freedom.jpg │ │ ├── surfarray_xfade.png │ │ ├── camera_background.jpg │ │ ├── surfarray_flipped.png │ │ ├── surfarray_redimg.png │ │ ├── surfarray_scaleup.png │ │ ├── surfarray_soften.png │ │ ├── surfarray_striped.png │ │ ├── camera_thresholded.jpg │ │ ├── surfarray_allblack.png │ │ ├── surfarray_rgbarray.png │ │ ├── surfarray_scaledown.png │ │ ├── tom_event-flowchart.png │ │ ├── common.txt │ │ └── chimp.py.rst │ ├── themes │ │ └── classic │ │ │ ├── page.html │ │ │ └── theme.conf │ ├── common.txt │ ├── c_api.rst │ ├── c_api │ │ ├── version.rst │ │ ├── cdrom.rst │ │ ├── display.rst │ │ ├── freetype.rst │ │ ├── event.rst │ │ ├── color.rst │ │ ├── bufferproxy.rst │ │ ├── surface.rst │ │ ├── rect.rst │ │ └── mixer.rst │ ├── filepaths.rst │ └── _templates │ │ └── header.h ├── pygame_logo.gif ├── pygame_tiny.gif ├── pygame_powered.gif ├── pygame_small.gif ├── ref │ └── docscomments.json ├── __init__.py ├── __main__.py ├── logos.html └── howto_release_pygame.txt ├── src_py ├── gp2x │ ├── locals.py │ ├── __init__.py │ └── constants.py ├── pygame.ico ├── _sdl2 │ └── __init__.py ├── freesansbold.ttf ├── pygame_icon.bmp ├── pygame_icon.icns ├── pygame_icon.tiff ├── .editorconfig ├── macosx.py ├── _dummybackend.py ├── locals.py ├── freetype.py ├── pkgdata.py └── _camera_opencv_highgui.py └── .gitignore /examples/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src_c/cython/pygame/__init__.pxd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src_c/cython/pygame/_sdl2/__init__.pxd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/font_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = [] 2 | -------------------------------------------------------------------------------- /test/fastevent_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = [] 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/all_ok/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/exclude/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/timeout/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/test_test_.py: -------------------------------------------------------------------------------- 1 | while True: 2 | pass 3 | -------------------------------------------------------------------------------- /docs/reST/ext/__init__.py: -------------------------------------------------------------------------------- 1 | # Make this a package 2 | 3 | -------------------------------------------------------------------------------- /test/run_tests__tests/everything/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/failures1/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/incomplete/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/print_stderr/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/print_stdout/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/touch_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['SDL1_ignore'] 2 | 3 | -------------------------------------------------------------------------------- /docs/reST/ref/common.txt: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | -------------------------------------------------------------------------------- /test/run_tests__tests/incomplete_todo/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/run_tests__tests/infinite_loop/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /test/cdrom_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['interactive', 'SDL2_ignore'] 2 | -------------------------------------------------------------------------------- /src_py/gp2x/locals.py: -------------------------------------------------------------------------------- 1 | 2 | from pygame.gp2x.constants import * 3 | 4 | -------------------------------------------------------------------------------- /src_py/pygame.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/src_py/pygame.ico -------------------------------------------------------------------------------- /docs/pygame_logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/pygame_logo.gif -------------------------------------------------------------------------------- /docs/pygame_tiny.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/pygame_tiny.gif -------------------------------------------------------------------------------- /src_c/_sdl2/touch.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/src_c/_sdl2/touch.c -------------------------------------------------------------------------------- /docs/pygame_powered.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/pygame_powered.gif -------------------------------------------------------------------------------- /docs/pygame_small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/pygame_small.gif -------------------------------------------------------------------------------- /examples/data/blue.mpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/blue.mpg -------------------------------------------------------------------------------- /examples/data/bomb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/bomb.gif -------------------------------------------------------------------------------- /examples/data/boom.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/boom.wav -------------------------------------------------------------------------------- /examples/data/brick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/brick.png -------------------------------------------------------------------------------- /examples/data/chimp.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/chimp.bmp -------------------------------------------------------------------------------- /examples/data/city.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/city.png -------------------------------------------------------------------------------- /examples/data/fist.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/fist.bmp -------------------------------------------------------------------------------- /examples/data/punch.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/punch.wav -------------------------------------------------------------------------------- /examples/data/sans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/sans.ttf -------------------------------------------------------------------------------- /examples/data/shot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/shot.gif -------------------------------------------------------------------------------- /examples/data/whiff.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/whiff.wav -------------------------------------------------------------------------------- /examples/data/yuv_1.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/yuv_1.pgm -------------------------------------------------------------------------------- /src_c/doc/gfxdraw_doc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/src_c/doc/gfxdraw_doc.h -------------------------------------------------------------------------------- /src_py/_sdl2/__init__.py: -------------------------------------------------------------------------------- 1 | from .sdl2 import * 2 | from .audio import * 3 | from .video import * 4 | -------------------------------------------------------------------------------- /src_py/freesansbold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/src_py/freesansbold.ttf -------------------------------------------------------------------------------- /src_py/pygame_icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/src_py/pygame_icon.bmp -------------------------------------------------------------------------------- /src_py/pygame_icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/src_py/pygame_icon.icns -------------------------------------------------------------------------------- /src_py/pygame_icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/src_py/pygame_icon.tiff -------------------------------------------------------------------------------- /test/overlay_tags.py: -------------------------------------------------------------------------------- 1 | # Overlay support was removed in SDL 2 2 | __tags__ = ['SDL2_ignore'] 3 | -------------------------------------------------------------------------------- /examples/data/alien1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/alien1.gif -------------------------------------------------------------------------------- /examples/data/alien1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/alien1.jpg -------------------------------------------------------------------------------- /examples/data/alien1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/alien1.png -------------------------------------------------------------------------------- /examples/data/alien2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/alien2.gif -------------------------------------------------------------------------------- /examples/data/alien2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/alien2.png -------------------------------------------------------------------------------- /examples/data/alien3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/alien3.gif -------------------------------------------------------------------------------- /examples/data/alien3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/alien3.png -------------------------------------------------------------------------------- /examples/data/asprite.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/asprite.bmp -------------------------------------------------------------------------------- /examples/data/danger.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/danger.gif -------------------------------------------------------------------------------- /examples/data/liquid.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/liquid.bmp -------------------------------------------------------------------------------- /examples/data/player1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/player1.gif -------------------------------------------------------------------------------- /examples/data/static.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/static.png -------------------------------------------------------------------------------- /docs/reST/_static/pygame.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/_static/pygame.ico -------------------------------------------------------------------------------- /docs/reST/tut/camera_hsv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_hsv.jpg -------------------------------------------------------------------------------- /docs/reST/tut/camera_rgb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_rgb.jpg -------------------------------------------------------------------------------- /docs/reST/tut/camera_yuv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_yuv.jpg -------------------------------------------------------------------------------- /docs/reST/tut/chimpshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/chimpshot.gif -------------------------------------------------------------------------------- /docs/reST/tut/intro_ball.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/intro_ball.gif -------------------------------------------------------------------------------- /docs/reST/tut/surfarray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray.png -------------------------------------------------------------------------------- /docs/reST/tut/tom_basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/tom_basic.png -------------------------------------------------------------------------------- /docs/ref/docscomments.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/ref/docscomments.json -------------------------------------------------------------------------------- /examples/data/arraydemo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/arraydemo.bmp -------------------------------------------------------------------------------- /examples/data/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/background.gif -------------------------------------------------------------------------------- /examples/data/car_door.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/car_door.wav -------------------------------------------------------------------------------- /examples/data/explosion1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/explosion1.gif -------------------------------------------------------------------------------- /examples/data/house_lo.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/house_lo.mp3 -------------------------------------------------------------------------------- /examples/data/house_lo.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/house_lo.ogg -------------------------------------------------------------------------------- /examples/data/house_lo.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/house_lo.wav -------------------------------------------------------------------------------- /examples/data/midikeys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/midikeys.png -------------------------------------------------------------------------------- /examples/data/oldplayer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/oldplayer.gif -------------------------------------------------------------------------------- /docs/reST/tut/camera_green.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_green.jpg -------------------------------------------------------------------------------- /docs/reST/tut/camera_mask.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_mask.jpg -------------------------------------------------------------------------------- /docs/reST/tut/intro_blade.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/intro_blade.jpg -------------------------------------------------------------------------------- /docs/reST/tut/tom_formulae.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/tom_formulae.png -------------------------------------------------------------------------------- /docs/reST/tut/tom_radians.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/tom_radians.png -------------------------------------------------------------------------------- /examples/data/secosmic_lo.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/data/secosmic_lo.wav -------------------------------------------------------------------------------- /docs/reST/_static/pygame_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/_static/pygame_tiny.png -------------------------------------------------------------------------------- /docs/reST/tut/camera_average.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_average.jpg -------------------------------------------------------------------------------- /docs/reST/tut/camera_thresh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_thresh.jpg -------------------------------------------------------------------------------- /docs/reST/tut/intro_freedom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/intro_freedom.jpg -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_xfade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_xfade.png -------------------------------------------------------------------------------- /test/fixtures/fonts/test_sans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/test/fixtures/fonts/test_sans.ttf -------------------------------------------------------------------------------- /docs/reST/tut/camera_background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_background.jpg -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_flipped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_flipped.png -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_redimg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_redimg.png -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_scaleup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_scaleup.png -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_soften.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_soften.png -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_striped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_striped.png -------------------------------------------------------------------------------- /test/fixtures/fonts/PyGameMono.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/test/fixtures/fonts/PyGameMono.otf -------------------------------------------------------------------------------- /test/fixtures/fonts/test_fixed.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/test/fixtures/fonts/test_fixed.otf -------------------------------------------------------------------------------- /docs/reST/tut/camera_thresholded.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/camera_thresholded.jpg -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_allblack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_allblack.png -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_rgbarray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_rgbarray.png -------------------------------------------------------------------------------- /docs/reST/tut/surfarray_scaledown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/surfarray_scaledown.png -------------------------------------------------------------------------------- /docs/reST/tut/tom_event-flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/tut/tom_event-flowchart.png -------------------------------------------------------------------------------- /src_c/SDL_gfx/SDL_gfxPrimitives_font.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/src_c/SDL_gfx/SDL_gfxPrimitives_font.h -------------------------------------------------------------------------------- /test/fixtures/fonts/A_PyGameMono-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/test/fixtures/fonts/A_PyGameMono-8.png -------------------------------------------------------------------------------- /test/fixtures/fonts/u13079_PyGameMono-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/test/fixtures/fonts/u13079_PyGameMono-8.png -------------------------------------------------------------------------------- /docs/reST/ref/code_examples/joystick_calls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/ref/code_examples/joystick_calls.png -------------------------------------------------------------------------------- /docs/reST/ref/code_examples/draw_module_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/docs/reST/ref/code_examples/draw_module_example.png -------------------------------------------------------------------------------- /examples/macosx/aliens_app_example/English.lproj/aliens.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/macosx/aliens_app_example/English.lproj/aliens.icns -------------------------------------------------------------------------------- /test/image_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = [] 2 | 3 | import pygame 4 | import sys 5 | if 'pygame.image' not in sys.modules: 6 | __tags__.extend(('ignore', 'subprocess_ignore')) 7 | 8 | -------------------------------------------------------------------------------- /test/mixer_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = [] 2 | 3 | import pygame 4 | import sys 5 | if 'pygame.mixer' not in sys.modules: 6 | __tags__.extend(('ignore', 'subprocess_ignore')) 7 | 8 | -------------------------------------------------------------------------------- /src_c/mask.h: -------------------------------------------------------------------------------- 1 | #ifndef PGMASK_INTERNAL_H 2 | #define PGMASK_INTERNAL_H 3 | 4 | #include "include/pygame_mask.h" 5 | #define PYGAMEAPI_MASK_NUMSLOTS 1 6 | 7 | #endif /* ~PGMASK_INTERNAL_H */ 8 | -------------------------------------------------------------------------------- /test/imageext_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = [] 2 | 3 | import pygame 4 | import sys 5 | if 'pygame.imageext' not in sys.modules: 6 | __tags__.extend(('ignore', 'subprocess_ignore')) 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/mixer_music_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = [] 2 | 3 | import pygame 4 | import sys 5 | if 'pygame.mixer_music' not in sys.modules: 6 | __tags__.extend(('ignore', 'subprocess_ignore')) 7 | 8 | -------------------------------------------------------------------------------- /docs/reST/tut/common.txt: -------------------------------------------------------------------------------- 1 | .. Common definitions for tutorials 2 | 3 | .. include:: ../common.txt 4 | 5 | .. role:: codelineref 6 | 7 | .. role:: clr(codelineref) 8 | :class: codelineref 9 | -------------------------------------------------------------------------------- /test/camera_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import math 3 | 4 | import pygame 5 | from pygame.compat import long_ 6 | 7 | 8 | class CameraModuleTest(unittest.TestCase): 9 | pass 10 | -------------------------------------------------------------------------------- /examples/macosx/aliens_app_example/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/pygame/master/examples/macosx/aliens_app_example/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /src_c/doc/README.rst: -------------------------------------------------------------------------------- 1 | These files are generated from the rst files in docs/reST/ref/ 2 | 3 | Both the .rst file and the generated .h file should be committed. 4 | 5 | To generate docs run: python setup.py docs 6 | -------------------------------------------------------------------------------- /src_c/pgbufferproxy.h: -------------------------------------------------------------------------------- 1 | #ifndef PG_BUFPROXY_INTERNAL_H 2 | #define PG_BUFPROXY_INTERNAL_H 3 | 4 | #include "include/pygame_bufferproxy.h" 5 | #define PYGAMEAPI_BUFPROXY_NUMSLOTS 4 6 | 7 | #endif /* ~PG_BUFPROXY_INTERNAL_H */ 8 | -------------------------------------------------------------------------------- /docs/reST/tut/chimp.py.rst: -------------------------------------------------------------------------------- 1 | .. include:: common.txt 2 | 3 | **************************** 4 | pygame/examples/chimp.py 5 | **************************** 6 | 7 | .. literalinclude:: ../../../examples/chimp.py 8 | :language: python 9 | -------------------------------------------------------------------------------- /docs/reST/themes/classic/page.html: -------------------------------------------------------------------------------- 1 | {%- extends "elements.html" %} 2 | 3 | {%- block document %} 4 | {{ header() }} 5 | {{ super() }} 6 | {%- endblock %} 7 | 8 | {%- block section %} 9 | {{ body }} 10 | {%- endblock %} 11 | -------------------------------------------------------------------------------- /test/ftfont_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['development'] 2 | 3 | exclude = False 4 | 5 | try: 6 | import pygame.ftfont 7 | except ImportError: 8 | exclude = True 9 | 10 | if exclude: 11 | __tags__.extend(['ignore', 'subprocess_ignore']) 12 | 13 | -------------------------------------------------------------------------------- /test/freetype_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['development'] 2 | 3 | exclude = False 4 | 5 | try: 6 | import pygame.freetype 7 | except ImportError: 8 | exclude = True 9 | 10 | if exclude: 11 | __tags__.extend(['ignore', 'subprocess_ignore']) 12 | 13 | -------------------------------------------------------------------------------- /test/sndarray_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['array'] 2 | 3 | exclude = False 4 | 5 | try: 6 | import pygame.mixer 7 | import numpy 8 | except ImportError: 9 | exclude = True 10 | 11 | if exclude: 12 | __tags__.extend(('ignore', 'subprocess_ignore')) 13 | -------------------------------------------------------------------------------- /src_c/doc/locals_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMELOCALS "pygame constants" 3 | 4 | 5 | /* Docs in a comment... slightly easier to read. */ 6 | 7 | /* 8 | 9 | pygame.locals 10 | pygame constants 11 | 12 | */ -------------------------------------------------------------------------------- /docs/reST/common.txt: -------------------------------------------------------------------------------- 1 | .. Pygame specific reST elements. 2 | 3 | .. role:: summaryline 4 | 5 | .. role:: sl(summaryline) 6 | :class: summaryline 7 | 8 | .. role:: signature 9 | 10 | .. role:: sg(signature) 11 | :class: signature 12 | 13 | .. role:: small-heading 14 | :class: small-heading 15 | -------------------------------------------------------------------------------- /docs/reST/c_api.rst: -------------------------------------------------------------------------------- 1 | ********* 2 | C API 3 | ********* 4 | 5 | pygame C API 6 | ============ 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | :glob: 11 | 12 | c_api/* 13 | 14 | src_c/include/ contains header files for applications 15 | that use the pygame C API, while src_c/ contains 16 | headers used by pygame internally. 17 | -------------------------------------------------------------------------------- /test/surfarray_tags.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['array'] 2 | 3 | exclude = False 4 | 5 | try: 6 | import numpy 7 | except ImportError: 8 | exclude = True 9 | else: 10 | try: 11 | import pygame.pixelcopy 12 | except ImportError: 13 | exclude = True 14 | 15 | if exclude: 16 | __tags__.extend(('ignore', 'subprocess_ignore')) 17 | -------------------------------------------------------------------------------- /docs/__init__.py: -------------------------------------------------------------------------------- 1 | # Make docs a package that brings up the main page in a web brower when 2 | # executed. 3 | # 4 | # python -m pygame.docs 5 | 6 | if __name__ == '__main__': 7 | import os 8 | pkg_dir = os.path.dirname(os.path.abspath(__file__)) 9 | main = os.path.join(pkg_dir, '__main__.py') 10 | exec(open(main).read()) 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/util/gen_stubs_test.py: -------------------------------------------------------------------------------- 1 | ######################### PYGAME UNITTEST STUBBER TESTS ######################## 2 | """ 3 | 4 | TODO 5 | ==== 6 | 7 | tests for new stubber: deleted tests for missing units 8 | 9 | """ 10 | 11 | import pygame, unittest, gen_stubs 12 | 13 | 14 | ################################################################################ -------------------------------------------------------------------------------- /examples/macosx/aliens_app_example/English.lproj/MainMenu.nib/JavaCompiling.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JavaSourceSubpath 6 | _MainMenu_EOArchive_English.java 7 | 8 | 9 | -------------------------------------------------------------------------------- /src_c/font.h: -------------------------------------------------------------------------------- 1 | #ifndef PGFONT_INTERNAL_H 2 | #define PGFONT_INTERNAL_H 3 | 4 | #include 5 | 6 | /* test font initialization */ 7 | #define FONT_INIT_CHECK() \ 8 | if(!(*(int*)PyFONT_C_API[2])) \ 9 | return RAISE(pgExc_SDLError, "font system not initialized") 10 | 11 | #include "include/pygame_font.h" 12 | 13 | #define PYGAMEAPI_FONT_NUMSLOTS 3 14 | 15 | #endif /* ~PGFONT_INTERNAL_H */ 16 | -------------------------------------------------------------------------------- /src_c/mixer.h: -------------------------------------------------------------------------------- 1 | #ifndef MIXER_INTERNAL_H 2 | #define MIXER_INTERNAL_H 3 | 4 | #include 5 | 6 | /* test mixer initializations */ 7 | #define MIXER_INIT_CHECK() \ 8 | if(!SDL_WasInit(SDL_INIT_AUDIO)) \ 9 | return RAISE(pgExc_SDLError, "mixer not initialized") 10 | 11 | #define PYGAMEAPI_MIXER_NUMSLOTS 7 12 | #include "include/pygame_mixer.h" 13 | 14 | #endif /* ~MIXER_INTERNAL_H */ 15 | -------------------------------------------------------------------------------- /examples/macosx/aliens_app_example/English.lproj/MainMenu.nib/classes.nib: -------------------------------------------------------------------------------- 1 | { 2 | IBClasses = ( 3 | {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 4 | { 5 | ACTIONS = {}; 6 | CLASS = PygameAppDelegate; 7 | LANGUAGE = ObjC; 8 | OUTLETS = {}; 9 | SUPERCLASS = NSObject; 10 | } 11 | ); 12 | IBVersion = 1; 13 | } -------------------------------------------------------------------------------- /test/fixtures/xbm_cursors/white_sizing.xbm: -------------------------------------------------------------------------------- 1 | #define resize_white_width 16 2 | #define resize_white_height 16 3 | #define resize_white_x_hot 7 4 | #define resize_white_y_hot 7 5 | static unsigned char resize_white_bits[] = { 6 | 0xff, 0x03, 0x01, 0x02, 0xfd, 0x03, 0x05, 0x00, 0xf5, 0x0f, 0x15, 0x08, 7 | 0xd5, 0xeb, 0x55, 0xaa, 0x55, 0xaa, 0xd7, 0xab, 0x10, 0xa8, 0xf0, 0xb7, 8 | 0x00, 0xa8, 0xc0, 0x9f, 0x40, 0x80, 0xc0, 0xff}; 9 | -------------------------------------------------------------------------------- /src_c/pgimport.h: -------------------------------------------------------------------------------- 1 | #ifndef PGIMPORT_INTERNAL_H 2 | #define PGIMPORT_INTERNAL_H 3 | 4 | #include "include/pgimport.h" 5 | 6 | #if PG_HAVE_CAPSULE 7 | #define encapsulate_api(ptr, module) \ 8 | PyCapsule_New(ptr, PG_CAPSULE_NAME(module), NULL) 9 | #else /* ~PG_HAVE_CAPSULE */ 10 | #define encapsulate_api(ptr, module) PyCObject_FromVoidPtr(ptr, NULL) 11 | #endif /* ~PG_HAVE_CAPSULE */ 12 | 13 | #endif /* PGIMPORT_INTERNAL_H */ 14 | -------------------------------------------------------------------------------- /test/fixtures/xbm_cursors/white_sizing_mask.xbm: -------------------------------------------------------------------------------- 1 | #define resize_white_mask_width 16 2 | #define resize_white_mask_height 16 3 | #define resize_white_mask_x_hot 7 4 | #define resize_white_mask_y_hot 7 5 | static unsigned char resize_white_mask_bits[] = { 6 | 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0x07, 0x00, 0xf7, 0x0f, 0xf7, 0x0f, 7 | 0xf7, 0xef, 0x77, 0xee, 0x77, 0xee, 0xf7, 0xef, 0xf0, 0xef, 0xf0, 0xff, 8 | 0x00, 0xf8, 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff}; 9 | -------------------------------------------------------------------------------- /src_c/doc/tests_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMETESTS "Pygame unit test suite package" 3 | #define DOC_PYGAMETESTSRUN "run(*args, **kwds) -> tuple\nRun the pygame unit test suite" 4 | 5 | 6 | /* Docs in a comment... slightly easier to read. */ 7 | 8 | /* 9 | 10 | pygame.tests 11 | Pygame unit test suite package 12 | 13 | pygame.tests.run 14 | run(*args, **kwds) -> tuple 15 | Run the pygame unit test suite 16 | 17 | */ -------------------------------------------------------------------------------- /test/.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | # The settings for C (*.c and *.h) files are mirrored in src_c/.clang-format. 8 | # Keep them in sync. 9 | [*.{c,h}] 10 | indent_style = space 11 | indent_size = 4 12 | tab_width = 4 13 | trim_trailing_whitespace = true 14 | max_line_length = 79 15 | 16 | [*.{py,pyx}] 17 | indent_style = space 18 | indent_size = 4 19 | charset = utf-8 20 | file_type_emacs = python 21 | trim_trailing_whitespace = true 22 | max_line_length = 79 23 | -------------------------------------------------------------------------------- /examples/.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | # The settings for C (*.c and *.h) files are mirrored in src_c/.clang-format. 8 | # Keep them in sync. 9 | [*.{c,h}] 10 | indent_style = space 11 | indent_size = 4 12 | tab_width = 4 13 | trim_trailing_whitespace = true 14 | max_line_length = 79 15 | 16 | [*.{py,pyx}] 17 | indent_style = space 18 | indent_size = 4 19 | charset = utf-8 20 | file_type_emacs = python 21 | trim_trailing_whitespace = true 22 | max_line_length = 79 23 | -------------------------------------------------------------------------------- /src_c/.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | # The settings for C (*.c and *.h) files are mirrored in src_c/.clang-format. 8 | # Keep them in sync. 9 | [*.{c,h}] 10 | indent_style = space 11 | indent_size = 4 12 | tab_width = 4 13 | trim_trailing_whitespace = true 14 | max_line_length = 79 15 | 16 | [*.{py,pyx}] 17 | indent_style = space 18 | indent_size = 4 19 | charset = utf-8 20 | file_type_emacs = python 21 | trim_trailing_whitespace = true 22 | max_line_length = 79 23 | -------------------------------------------------------------------------------- /src_py/.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | # The settings for C (*.c and *.h) files are mirrored in src_c/.clang-format. 8 | # Keep them in sync. 9 | [*.{c,h}] 10 | indent_style = space 11 | indent_size = 4 12 | tab_width = 4 13 | trim_trailing_whitespace = true 14 | max_line_length = 79 15 | 16 | [*.{py,pyx}] 17 | indent_style = space 18 | indent_size = 4 19 | charset = utf-8 20 | file_type_emacs = python 21 | trim_trailing_whitespace = true 22 | max_line_length = 79 23 | -------------------------------------------------------------------------------- /test/scrap_tags.py: -------------------------------------------------------------------------------- 1 | # For now the scrap module has not been updated for SDL 2 2 | __tags__ = ['SDL2_ignore'] 3 | 4 | import sys 5 | 6 | exclude = False 7 | 8 | if sys.platform == 'win32' or sys.platform.startswith('linux'): 9 | try: 10 | import pygame 11 | pygame.scrap._NOT_IMPLEMENTED_ 12 | except AttributeError: 13 | pass 14 | else: 15 | exclude = True 16 | else: 17 | exclude = True 18 | 19 | if exclude: 20 | __tags__.extend(['ignore', 'subprocess_ignore']) 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/macosx/aliens_app_example/README.txt: -------------------------------------------------------------------------------- 1 | ********************************************************************* 2 | THESE INSTRUCTIONS ARE ONLY FOR MAC OS X 10.3, AND WILL ONLY CREATE 3 | STANDALONE BUNDLES FOR MAC OS X 10.3. THERE IS NO SUPPORT FOR 4 | MAC OS X 10.2. 5 | 6 | Also works on 10.4 and 10.5 7 | ********************************************************************* 8 | 9 | 10 | Install py2app and its dependencies. 11 | 12 | easy_install py2app 13 | 14 | 15 | 16 | To create the bundle: 17 | python setup.py py2app 18 | -------------------------------------------------------------------------------- /src_c/pgopengl.h: -------------------------------------------------------------------------------- 1 | #if !defined(PGOPENGL_H) 2 | #define PGOPENGL_H 3 | 4 | /** This header includes definitions of Opengl functions as pointer types for 5 | ** use with the SDL function SDL_GL_GetProcAddress. 6 | **/ 7 | 8 | #if defined(_WIN32) 9 | #define GL_APIENTRY __stdcall 10 | #else 11 | #define GL_APIENTRY 12 | #endif 13 | 14 | typedef void (GL_APIENTRY *GL_glReadPixels_Func)(int, int, int, int, unsigned int, unsigned int, void*); 15 | 16 | typedef void (GL_APIENTRY *GL_glViewport_Func)(int, int, unsigned int, unsigned int); 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /src_c/.clang-format: -------------------------------------------------------------------------------- 1 | # PEP 7 2 | BasedOnStyle: Google 3 | AllowShortLoopsOnASingleLine: false 4 | AllowShortIfStatementsOnASingleLine: false 5 | AlwaysBreakAfterReturnType: All 6 | AlignAfterOpenBracket: Align 7 | BreakBeforeBraces: Stroustrup 8 | ColumnLimit: 79 9 | DerivePointerAlignment: false 10 | # These settings are mirrored in .editorconfig. Keep them in sync. 11 | IndentWidth: 4 12 | Language: Cpp 13 | PointerAlignment: Right 14 | ReflowComments: true 15 | SpaceBeforeParens: ControlStatements 16 | SpacesInParentheses: false 17 | TabWidth: 4 18 | UseTab: Never 19 | -------------------------------------------------------------------------------- /test/test_utils/endian.py: -------------------------------------------------------------------------------- 1 | # Module pygame.tests.test_utils.endian 2 | # 3 | # Machine independent conversion to little-endian and big-endian Python 4 | # integer values. 5 | 6 | import struct 7 | 8 | def little_endian_uint32(i): 9 | """Return the 32 bit unsigned integer little-endian representation of i""" 10 | 11 | s = struct.pack('I', i) 18 | return struct.unpack('=I', s)[0] 19 | -------------------------------------------------------------------------------- /src_c/cython/pygame/_sdl2/mixer.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | # 3 | 4 | from sdl2 cimport * 5 | 6 | #https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC79 7 | 8 | ctypedef void (*mixcallback)(void *udata, Uint8 *stream, int len) nogil 9 | 10 | cdef extern from "SDL_mixer.h" nogil: 11 | ctypedef void (*mix_func)(void *udata, Uint8 *stream, int len) 12 | void Mix_SetPostMix(void (*mixcallback)(void *udata, Uint8 *stream, int len), void *arg) 13 | 14 | 15 | cdef class _PostMix: 16 | cdef mixcallback callback 17 | cdef void *userdata 18 | cdef object _callback 19 | -------------------------------------------------------------------------------- /test/ftfont_test.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import unittest 4 | from pygame.tests import font_test 5 | 6 | import pygame.ftfont 7 | 8 | font_test.pygame_font = pygame.ftfont 9 | # Disable UCS-4 specific tests as this "Font" type does accept UCS-4 codes. 10 | font_test.UCS_4 = False 11 | 12 | for name in dir(font_test): 13 | obj = getattr(font_test, name) 14 | if (isinstance(obj, type) and # conditional and 15 | issubclass(obj, unittest.TestCase)): 16 | new_name = 'Ft%s' % name 17 | globals()[new_name] = type(new_name, (obj, ), {}) 18 | 19 | if __name__ == '__main__': 20 | unittest.main() 21 | -------------------------------------------------------------------------------- /src_py/gp2x/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # this lets me know that the module has not been imported. 4 | # we store it so we don't reimport a module each time the isgp2x function is called. 5 | _is_gp2x = -1 6 | 7 | def isgp2x(): 8 | """ Returns True if we are running on a gp2x, else False 9 | """ 10 | 11 | if _is_gp2x == -1: 12 | #TODO: FIXME: HACK: need to find a good way to do this. 13 | # Use configure to put 'gp2x' in the version string? 14 | import sys 15 | 16 | if "arm" in sys.version: 17 | _is_gp2x = True 18 | else: 19 | _is_gp2x = False 20 | 21 | return _is_gp2x 22 | 23 | -------------------------------------------------------------------------------- /src_py/gp2x/constants.py: -------------------------------------------------------------------------------- 1 | 2 | # GP2X joystick button mappings 3 | BUTTON_UP = (0) 4 | BUTTON_DOWN = (4) 5 | BUTTON_LEFT = (2) 6 | BUTTON_RIGHT = (6) 7 | BUTTON_UPLEFT = (1) 8 | BUTTON_UPRIGHT = (7) 9 | BUTTON_DOWNLEFT = (3) 10 | BUTTON_DOWNRIGHT = (5) 11 | BUTTON_CLICK = (18) 12 | BUTTON_A = (12) 13 | BUTTON_B = (13) 14 | BUTTON_X = (14) 15 | BUTTON_Y = (15) 16 | BUTTON_L = (10) 17 | BUTTON_R = (11) 18 | BUTTON_START = (8) 19 | BUTTON_SELECT = (9) 20 | BUTTON_VOLUP = (16) 21 | BUTTON_VOLDOWN = (17) 22 | -------------------------------------------------------------------------------- /examples/macosx/aliens_app_example/English.lproj/MainMenu.nib/info.nib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IBDocumentLocation 6 | 269 494 356 240 0 0 1600 1002 7 | IBEditorPositions 8 | 9 | 29 10 | 125 344 278 44 0 0 1600 1002 11 | 12 | IBFramework Version 13 | 349.0 14 | IBOpenObjects 15 | 16 | 29 17 | 18 | IBSystem Version 19 | 7D24 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/macosx/aliens_app_example/setup.py: -------------------------------------------------------------------------------- 1 | """ 2 | Script for building the example. 3 | 4 | Usage: 5 | python setup.py py2app 6 | """ 7 | from distutils.core import setup 8 | import py2app 9 | 10 | NAME = 'aliens' 11 | VERSION = '0.1' 12 | 13 | plist = dict( 14 | CFBundleIconFile=NAME, 15 | CFBundleName=NAME, 16 | CFBundleShortVersionString=VERSION, 17 | CFBundleGetInfoString=' '.join([NAME, VERSION]), 18 | CFBundleExecutable=NAME, 19 | CFBundleIdentifier='org.pygame.examples.aliens', 20 | ) 21 | 22 | setup( 23 | data_files=['English.lproj', '../../data'], 24 | app=[ 25 | #dict(script="aliens_bootstrap.py", plist=plist), 26 | dict(script="aliens.py", plist=plist), 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Pygame build process: config.py setup.py 2 | /Setup 3 | *.pyc 4 | /build/ 5 | /src_py/version.py 6 | 7 | # Windows prebuilt external libraries 8 | /prebuilt-x?? 9 | 10 | # Sphinx generated files: makeref.py 11 | /docs/\.buildinfo 12 | /docs/objects.inv 13 | /docs/doctrees/ 14 | /docs/_sources/ 15 | /docs/_static/ 16 | /docs/_images/ 17 | /docs/genindex.html 18 | /docs/search.html 19 | /docs/searchindex.js 20 | /docs/tut/ 21 | /docs/filepaths.html 22 | /docs/index.html 23 | /docs/ref/*.html 24 | 25 | # Emacs temporary files 26 | *~ 27 | 28 | # VIM temporary files 29 | *.swp 30 | 31 | # Other 32 | envdev* 33 | .virtualenv* 34 | buildconfig/manylinux-build/wheelhouse/ 35 | anenv 36 | dist 37 | .vagrant 38 | *.egg-info/ 39 | *.so 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/all_ok/zero_tests_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | pass 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /docs/reST/c_api/version.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ****************************************** 6 | API exported by pygame.version 7 | ****************************************** 8 | 9 | src_py/version.py 10 | ================= 11 | 12 | Header file: src_c/include/pygame.h 13 | 14 | Version information can be retrieved at compile-time using these macros. 15 | 16 | .. versionadded:: 1.9.5 17 | 18 | .. c:macro:: PG_MAJOR_VERSION 19 | 20 | .. c:macro:: PG_MINOR_VERSION 21 | 22 | .. c:macro:: PG_PATCH_VERSION 23 | 24 | .. c:function:: PG_VERSIONNUM(MAJOR, MINOR, PATCH) 25 | 26 | Returns an integer representing the given version. 27 | 28 | .. c:function:: PG_VERSION_ATLEAST(MAJOR, MINOR, PATCH) 29 | 30 | Returns true if the current version is at least equal 31 | to the specified version. 32 | -------------------------------------------------------------------------------- /src_py/macosx.py: -------------------------------------------------------------------------------- 1 | import platform 2 | import os 3 | import sys 4 | from pygame.pkgdata import getResource 5 | from pygame import sdlmain_osx 6 | 7 | __all__ = ['Video_AutoInit'] 8 | 9 | def Video_AutoInit(): 10 | """Called from the base.c just before display module is initialized.""" 11 | if 'Darwin' in platform.platform(): 12 | if not sdlmain_osx.RunningFromBundleWithNSApplication(): 13 | try: 14 | default_icon_data = getResource('pygame_icon.tiff').read() 15 | except IOError: 16 | default_icon_data = None 17 | except NotImplementedError: 18 | default_icon_data = None 19 | sdlmain_osx.InstallNSApplication(default_icon_data) 20 | if (os.getcwd() == '/') and len(sys.argv) > 1: 21 | os.chdir(os.path.dirname(sys.argv[0])) 22 | return True 23 | -------------------------------------------------------------------------------- /docs/__main__.py: -------------------------------------------------------------------------------- 1 | # python -m pygame.docs 2 | 3 | import os 4 | import webbrowser 5 | try: 6 | from urllib.parse import urlunparse, quote 7 | except ImportError: 8 | from urlparse import urlunparse 9 | from urllib import quote 10 | 11 | def iterpath(path): 12 | path, last = os.path.split(path) 13 | if last: 14 | for p in iterpath(path): 15 | yield p 16 | yield last 17 | 18 | pkg_dir = os.path.dirname(os.path.abspath(__file__)) 19 | main_page = os.path.join(pkg_dir, 'index.html') 20 | if os.path.exists(main_page): 21 | url_path = quote('/'.join(iterpath(main_page))) 22 | drive, rest = os.path.splitdrive(__file__) 23 | if drive: 24 | url_path = "%s/%s" % (drive, url_path) 25 | url = urlunparse(('file', '', url_path, '', '', '')) 26 | else: 27 | url = "https://www.pygame.org/docs/" 28 | webbrowser.open(url) 29 | -------------------------------------------------------------------------------- /src_py/_dummybackend.py: -------------------------------------------------------------------------------- 1 | """dummy Movie class if all else fails """ 2 | class Movie: 3 | def __init__(self, filename, surface=None): 4 | self.filename=filename 5 | self.surface = surface 6 | self.process = None 7 | self.loops=0 8 | self.playing = False 9 | self.paused = False 10 | self._backend = "DUMMY" 11 | self.width=0 12 | self.height=0 13 | self.finished = 1 14 | def play(self, loops=0): 15 | self.playing= not self.playing 16 | 17 | def stop(self): 18 | self.playing=not self.playing 19 | self.paused =not self.paused 20 | 21 | def pause(self): 22 | self.paused=not self.paused 23 | 24 | def resize(self, w, h): 25 | self.width=w 26 | self.height=h 27 | 28 | def __repr__(self): 29 | return "(%s 0.0s)"%self.filename 30 | -------------------------------------------------------------------------------- /src_c/doc/cursors_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMECURSORS "pygame module for cursor resources" 3 | #define DOC_PYGAMECURSORSCOMPILE "compile(strings, black='X', white='.', xor='o') -> data, mask\ncreate binary cursor data from simple strings" 4 | #define DOC_PYGAMECURSORSLOADXBM "load_xbm(cursorfile) -> cursor_args\nload_xbm(cursorfile, maskfile) -> cursor_args\nload cursor data from an XBM file" 5 | 6 | 7 | /* Docs in a comment... slightly easier to read. */ 8 | 9 | /* 10 | 11 | pygame.cursors 12 | pygame module for cursor resources 13 | 14 | pygame.cursors.compile 15 | compile(strings, black='X', white='.', xor='o') -> data, mask 16 | create binary cursor data from simple strings 17 | 18 | pygame.cursors.load_xbm 19 | load_xbm(cursorfile) -> cursor_args 20 | load_xbm(cursorfile, maskfile) -> cursor_args 21 | load cursor data from an XBM file 22 | 23 | */ -------------------------------------------------------------------------------- /test/sysfont_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import platform 3 | 4 | class SysfontModuleTest(unittest.TestCase): 5 | def todo_test_create_aliases(self): 6 | self.fail() 7 | 8 | def todo_test_initsysfonts(self): 9 | self.fail() 10 | 11 | @unittest.skipIf('Darwin' not in platform.platform(), 'Not mac we skip.') 12 | def test_initsysfonts_darwin(self): 13 | import pygame.sysfont 14 | self.assertTrue(len(pygame.sysfont.get_fonts()) > 10) 15 | 16 | def test_sysfont(self): 17 | import pygame.font 18 | pygame.font.init() 19 | arial = pygame.font.SysFont('Arial', 40) 20 | 21 | def todo_test_initsysfonts_unix(self): 22 | self.fail() 23 | 24 | def todo_test_initsysfonts_win32(self): 25 | self.fail() 26 | 27 | ################################################################################ 28 | 29 | if __name__ == '__main__': 30 | unittest.main() 31 | -------------------------------------------------------------------------------- /test/run_tests__tests/everything/sleep_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | import time 19 | 20 | class KeyModuleTest(unittest.TestCase): 21 | def test_get_focused(self): 22 | stop_time = time.time() + 10.0 23 | while time.time() < stop_time: 24 | time.sleep(1) 25 | self.assertTrue(True) 26 | 27 | 28 | if __name__ == '__main__': 29 | unittest.main() 30 | -------------------------------------------------------------------------------- /src_c/_camera.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public 6 | License as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with this library; if not, write to the Free 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | #ifndef _CAMERA_H 21 | #define _CAMERA_H 22 | 23 | #include "_pygame.h" 24 | #include "camera.h" 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /test/run_tests__tests/timeout/sleep_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | import time 19 | 20 | class KeyModuleTest(unittest.TestCase): 21 | def test_get_focused(self): 22 | stop_time = time.time() + 10.0 23 | while time.time() < stop_time: 24 | time.sleep(1) 25 | 26 | self.assertTrue(True) 27 | 28 | 29 | if __name__ == '__main__': 30 | unittest.main() 31 | -------------------------------------------------------------------------------- /docs/reST/_static/tooltip.css: -------------------------------------------------------------------------------- 1 | /* Implement hyperlink tooltips 2 | * 3 | * Adapted from "Sexy Tooltips with Just CSS" 4 | * http://sixrevisions.com/css/css-only-tooltips/ 5 | */ 6 | 7 | .tooltip { 8 | cursor: help; text-decoration: none; 9 | position: relative; 10 | } 11 | 12 | .tooltip span.tooltip-content { 13 | margin-left: -999em; 14 | position: absolute; 15 | } 16 | 17 | .tooltip:hover span.tooltip-content { 18 | position: absolute; 19 | left: 1em; 20 | top: 2em; 21 | z-index: 99; 22 | margin-left: 0; 23 | } 24 | 25 | .tooltip:hover img { 26 | border: 0; 27 | margin: -10px 0 0 -55px; 28 | float: left; 29 | position: absolute; 30 | } 31 | 32 | .tooltip:hover em { 33 | font-family: Candara, Tahoma, Geneva, sans-serif; 34 | font-size: 1.2em; 35 | font-weight: bold; 36 | display: block; 37 | padding: 0.2em 0 0.6em 0; 38 | } 39 | 40 | .classic { padding: 0.8em 1em; } 41 | 42 | .custom { padding: 0.5em 0.8em 0.8em 2em; } 43 | 44 | * html a:hover { background: transparent; } 45 | -------------------------------------------------------------------------------- /src_c/doc/overlay_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMEOVERLAY "Overlay(format, (width, height)) -> Overlay\npygame object for video overlay graphics" 3 | #define DOC_OVERLAYDISPLAY "display((y, u, v)) -> None\ndisplay() -> None\nset the overlay pixel data" 4 | #define DOC_OVERLAYSETLOCATION "set_location(rect) -> None\ncontrol where the overlay is displayed" 5 | #define DOC_OVERLAYGETHARDWARE "get_hardware(rect) -> int\ntest if the Overlay is hardware accelerated" 6 | 7 | 8 | /* Docs in a comment... slightly easier to read. */ 9 | 10 | /* 11 | 12 | pygame.Overlay 13 | Overlay(format, (width, height)) -> Overlay 14 | pygame object for video overlay graphics 15 | 16 | pygame.Overlay.display 17 | display((y, u, v)) -> None 18 | display() -> None 19 | set the overlay pixel data 20 | 21 | pygame.Overlay.set_location 22 | set_location(rect) -> None 23 | control where the overlay is displayed 24 | 25 | pygame.Overlay.get_hardware 26 | get_hardware(rect) -> int 27 | test if the Overlay is hardware accelerated 28 | 29 | */ -------------------------------------------------------------------------------- /src_c/_surface.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2000-2001 Pete Shinners 4 | Copyright (C) 2007 Marcus von Appen 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Library General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Library General Public License for more details. 15 | 16 | You should have received a copy of the GNU Library General Public 17 | License along with this library; if not, write to the Free 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | 20 | Pete Shinners 21 | pete@shinners.org 22 | */ 23 | 24 | #ifndef _SURFACE_H 25 | #define _SURFACE_H 26 | 27 | #include "_pygame.h" 28 | #include "surface.h" 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /test/run_tests__tests/all_ok/no_assertions__ret_code_of_1__test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | pass 21 | 22 | def test_get_mods(self): 23 | pass 24 | 25 | def test_get_pressed(self): 26 | pass 27 | 28 | def test_name(self): 29 | pass 30 | 31 | def test_set_mods(self): 32 | pass 33 | 34 | def test_set_repeat(self): 35 | pass 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /docs/reST/filepaths.rst: -------------------------------------------------------------------------------- 1 | File Path Function Arguments 2 | ============================ 3 | 4 | File Path Function Arguments 5 | ---------------------------- 6 | 7 | A pygame function or method which takes a file path argument 8 | will accept either a Unicode or a byte — 8-bit or ASCII character — string. 9 | Unicode strings are translated to Python's default filesystem encoding, 10 | as returned by sys.getfilesystemencoding(). 11 | A Unicode code point above U+FFFF — '\uFFFF' — can 12 | be coded directly with a 32-bit escape 13 | sequences — '\Uxxxxxxxx' — , 14 | even for Python interpreters built with an UCS-2 (16-bit character) Unicode type. 15 | Byte strings are passed to the operating system unchanged. 16 | 17 | Null characters — '\x00' —  18 | are not permitted in the path, raising an exception. 19 | An exception is also raised if an Unicode file path cannot be encoded. 20 | How UTF-16 surrogate codes are handled is Python-interpreter-dependent. 21 | Use UTF-32 code points and 32-bit escape sequences instead. 22 | The exception types are function-dependent. 23 | -------------------------------------------------------------------------------- /test/overlay_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | 4 | class OverlayTypeTest(unittest.TestCase): 5 | def todo_test_display(self): 6 | 7 | # __doc__ (as of 2008-08-02) for pygame.overlay.overlay.display: 8 | 9 | # Overlay.display((y, u, v)): return None 10 | # Overlay.display(): return None 11 | # set the overlay pixel data 12 | 13 | self.fail() 14 | 15 | def todo_test_get_hardware(self): 16 | 17 | # __doc__ (as of 2008-08-02) for pygame.overlay.overlay.get_hardware: 18 | 19 | # Overlay.get_hardware(rect): return int 20 | # test if the Overlay is hardware accelerated 21 | 22 | self.fail() 23 | 24 | def todo_test_set_location(self): 25 | 26 | # __doc__ (as of 2008-08-02) for pygame.overlay.overlay.set_location: 27 | 28 | # Overlay.set_location(rect): return None 29 | # control where the overlay is displayed 30 | 31 | self.fail() 32 | 33 | ################################################################################ 34 | 35 | if __name__ == '__main__': 36 | unittest.main() 37 | -------------------------------------------------------------------------------- /src_c/pgplatform.h: -------------------------------------------------------------------------------- 1 | /* platform/compiler adjustments (internal) */ 2 | #ifndef PG_PLATFORM_INTERNAL_H 3 | #define PG_PLATFORM_INTERNAL_H 4 | 5 | /* This must be before all else */ 6 | #if defined(__SYMBIAN32__) && defined(OPENC) 7 | #include 8 | #if defined(__WINS__) 9 | void * 10 | _alloca(size_t size); 11 | #define alloca _alloca 12 | #endif /* __WINS__ */ 13 | #endif /* defined(__SYMBIAN32__) && defined(OPENC) */ 14 | 15 | #include "include/pgplatform.h" 16 | 17 | #ifndef MIN 18 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 19 | #endif 20 | #ifndef MAX 21 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 22 | #endif 23 | #ifndef ABS 24 | #define ABS(a) (((a) < 0) ? -(a) : (a)) 25 | #endif 26 | 27 | #if defined(macintosh) && defined(__MWERKS__) || defined(__SYMBIAN32__) 28 | #define PYGAME_EXPORT __declspec(export) 29 | #else 30 | #define PYGAME_EXPORT 31 | #endif 32 | 33 | /* warnings */ 34 | #define PG_STRINGIZE_HELPER(x) #x 35 | #define PG_STRINGIZE(x) PG_STRINGIZE_HELPER(x) 36 | #define PG_WARN(desc) message(__FILE__ "(" PG_STRINGIZE(__LINE__) "): WARNING: " #desc) 37 | 38 | #endif /* ~PG_PLATFORM_INTERNAL_H */ 39 | -------------------------------------------------------------------------------- /test/run_tests__tests/exclude/magic_tag_test.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['magic'] 2 | 3 | if __name__ == '__main__': 4 | import sys 5 | import os 6 | pkg_dir = (os.path.split( 7 | os.path.split( 8 | os.path.split( 9 | os.path.abspath(__file__))[0])[0])[0]) 10 | parent_dir, pkg_name = os.path.split(pkg_dir) 11 | is_pygame_pkg = (pkg_name == 'tests' and 12 | os.path.split(parent_dir)[1] == 'pygame') 13 | if not is_pygame_pkg: 14 | sys.path.insert(0, parent_dir) 15 | else: 16 | is_pygame_pkg = __name__.startswith('pygame.tests.') 17 | 18 | import unittest 19 | 20 | class KeyModuleTest(unittest.TestCase): 21 | def test_get_focused(self): 22 | self.assertTrue(True) 23 | 24 | def test_get_mods(self): 25 | self.assertTrue(True) 26 | 27 | def test_get_pressed(self): 28 | self.assertTrue(True) 29 | 30 | def test_name(self): 31 | self.assertTrue(True) 32 | 33 | def test_set_mods(self): 34 | self.assertTrue(True) 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /docs/reST/ref/locals.rst: -------------------------------------------------------------------------------- 1 | .. include:: common.txt 2 | 3 | :mod:`pygame.locals` 4 | ==================== 5 | 6 | .. module:: pygame.locals 7 | :synopsis: pygame constants 8 | 9 | | :sl:`pygame constants` 10 | 11 | This module contains various constants used by pygame. Its contents are 12 | automatically placed in the pygame module namespace. However, an application 13 | can use ``pygame.locals`` to include only the pygame constants with a ``from 14 | pygame.locals import *``. 15 | 16 | Detailed descriptions of the various constants can be found throughout the 17 | pygame documentation. Here are the locations of some of them. 18 | 19 | - The :mod:`pygame.display` module contains flags like ``HWSURFACE`` used by 20 | :func:`pygame.display.set_mode`. 21 | - The :mod:`pygame.event` module contains the various event types. 22 | - The :mod:`pygame.key` module lists the keyboard constants and modifiers 23 | (``K_``\* and ``MOD_``\*) relating to the ``key`` and ``mod`` attributes of 24 | the ``KEYDOWN`` and ``KEYUP`` events. 25 | - The :mod:`pygame.time` module defines ``TIMER_RESOLUTION``. 26 | 27 | .. ## pygame.locals ## 28 | -------------------------------------------------------------------------------- /test/run_tests__tests/everything/magic_tag_test.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['magic'] 2 | 3 | if __name__ == '__main__': 4 | import sys 5 | import os 6 | pkg_dir = (os.path.split( 7 | os.path.split( 8 | os.path.split( 9 | os.path.abspath(__file__))[0])[0])[0]) 10 | parent_dir, pkg_name = os.path.split(pkg_dir) 11 | is_pygame_pkg = (pkg_name == 'tests' and 12 | os.path.split(parent_dir)[1] == 'pygame') 13 | if not is_pygame_pkg: 14 | sys.path.insert(0, parent_dir) 15 | else: 16 | is_pygame_pkg = __name__.startswith('pygame.tests.') 17 | 18 | import unittest 19 | 20 | class KeyModuleTest(unittest.TestCase): 21 | def test_get_focused(self): 22 | self.assertTrue(True) 23 | 24 | def test_get_mods(self): 25 | self.assertTrue(True) 26 | 27 | def test_get_pressed(self): 28 | self.assertTrue(True) 29 | 30 | def test_name(self): 31 | self.assertTrue(True) 32 | 33 | def test_set_mods(self): 34 | self.assertTrue(True) 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /src_c/pgarrinter.h: -------------------------------------------------------------------------------- 1 | /* array structure interface version 3 declarations */ 2 | 3 | #if !defined(PG_ARRAYINTER_HEADER) 4 | #define PG_ARRAYINTER_HEADER 5 | 6 | static const int PAI_CONTIGUOUS = 0x01; 7 | static const int PAI_FORTRAN = 0x02; 8 | static const int PAI_ALIGNED = 0x100; 9 | static const int PAI_NOTSWAPPED = 0x200; 10 | static const int PAI_WRITEABLE = 0x400; 11 | static const int PAI_ARR_HAS_DESCR = 0x800; 12 | 13 | typedef struct { 14 | int two; /* contains the integer 2 -- simple sanity check */ 15 | int nd; /* number of dimensions */ 16 | char typekind; /* kind in array -- character code of typestr */ 17 | int itemsize; /* size of each element */ 18 | int flags; /* flags indicating how the data should be */ 19 | /* interpreted */ 20 | Py_intptr_t *shape; /* A length-nd array of shape information */ 21 | Py_intptr_t *strides; /* A length-nd array of stride information */ 22 | void *data; /* A pointer to the first element of the array */ 23 | PyObject *descr; /* NULL or a data-description */ 24 | } PyArrayInterface; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /test/run_tests__tests/incomplete/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def todo_test_get_pressed(self): 26 | self.fail() 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def todo_test_set_mods(self): 32 | self.fail() 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/all_ok/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/all_ok/fake_3_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/all_ok/fake_4_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/all_ok/fake_5_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/all_ok/fake_6_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/everything/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/exclude/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/failures1/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/failures1/fake_3_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/incomplete/fake_3_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/timeout/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/incomplete_todo/fake_3_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/infinite_loop/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/print_stderr/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/print_stdout/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/incomplete_todo/fake_2_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def todo_test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def todo_test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/run_tests__tests/infinite_loop/fake_1_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | while True: 24 | pass 25 | 26 | def test_get_pressed(self): 27 | self.assertTrue(True) 28 | 29 | def test_name(self): 30 | self.assertTrue(True) 31 | 32 | def test_set_mods(self): 33 | self.assertTrue(True) 34 | 35 | def test_set_repeat(self): 36 | self.assertTrue(True) 37 | 38 | 39 | if __name__ == '__main__': 40 | unittest.main() 41 | -------------------------------------------------------------------------------- /test/run_tests__tests/everything/incomplete_todo_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def todo_test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def todo_test_set_mods(self): 32 | self.assertTrue(True) 33 | 34 | def test_set_repeat(self): 35 | self.assertTrue(True) 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /docs/reST/ext/customversion.py: -------------------------------------------------------------------------------- 1 | from sphinx.domains.changeset import versionlabels, VersionChange 2 | from sphinx.locale import _ # just to suppress warnings 3 | 4 | try: 5 | from sphinx.domains.changeset import versionlabel_classes 6 | except ImportError: 7 | # versionlabel_classes doesn't exist in old Sphinx versions. 8 | UPDATE_VERIONLABEL_CLASSES = False 9 | else: 10 | UPDATE_VERIONLABEL_CLASSES = True 11 | 12 | 13 | labels = ('versionadded', 'versionchanged', 'deprecated', 'versionextended') 14 | 15 | 16 | def set_version_formats(app, config): 17 | for label in labels: 18 | versionlabels[label] = \ 19 | _(getattr(config, '{}_format'.format(label))) 20 | 21 | 22 | def setup(app): 23 | app.add_directive('versionextended', VersionChange) 24 | versionlabels['versionextended'] = 'Extended in pygame %s' 25 | 26 | if UPDATE_VERIONLABEL_CLASSES: 27 | versionlabel_classes['versionextended'] = 'extended' 28 | 29 | for label in ('versionadded', 'versionchanged', 'deprecated', 'versionextended'): 30 | app.add_config_value('{}_format'.format(label), str(versionlabels[label]), 'env') 31 | 32 | app.connect('config-inited', set_version_formats) 33 | -------------------------------------------------------------------------------- /src_c/pygame.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2000-2001 Pete Shinners 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Pete Shinners 20 | pete@shinners.org 21 | */ 22 | 23 | /* This will use PYGAMEAPI_DEFINE_SLOTS instead 24 | * of PYGAMEAPI_EXTERN_SLOTS for base modules. 25 | */ 26 | #ifndef PYGAME_INTERNAL_H 27 | #define PYGAME_INTERNAL_H 28 | 29 | #define PYGAME_H 30 | #include "_pygame.h" 31 | 32 | #endif /* ~PYGAME_INTERNAL_H */ 33 | -------------------------------------------------------------------------------- /src_c/pgcompat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if defined(SDL_VERSION_ATLEAST) 4 | #if !(SDL_VERSION_ATLEAST(2, 0, 5)) 5 | /* These functions require SDL 2.0.5 or greater. 6 | 7 | https://wiki.libsdl.org/SDL_SetWindowResizable 8 | */ 9 | void 10 | SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable) 11 | { 12 | } 13 | int 14 | SDL_GetWindowOpacity(SDL_Window *window, float *opacity) 15 | { 16 | SDL_SetError("SDL 2.0.5 or greater required"); 17 | return -1; 18 | } 19 | int 20 | SDL_SetWindowOpacity(SDL_Window *window, float opacity) 21 | { 22 | SDL_SetError("SDL 2.0.5 or greater required"); 23 | return -1; 24 | } 25 | 26 | int 27 | SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window) 28 | { 29 | SDL_SetError("SDL 2.0.5 or greater required"); 30 | return -1; 31 | } 32 | int 33 | SDL_SetWindowInputFocus(SDL_Window *window) 34 | { 35 | SDL_SetError("SDL 2.0.5 or greater required"); 36 | return -1; 37 | } 38 | SDL_Surface * 39 | SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, 40 | Uint32 format) 41 | { 42 | SDL_SetError("SDL 2.0.5 or greater required"); 43 | return NULL; 44 | } 45 | 46 | #endif 47 | #endif -------------------------------------------------------------------------------- /test/run_tests__tests/exclude/invisible_tag_test.py: -------------------------------------------------------------------------------- 1 | __tags__ = ['invisible'] 2 | 3 | if __name__ == '__main__': 4 | import sys 5 | import os 6 | pkg_dir = (os.path.split( 7 | os.path.split( 8 | os.path.split( 9 | os.path.abspath(__file__))[0])[0])[0]) 10 | parent_dir, pkg_name = os.path.split(pkg_dir) 11 | is_pygame_pkg = (pkg_name == 'tests' and 12 | os.path.split(parent_dir)[1] == 'pygame') 13 | if not is_pygame_pkg: 14 | sys.path.insert(0, parent_dir) 15 | else: 16 | is_pygame_pkg = __name__.startswith('pygame.tests.') 17 | 18 | import unittest 19 | 20 | class KeyModuleTest(unittest.TestCase): 21 | def test_get_focused(self): 22 | self.assertTrue(True) 23 | 24 | def test_get_mods(self): 25 | self.assertTrue(True) 26 | 27 | def test_get_pressed(self): 28 | self.assertTrue(True) 29 | 30 | def test_name(self): 31 | self.assertTrue(True) 32 | 33 | def test_set_mods(self): 34 | self.assertTrue(True) 35 | 36 | def test_set_repeat(self): 37 | self.assertTrue(True) 38 | 39 | 40 | if __name__ == '__main__': 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /src_py/locals.py: -------------------------------------------------------------------------------- 1 | ## pygame - Python Game Library 2 | ## Copyright (C) 2000-2003 Pete Shinners 3 | ## 4 | ## This library is free software; you can redistribute it and/or 5 | ## modify it under the terms of the GNU Library General Public 6 | ## License as published by the Free Software Foundation; either 7 | ## version 2 of the License, or (at your option) any later version. 8 | ## 9 | ## This library is distributed in the hope that it will be useful, 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ## Library General Public License for more details. 13 | ## 14 | ## You should have received a copy of the GNU Library General Public 15 | ## License along with this library; if not, write to the Free 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ## 18 | ## Pete Shinners 19 | ## pete@shinners.org 20 | 21 | 22 | 23 | """Set of functions from PyGame that are handy to have in 24 | the local namespace for your module""" 25 | 26 | from pygame.constants import * 27 | from pygame.rect import Rect 28 | import pygame.color as color 29 | Color = color.Color 30 | 31 | -------------------------------------------------------------------------------- /test/run_tests__tests/failures1/fake_4_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(False, "Some Jibberish") 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | if 1: 33 | if 1: 34 | assert False 35 | 36 | def test_set_repeat(self): 37 | self.assertTrue(True) 38 | 39 | 40 | if __name__ == '__main__': 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /examples/aacircle.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Proof of concept gfxdraw example""" 4 | 5 | import pygame 6 | import pygame.gfxdraw 7 | 8 | 9 | def main(): 10 | pygame.init() 11 | screen = pygame.display.set_mode((500, 500)) 12 | screen.fill((255, 0, 0)) 13 | s = pygame.Surface(screen.get_size(), pygame.SRCALPHA, 32) 14 | pygame.draw.line(s, (0, 0, 0), (250, 250), (250 + 200, 250)) 15 | 16 | width = 1 17 | for a_radius in range(width): 18 | radius = 200 19 | pygame.gfxdraw.aacircle(s, 250, 250, radius - a_radius, (0, 0, 0)) 20 | 21 | screen.blit(s, (0, 0)) 22 | 23 | pygame.draw.circle(screen, pygame.Color("GREEN"), (50, 100), 10) 24 | pygame.draw.circle(screen, pygame.Color("BLACK"), (50, 100), 10, 1) 25 | 26 | pygame.display.flip() 27 | try: 28 | while 1: 29 | event = pygame.event.wait() 30 | if event.type == pygame.QUIT: 31 | break 32 | if event.type == pygame.KEYDOWN: 33 | if event.key == pygame.K_ESCAPE or event.unicode == "q": 34 | break 35 | pygame.display.flip() 36 | finally: 37 | pygame.quit() 38 | 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /test/run_tests__tests/print_stderr/fake_3_test.py: -------------------------------------------------------------------------------- 1 | import sys 2 | if __name__ == '__main__': 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(True) 27 | 28 | def test_name(self): 29 | sys.stderr.write("jibberish messes things up\n") 30 | self.assertTrue(False) 31 | 32 | def test_set_mods(self): 33 | self.assertTrue(True) 34 | 35 | def test_set_repeat(self): 36 | self.assertTrue(True) 37 | 38 | 39 | if __name__ == '__main__': 40 | unittest.main() 41 | -------------------------------------------------------------------------------- /test/run_tests__tests/print_stderr/fake_4_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(False, "Some Jibberish") 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | if 1: 33 | if 1: 34 | assert False 35 | 36 | def test_set_repeat(self): 37 | self.assertTrue(True) 38 | 39 | 40 | if __name__ == '__main__': 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/run_tests__tests/print_stdout/fake_4_test.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | import sys 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | self.assertTrue(False, "Some Jibberish") 27 | 28 | def test_name(self): 29 | self.assertTrue(True) 30 | 31 | def test_set_mods(self): 32 | if 1: 33 | if 1: 34 | assert False 35 | 36 | def test_set_repeat(self): 37 | self.assertTrue(True) 38 | 39 | 40 | if __name__ == '__main__': 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /examples/setmodescale.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | from pygame.locals import * 3 | 4 | pygame.init() 5 | 6 | RES = (160, 120) 7 | FPS = 30 8 | clock = pygame.time.Clock() 9 | 10 | screen = pygame.display.set_mode(RES, SCALED | RESIZABLE) 11 | 12 | # MAIN LOOP 13 | 14 | done = False 15 | 16 | i = 0 17 | j = 0 18 | 19 | while not done: 20 | for event in pygame.event.get(): 21 | if event.type == KEYDOWN and event.key == K_q: 22 | done = True 23 | if event.type == QUIT: 24 | done = True 25 | if event.type == KEYDOWN and event.key == K_f: 26 | pygame.display.toggle_fullscreen() 27 | if event.type == VIDEORESIZE: 28 | pygame.display.resize_event(event) 29 | 30 | i += 1 31 | i = i % screen.get_width() 32 | j += i % 2 33 | j = j % screen.get_height() 34 | 35 | screen.fill((255, 0, 255)) 36 | pygame.draw.circle(screen, (0, 0, 0), (100, 100), 20) 37 | pygame.draw.circle(screen, (0, 0, 200), (0, 0), 10) 38 | pygame.draw.circle(screen, (200, 0, 0), (160, 120), 30) 39 | pygame.draw.line(screen, (250, 250, 0), (0, 120), (160, 0)) 40 | pygame.draw.circle(screen, (255, 255, 255), (i, j), 5) 41 | 42 | pygame.display.flip() 43 | clock.tick(FPS) 44 | -------------------------------------------------------------------------------- /src_c/doc/touch_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMESDL2TOUCH "pygame module to work with touch input" 3 | #define DOC_PYGAMESDL2TOUCHGETNUMDEVICES "get_num_devices() -> int\nget the number of touch devices" 4 | #define DOC_PYGAMESDL2TOUCHGETDEVICE "get_device(index) -> touchid\nget the a touch device id for a given index" 5 | #define DOC_PYGAMESDL2TOUCHGETNUMFINGERS "get_num_fingers(touchid) -> int\nthe number of active fingers for a given touch device" 6 | #define DOC_PYGAMESDL2TOUCHGETFINGER "get_finger(touchid, index) -> int\nget information about an active finger" 7 | 8 | 9 | /* Docs in a comment... slightly easier to read. */ 10 | 11 | /* 12 | 13 | pygame._sdl2.touch 14 | pygame module to work with touch input 15 | 16 | pygame._sdl2.touch.get_num_devices 17 | get_num_devices() -> int 18 | get the number of touch devices 19 | 20 | pygame._sdl2.touch.get_device 21 | get_device(index) -> touchid 22 | get the a touch device id for a given index 23 | 24 | pygame._sdl2.touch.get_num_fingers 25 | get_num_fingers(touchid) -> int 26 | the number of active fingers for a given touch device 27 | 28 | pygame._sdl2.touch.get_finger 29 | get_finger(touchid, index) -> int 30 | get information about an active finger 31 | 32 | */ -------------------------------------------------------------------------------- /docs/reST/c_api/cdrom.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ******************************** 6 | API exported by pygame.cdrom 7 | ******************************** 8 | 9 | src_c/cdrom.c 10 | ============= 11 | 12 | The :py:mod:`pygame.cdrom` extension module. Only available for SDL 1. 13 | 14 | Header file: src_c/include/pygame.h 15 | 16 | 17 | .. c:type:: pgCDObject 18 | 19 | The :py:class:`pygame.cdrom.CD` instance C struct. 20 | 21 | .. c:var:: PyTypeObject pgCD_Type 22 | 23 | The :py:class:`pygame.cdrom.CD` Python type. 24 | 25 | .. c:function:: PyObject* pgCD_New(int id) 26 | 27 | Return a new :py:class:`pygame.cdrom.CD` instance for CD drive *id*. 28 | On error raise a Python exception and return ``NULL``. 29 | 30 | .. c:function:: int pgCD_Check(PyObject *x) 31 | 32 | Return true if *x* is a :py:class:`pygame.cdrom.CD` instance. 33 | Will return false for a subclass of :py:class:`CD`. 34 | This is a macro. No check is made that *x* is not ``NULL``. 35 | 36 | .. c:function:: int pgCD_AsID(PyObject *x) 37 | 38 | Return the CD identifier associated with the :py:class:`pygame.cdrom.CD` 39 | instance *x*. 40 | This is a macro. No check is made that *x* is a :py:class:`pygame.cdrom.CD` 41 | instance or is not ``NULL``. 42 | -------------------------------------------------------------------------------- /docs/reST/_templates/header.h: -------------------------------------------------------------------------------- 1 | {#- Generate an extension module header file of doc strings #} 2 | 3 | {%- set classmembers = ['attribute', 'method', 'staticmethod', 'classmethod'] %} 4 | 5 | {%- macro cmacro(item) %} 6 | {%- if item['desctype'] in classmembers %} 7 | {%- set start_at = -2 %} 8 | {%- else %} 9 | {%- set start_at = 0 %} 10 | {%- endif %} 11 | {%- set name = item['fullname'] %} 12 | {{- 'DOC_' + name.split('.')[start_at:]|join('')|replace('_', '')|upper }} 13 | {%- endmacro %} 14 | 15 | {%- macro join_sigs(item) %} 16 | {%- set sigs = item['signatures'] %} 17 | {%- if sigs %} 18 | {{- sigs|join('\\n') + '\\n' }} 19 | {%- else %} 20 | {{- '' }} 21 | {%- endif %} 22 | {%- endmacro %} 23 | 24 | {#- -#} 25 | 26 | 27 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 28 | {% for item in hdr_items -%} 29 | #define {{ cmacro(item) }} "{{ join_sigs(item) }}{{ item['summary'] }}" 30 | {% endfor %} 31 | 32 | /* Docs in a comment... slightly easier to read. */ 33 | 34 | /* 35 | 36 | {% for item in hdr_items -%} 37 | {{ item['fullname'] }} 38 | {% set sigs = item['signatures'] -%} 39 | {% if sigs -%} 40 | {{ ' ' + sigs|join('\n ') }} 41 | {% endif -%} 42 | {{ item['summary'] }} 43 | 44 | {% endfor -%} 45 | */ 46 | -------------------------------------------------------------------------------- /docs/reST/themes/classic/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = pygame.css 4 | pygments_style = sphinx 5 | 6 | [options] 7 | home_uri = '' 8 | embedded = true 9 | nosidebar = true 10 | nofooter = true 11 | relbar = false 12 | noheader = false 13 | noheading = false 14 | notableofcontents = false 15 | 16 | footerbgcolor = #11303d 17 | footertextcolor = #000000 18 | sidebarbgcolor = #1c4e63 19 | sidebartextcolor = #ffffff 20 | sidebarlinkcolor = #98dbcc 21 | relbarbgcolor = #6aee28 22 | relbartextcolor = #000000 23 | relbarlinkcolor = #000000 24 | bgcolor = #aaeebb 25 | textcolor = #000000 26 | headbgcolor = #f2f2f2 27 | headtextcolor = #20435c 28 | headlinkcolor = #c60f0f 29 | linkcolor = #000000 30 | codebgcolor = #eeffcc 31 | codetextcolor = #333333 32 | headerbgcolor = #6aee28 33 | logobgcolor = #c2fc20 34 | tooltipbgcolor = #c2fc20 35 | tooltipbdrcolor = #ace01C 36 | 37 | headerborder = 3px solid black 38 | 39 | bodyfont = sans-serif 40 | headfont = sans-serif 41 | sigfont = monospace 42 | -------------------------------------------------------------------------------- /src_c/doc/bufferproxy_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMEBUFFERPROXY "BufferProxy() -> BufferProxy\npygame object to export a surface buffer through an array protocol" 3 | #define DOC_BUFFERPROXYPARENT "parent -> Surface\nparent -> \nReturn wrapped exporting object." 4 | #define DOC_BUFFERPROXYLENGTH "length -> int\nThe size, in bytes, of the exported buffer." 5 | #define DOC_BUFFERPROXYRAW "raw -> bytes\nA copy of the exported buffer as a single block of bytes." 6 | #define DOC_BUFFERPROXYWRITE "write(buffer, offset=0)\nWrite raw bytes to object buffer." 7 | 8 | 9 | /* Docs in a comment... slightly easier to read. */ 10 | 11 | /* 12 | 13 | pygame.BufferProxy 14 | BufferProxy() -> BufferProxy 15 | pygame object to export a surface buffer through an array protocol 16 | 17 | pygame.BufferProxy.parent 18 | parent -> Surface 19 | parent -> 20 | Return wrapped exporting object. 21 | 22 | pygame.BufferProxy.length 23 | length -> int 24 | The size, in bytes, of the exported buffer. 25 | 26 | pygame.BufferProxy.raw 27 | raw -> bytes 28 | A copy of the exported buffer as a single block of bytes. 29 | 30 | pygame.BufferProxy.write 31 | write(buffer, offset=0) 32 | Write raw bytes to object buffer. 33 | 34 | */ -------------------------------------------------------------------------------- /test/run_tests__tests/print_stdout/fake_3_test.py: -------------------------------------------------------------------------------- 1 | import sys 2 | if __name__ == '__main__': 3 | import os 4 | pkg_dir = (os.path.split( 5 | os.path.split( 6 | os.path.split( 7 | os.path.abspath(__file__))[0])[0])[0]) 8 | parent_dir, pkg_name = os.path.split(pkg_dir) 9 | is_pygame_pkg = (pkg_name == 'tests' and 10 | os.path.split(parent_dir)[1] == 'pygame') 11 | if not is_pygame_pkg: 12 | sys.path.insert(0, parent_dir) 13 | else: 14 | is_pygame_pkg = __name__.startswith('pygame.tests.') 15 | 16 | import unittest 17 | 18 | class KeyModuleTest(unittest.TestCase): 19 | def test_get_focused(self): 20 | self.assertTrue(True) 21 | 22 | def test_get_mods(self): 23 | self.assertTrue(True) 24 | 25 | def test_get_pressed(self): 26 | sys.stdout.write("jibberish ruins everything\n") 27 | self.assertTrue(False) 28 | 29 | def test_name(self): 30 | sys.stdout.write("forgot to remove debug crap\n") 31 | self.assertTrue(True) 32 | 33 | def test_set_mods(self): 34 | self.assertTrue(True) 35 | 36 | def test_set_repeat(self): 37 | self.assertTrue(True) 38 | 39 | 40 | if __name__ == '__main__': 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /docs/reST/_static/reset.css: -------------------------------------------------------------------------------- 1 | /* Set browser to a known state to get around browser incompatibilities. 2 | * Copied from http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ 3 | */ 4 | html, body, div, span, applet, object, iframe, 5 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 6 | a, abbr, acronym, address, big, cite, code, 7 | del, dfn, em, font, img, ins, kbd, q, s, samp, 8 | small, strike, strong, sub, sup, tt, var, 9 | dl, dt, dd, ol, ul, li, 10 | fieldset, form, label, legend, 11 | table, caption, tbody, tfoot, thead, tr, th, td { 12 | margin: 0; 13 | padding: 0; 14 | border: 0; 15 | outline: 0; 16 | font-weight: inherit; 17 | font-style: inherit; 18 | font-size: 100%; 19 | font-family: inherit; 20 | vertical-align: baseline; 21 | } 22 | /* remember to define focus styles! */ 23 | :focus { 24 | outline: 0; 25 | } 26 | body { 27 | line-height: 1; 28 | color: black; 29 | background: white; 30 | } 31 | ol, ul { 32 | list-style: none; 33 | } 34 | /* tables still need 'cellspacing="0"' in the markup */ 35 | table { 36 | border-collapse: separate; 37 | border-spacing: 0; 38 | } 39 | caption, th, td { 40 | text-align: left; 41 | font-weight: normal; 42 | } 43 | blockquote:before, blockquote:after, 44 | q:before, q:after { 45 | content: ""; 46 | } 47 | blockquote, q { 48 | quotes: "" ""; 49 | } 50 | -------------------------------------------------------------------------------- /docs/reST/c_api/display.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ********************************** 6 | API exported by pygame.display 7 | ********************************** 8 | 9 | src_c/display.c 10 | =============== 11 | 12 | This is the :py:mod:`pygame.display` extension module. 13 | 14 | Header file: src_c/include/pygame.h 15 | 16 | 17 | .. c:type:: pgVidInfoObject 18 | 19 | A pygame object that wraps an SDL_VideoInfo struct. 20 | The object returned by :py:func:`pgyame.display.Info()`. 21 | 22 | .. c:var:: PyTypeObject *pgVidInfo_Type 23 | 24 | The pgVidInfoObject object Python type. 25 | 26 | .. c:function:: SDL_VideoInfo pgVidInfo_AsVidInfo(PyObject *obj) 27 | 28 | Return the SDL_VideoInfo field of *obj*, a :c:data:`pgVidInfo_Type` instance. 29 | This macro does not check that *obj* is not ``NULL`` or an actual :c:type:`pgVidInfoObject` object. 30 | 31 | .. c:function:: PyObject* pgVidInfo_New(SDL_VideoInfo *i) 32 | 33 | Return a new :c:type:`pgVidInfoObject` object for the SDL_VideoInfo *i*. 34 | On failure, raise a Python exception and return ``NULL``. 35 | 36 | .. c:function:: int pgVidInfo_Check(PyObject *x) 37 | 38 | Return true if *x* is a :c:data:`pgVidInfo_Type` instance 39 | 40 | Will return false if *x* is a subclass of :c:data:`pgVidInfo_Type`. 41 | This macro does not check that *x* is not ``NULL``. 42 | -------------------------------------------------------------------------------- /src_c/include/pgplatform.h: -------------------------------------------------------------------------------- 1 | /* platform/compiler adjustments */ 2 | #ifndef PG_PLATFORM_H 3 | #define PG_PLATFORM_H 4 | 5 | #if defined(HAVE_SNPRINTF) /* defined in python.h (pyerrors.h) and SDL.h \ 6 | (SDL_config.h) */ 7 | #undef HAVE_SNPRINTF /* remove GCC redefine warning */ 8 | #endif /* HAVE_SNPRINTF */ 9 | 10 | #ifndef PG_INLINE 11 | #if defined(__clang__) 12 | #define PG_INLINE __inline__ __attribute__((__unused__)) 13 | #elif defined(__GNUC__) 14 | #define PG_INLINE __inline__ 15 | #elif defined(_MSC_VER) 16 | #define PG_INLINE __inline 17 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 18 | #define PG_INLINE inline 19 | #else 20 | #define PG_INLINE 21 | #endif 22 | #endif /* ~PG_INLINE */ 23 | 24 | /* This is unconditionally defined in Python.h */ 25 | #if defined(_POSIX_C_SOURCE) 26 | #undef _POSIX_C_SOURCE 27 | #endif 28 | 29 | /* No signal() */ 30 | #if defined(__SYMBIAN32__) && defined(HAVE_SIGNAL_H) 31 | #undef HAVE_SIGNAL_H 32 | #endif 33 | 34 | #if defined(HAVE_SNPRINTF) 35 | #undef HAVE_SNPRINTF 36 | #endif 37 | 38 | /* SDL needs WIN32 */ 39 | #if !defined(WIN32) && \ 40 | (defined(MS_WIN32) || defined(_WIN32) || \ 41 | defined(__WIN32) || defined(__WIN32__) || defined(_WINDOWS)) 42 | #define WIN32 43 | #endif 44 | 45 | #endif /* ~PG_PLATFORM_H */ 46 | -------------------------------------------------------------------------------- /test/touch_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pygame 3 | from pygame._sdl2 import touch 4 | 5 | 6 | has_touchdevice = touch.get_num_devices() > 0 7 | 8 | 9 | class TouchTest(unittest.TestCase): 10 | 11 | @classmethod 12 | def setUpClass(cls): 13 | pygame.display.init() 14 | 15 | @classmethod 16 | def tearDownClass(cls): 17 | pygame.display.quit() 18 | 19 | def test_num_devices(self): 20 | touch.get_num_devices() 21 | 22 | @unittest.skipIf(not has_touchdevice, 'no touch devices found') 23 | def test_get_device(self): 24 | touch.get_device(0) 25 | 26 | def test_num_fingers__invalid(self): 27 | self.assertRaises(pygame.error, touch.get_device, -1234) 28 | self.assertRaises(TypeError, touch.get_device, 'test') 29 | 30 | @unittest.skipIf(not has_touchdevice, 'no touch devices found') 31 | def test_num_fingers(self): 32 | touch.get_num_fingers(touch.get_device(0)) 33 | 34 | def test_num_fingers__invalid(self): 35 | self.assertRaises(TypeError, touch.get_num_fingers, 'test') 36 | self.assertRaises(pygame.error, touch.get_num_fingers, -1234) 37 | 38 | @unittest.skipIf(not has_touchdevice, 'no touch devices found') 39 | def todo_test_get_finger(self): 40 | """ask for touch input and check the dict""" 41 | 42 | 43 | if __name__ == '__main__': 44 | unittest.main() 45 | -------------------------------------------------------------------------------- /src_c/include/pygame.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2000-2001 Pete Shinners 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Pete Shinners 20 | pete@shinners.org 21 | */ 22 | 23 | /* To allow the Pygame C api to be globally shared by all code within an 24 | * extension module built from multiple C files, only include the pygame.h 25 | * header within the top level C file, the one which calls the 26 | * 'import_pygame_*' macros. All other C source files of the module should 27 | * include _pygame.h instead. 28 | */ 29 | #ifndef PYGAME_H 30 | #define PYGAME_H 31 | 32 | #include "_pygame.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /test/image__save_gl_surface_test.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | 4 | from pygame.tests import test_utils 5 | import pygame 6 | from pygame.locals import * 7 | 8 | 9 | @unittest.skipIf(os.environ.get('SDL_VIDEODRIVER') == 'dummy', 10 | 'OpenGL requires a non-"dummy" SDL_VIDEODRIVER') 11 | class GL_ImageSave(unittest.TestCase): 12 | def test_image_save_works_with_opengl_surfaces(self): 13 | """ 14 | |tags:display,slow,opengl| 15 | """ 16 | 17 | pygame.display.init() 18 | screen = pygame.display.set_mode((640,480), OPENGL|DOUBLEBUF) 19 | pygame.display.flip() 20 | 21 | tmp_dir = test_utils.get_tmp_dir() 22 | # Try the imageext module. 23 | tmp_file = os.path.join(tmp_dir, "opengl_save_surface_test.png") 24 | pygame.image.save(screen, tmp_file) 25 | 26 | self.assertTrue(os.path.exists(tmp_file)) 27 | 28 | os.remove(tmp_file) 29 | 30 | # Only test the image module. 31 | tmp_file = os.path.join(tmp_dir, "opengl_save_surface_test.bmp") 32 | pygame.image.save(screen, tmp_file) 33 | 34 | self.assertTrue(os.path.exists(tmp_file)) 35 | 36 | os.remove(tmp_file) 37 | 38 | # stops tonnes of tmp dirs building up in trunk dir 39 | os.rmdir(tmp_dir) 40 | pygame.display.quit() 41 | 42 | 43 | if __name__ == '__main__': 44 | unittest.main() 45 | -------------------------------------------------------------------------------- /docs/reST/ext/edit_on_github.py: -------------------------------------------------------------------------------- 1 | """ 2 | from: https://gist.github.com/mgedmin/6052926 3 | Sphinx extension to add ReadTheDocs-style "Edit on GitHub" links to the 4 | sidebar. 5 | Loosely based on https://github.com/astropy/astropy/pull/347 6 | """ 7 | 8 | import os 9 | import warnings 10 | 11 | 12 | __licence__ = 'BSD (3 clause)' 13 | 14 | 15 | def get_github_url(app, view, path): 16 | return 'https://github.com/{project}/{view}/{branch}/docs/reST/{path}'.format( 17 | project=app.config.edit_on_github_project, 18 | view=view, 19 | branch=app.config.edit_on_github_branch, 20 | path=path) 21 | 22 | 23 | def html_page_context(app, pagename, templatename, context, doctree): 24 | if templatename != 'page.html': 25 | return 26 | 27 | if not app.config.edit_on_github_project: 28 | warnings.warn("edit_on_github_project not specified") 29 | return 30 | 31 | path = os.path.relpath(doctree.get('source'), app.builder.srcdir) 32 | show_url = get_github_url(app, 'blob', path) 33 | edit_url = get_github_url(app, 'edit', path) 34 | 35 | context['show_on_github_url'] = show_url 36 | context['edit_on_github_url'] = edit_url 37 | 38 | 39 | def setup(app): 40 | app.add_config_value('edit_on_github_project', '', True) 41 | app.add_config_value('edit_on_github_branch', 'master', True) 42 | app.connect('html-page-context', html_page_context) 43 | -------------------------------------------------------------------------------- /test/__init__.py: -------------------------------------------------------------------------------- 1 | """Pygame unit test suite package 2 | 3 | Exports function run() 4 | 5 | A quick way to run the test suite package from the command line 6 | is by importing the go submodule: 7 | 8 | python -m "import pygame.tests" [] 9 | 10 | Command line option --help displays a usage message. Available options 11 | correspond to the pygame.tests.run arguments. 12 | 13 | The xxxx_test submodules of the tests package are unit test suites for 14 | individual parts of Pygame. Each can also be run as a main program. This is 15 | useful if the test, such as cdrom_test, is interactive. 16 | 17 | For Pygame development the test suite can be run from a Pygame distribution 18 | root directory using run_tests.py. Alternately, test/__main__.py can be run 19 | directly. 20 | 21 | """ 22 | 23 | if __name__ == 'pygame.tests': 24 | from pygame.tests.test_utils.run_tests import run 25 | elif __name__ == '__main__': 26 | import os 27 | import sys 28 | pkg_dir = os.path.split(os.path.abspath(__file__))[0] 29 | parent_dir, pkg_name = os.path.split(pkg_dir) 30 | is_pygame_pkg = (pkg_name == 'tests' and 31 | os.path.split(parent_dir)[1] == 'pygame') 32 | if not is_pygame_pkg: 33 | sys.path.insert(0, parent_dir) 34 | 35 | if is_pygame_pkg: 36 | import pygame.tests.__main__ 37 | else: 38 | import test.__main__ 39 | else: 40 | from test.test_utils.run_tests import run 41 | -------------------------------------------------------------------------------- /src_c/cython/pygame/_sdl2/sdl2.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | # 3 | 4 | from libc.string cimport memset 5 | from libc.stdio cimport * 6 | 7 | cdef extern from "SDL.h" nogil: 8 | # SDL_stdinc.h provides the real ones based on platform. 9 | ctypedef char Sint8 10 | ctypedef unsigned char Uint8 11 | ctypedef signed short Sint16 12 | ctypedef unsigned short Uint16 13 | ctypedef signed long Sint32 14 | ctypedef unsigned long Uint32 15 | ctypedef unsigned long long Uint64 16 | ctypedef signed long long Sint64 17 | ctypedef int SDL_bool 18 | 19 | const char *SDL_GetError() 20 | 21 | # https://wiki.libsdl.org/SDL_InitSubSystem 22 | # https://wiki.libsdl.org/SDL_QuitSubSystem 23 | # https://wiki.libsdl.org/SDL_WasInit 24 | int SDL_InitSubSystem(Uint32 flags) 25 | void SDL_QuitSubSystem(Uint32 flags) 26 | Uint32 SDL_WasInit(Uint32 flags) 27 | 28 | cdef int _SDL_INIT_TIMER "SDL_INIT_TIMER" 29 | cdef int _SDL_INIT_AUDIO "SDL_INIT_AUDIO" 30 | cdef int _SDL_INIT_VIDEO "SDL_INIT_VIDEO" 31 | cdef int _SDL_INIT_JOYSTICK "SDL_INIT_JOYSTICK" 32 | cdef int _SDL_INIT_HAPTIC "SDL_INIT_HAPTIC" 33 | cdef int _SDL_INIT_GAMECONTROLLER "SDL_INIT_GAMECONTROLLER" 34 | cdef int _SDL_INIT_EVENTS "SDL_INIT_EVENTS" 35 | cdef int _SDL_INIT_SENSOR "SDL_INIT_SENSOR" 36 | cdef int _SDL_INIT_NOPARACHUTE "SDL_INIT_NOPARACHUTE" 37 | cdef int _SDL_INIT_EVERYTHING "SDL_INIT_EVERYTHING" 38 | -------------------------------------------------------------------------------- /src_c/doc/pixelcopy_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMEPIXELCOPY "pygame module for general pixel array copying" 3 | #define DOC_PYGAMEPIXELCOPYSURFACETOARRAY "surface_to_array(array, surface, kind='P', opaque=255, clear=0) -> None\ncopy surface pixels to an array object" 4 | #define DOC_PYGAMEPIXELCOPYARRAYTOSURFACE "array_to_surface(, ) -> None\ncopy an array object to a surface" 5 | #define DOC_PYGAMEPIXELCOPYMAPARRAY "map_array(, , ) -> None\ncopy an array to another array, using surface format" 6 | #define DOC_PYGAMEPIXELCOPYMAKESURFACE "pygame.pixelcopy.make_surface(array) -> Surface\nCopy an array to a new surface" 7 | 8 | 9 | /* Docs in a comment... slightly easier to read. */ 10 | 11 | /* 12 | 13 | pygame.pixelcopy 14 | pygame module for general pixel array copying 15 | 16 | pygame.pixelcopy.surface_to_array 17 | surface_to_array(array, surface, kind='P', opaque=255, clear=0) -> None 18 | copy surface pixels to an array object 19 | 20 | pygame.pixelcopy.array_to_surface 21 | array_to_surface(, ) -> None 22 | copy an array object to a surface 23 | 24 | pygame.pixelcopy.map_array 25 | map_array(, , ) -> None 26 | copy an array to another array, using surface format 27 | 28 | pygame.pixelcopy.make_surface 29 | pygame.pixelcopy.make_surface(array) -> Surface 30 | Copy an array to a new surface 31 | 32 | */ -------------------------------------------------------------------------------- /docs/reST/c_api/freetype.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ************************************ 6 | API exported by pygame._freetype 7 | ************************************ 8 | 9 | src_c/_freetype.c 10 | ================= 11 | 12 | This extension module defines Python type :py:class:`pygame.freetype.Font`. 13 | 14 | Header file: src_c/include/pygame_freetype.h 15 | 16 | 17 | .. c:type:: pgFontObject 18 | 19 | The :py:class:`pygame.freetype.Font` instance C struct. 20 | 21 | .. c:type:: pgFont_Type 22 | 23 | The :py:class:`pygame.freetype.Font` Python type. 24 | 25 | .. c:function:: PyObject* pgFont_New(const char *filename, long font_index) 26 | 27 | Open the font file with path *filename* and return a new 28 | new :py:class:`pygame.freetype.Font` instance for that font. 29 | Set *font_index* to ``0`` unless the file contains multiple, indexed, fonts. 30 | On error raise a Python exception and return ``NULL``. 31 | 32 | .. c:function:: int pgFont_Check(PyObject *x) 33 | 34 | Return true if *x* is a :py:class:`pygame.freetype.Font` instance. 35 | Will return false for a subclass of :py:class:`Font`. 36 | This is a macro. No check is made that *x* is not ``NULL``. 37 | 38 | .. c:function:: int pgFont_IS_ALIVE(PyObject *o) 39 | 40 | Return true if :py:class:`pygame.freetype.Font` object ``o`` 41 | is an open font file. 42 | This is a macro. No check is made that *o* is not ``NULL`` 43 | or not a :py:class:`Font` instance. 44 | -------------------------------------------------------------------------------- /test/version_test.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | 4 | 5 | pg_header = os.path.join('src_c', 'include', '_pygame.h') 6 | 7 | 8 | class VersionTest(unittest.TestCase): 9 | @unittest.skipIf(not os.path.isfile(pg_header), 10 | "Skipping because we cannot find _pygame.h") 11 | def test_pg_version_consistency(self): 12 | from pygame import version 13 | pgh_major = -1 14 | pgh_minor = -1 15 | pgh_patch = -1 16 | import re 17 | major_exp_search = re.compile(r'define\s+PG_MAJOR_VERSION\s+([0-9]+)').search 18 | minor_exp_search = re.compile(r'define\s+PG_MINOR_VERSION\s+([0-9]+)').search 19 | patch_exp_search = re.compile(r'define\s+PG_PATCH_VERSION\s+([0-9]+)').search 20 | with open(pg_header) as f: 21 | for line in f: 22 | if pgh_major == -1: 23 | m = major_exp_search(line) 24 | if m: pgh_major = int(m.group(1)) 25 | if pgh_minor == -1: 26 | m = minor_exp_search(line) 27 | if m: pgh_minor = int(m.group(1)) 28 | if pgh_patch == -1: 29 | m = patch_exp_search(line) 30 | if m: pgh_patch = int(m.group(1)) 31 | self.assertEqual(pgh_major, version.vernum[0]) 32 | self.assertEqual(pgh_minor, version.vernum[1]) 33 | self.assertEqual(pgh_patch, version.vernum[2]) 34 | 35 | if __name__ == '__main__': 36 | unittest.main() 37 | -------------------------------------------------------------------------------- /src_c/include/pygame_mask.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public 6 | License as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with this library; if not, write to the Free 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef PGMASK_H 20 | #define PGMASK_H 21 | 22 | #include 23 | #include "bitmask.h" 24 | 25 | typedef struct { 26 | PyObject_HEAD 27 | bitmask_t *mask; 28 | void *bufdata; 29 | } pgMaskObject; 30 | 31 | #define pgMask_AsBitmap(x) (((pgMaskObject*)x)->mask) 32 | 33 | #ifndef PYGAMEAPI_MASK_INTERNAL 34 | 35 | #include "pgimport.h" 36 | 37 | PYGAMEAPI_DEFINE_SLOTS(mask); 38 | 39 | #define pgMask_Type (*(PyTypeObject*) \ 40 | PYGAMEAPI_GET_SLOT(mask, 0)) 41 | #define pgMask_Check(x) ((x)->ob_type == &pgMask_Type) 42 | 43 | #define import_pygame_mask() _IMPORT_PYGAME_MODULE(mask) 44 | 45 | #endif /* ~PYGAMEAPI_MASK_INTERNAL */ 46 | 47 | #endif /* ~PGMASK_H */ 48 | -------------------------------------------------------------------------------- /examples/sound.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """extremely simple demonstration playing a soundfile 4 | and waiting for it to finish. you'll need the pygame.mixer 5 | module for this to work. Note how in this simple example we 6 | don't even bother loading all of the pygame package. Just 7 | pick the mixer for sound and time for the delay function. 8 | 9 | Optional command line argument: 10 | the name of an audio file. 11 | 12 | 13 | """ 14 | 15 | import os.path, sys 16 | import pygame.mixer, pygame.time 17 | 18 | mixer = pygame.mixer 19 | time = pygame.time 20 | 21 | main_dir = os.path.split(os.path.abspath(__file__))[0] 22 | 23 | 24 | def main(file_path=None): 25 | """Play an audio file as a buffered sound sample 26 | 27 | Option argument: 28 | the name of an audio file (default data/secosmic_low.wav 29 | 30 | """ 31 | if file_path is None: 32 | file_path = os.path.join(main_dir, "data", "secosmic_lo.wav") 33 | 34 | # choose a desired audio format 35 | mixer.init(11025) # raises exception on fail 36 | 37 | # load the sound 38 | sound = mixer.Sound(file_path) 39 | 40 | # start playing 41 | print("Playing Sound...") 42 | channel = sound.play() 43 | 44 | # poll until finished 45 | while channel.get_busy(): # still playing 46 | print(" ...still going...") 47 | time.wait(1000) 48 | print("...Finished") 49 | 50 | 51 | if __name__ == "__main__": 52 | if len(sys.argv) > 1: 53 | main(sys.argv[1]) 54 | else: 55 | main() 56 | -------------------------------------------------------------------------------- /src_c/include/pygame_freetype.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2009 Vicent Marti 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | */ 20 | #ifndef PYGAME_FREETYPE_H_ 21 | #define PYGAME_FREETYPE_H_ 22 | 23 | #include "pgplatform.h" 24 | #include "pgimport.h" 25 | #include "pgcompat.h" 26 | 27 | #ifndef PYGAME_FREETYPE_INTERNAL 28 | 29 | PYGAMEAPI_DEFINE_SLOTS(_freetype); 30 | 31 | #define pgFont_Type (*(PyTypeObject*) \ 32 | PYGAMEAPI_GET_SLOT(_freetype, 0)) 33 | 34 | #define pgFont_Check(x) ((x)->ob_type == &pgFont_Type) 35 | 36 | #define pgFont_New (*(PyObject*(*)(const char*, long)) \ 37 | PYGAMEAPI_GET_SLOT(_freetype, 1)) 38 | 39 | #define import_pygame_freetype() _IMPORT_PYGAME_MODULE(_freetype) 40 | 41 | #endif /* PYGAME_FREETYPE_INTERNAL */ 42 | 43 | #endif /* PYGAME_FREETYPE_H_ */ 44 | -------------------------------------------------------------------------------- /examples/headless_no_windows_needed.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """How to use pygame with no windowing system, like on headless servers. 3 | 4 | Thumbnail generation with scaling is an example of what you can do with pygame. 5 | NOTE: the pygame scale function uses mmx/sse if available, and can be run 6 | in multiple threads. 7 | 8 | """ 9 | useage = """-scale inputimage outputimage new_width new_height 10 | eg. -scale in.png out.png 50 50 11 | 12 | """ 13 | 14 | import os, sys 15 | 16 | # set SDL to use the dummy NULL video driver, 17 | # so it doesn't need a windowing system. 18 | os.environ["SDL_VIDEODRIVER"] = "dummy" 19 | 20 | 21 | import pygame.transform 22 | 23 | # Some platforms need to init the display for some parts of pygame. 24 | import pygame.display 25 | 26 | pygame.display.init() 27 | screen = pygame.display.set_mode((1, 1)) 28 | 29 | 30 | def scaleit(fin, fout, w, h): 31 | i = pygame.image.load(fin) 32 | 33 | if hasattr(pygame.transform, "smoothscale"): 34 | scaled_image = pygame.transform.smoothscale(i, (w, h)) 35 | else: 36 | scaled_image = pygame.transform.scale(i, (w, h)) 37 | pygame.image.save(scaled_image, fout) 38 | 39 | 40 | def main(fin, fout, w, h): 41 | """smoothscale image file named fin as fout with new size (w,h)""" 42 | scaleit(fin, fout, w, h) 43 | 44 | 45 | if __name__ == "__main__": 46 | if "-scale" in sys.argv: 47 | fin, fout, w, h = sys.argv[2:] 48 | w, h = map(int, [w, h]) 49 | main(fin, fout, w, h) 50 | else: 51 | print(useage) 52 | -------------------------------------------------------------------------------- /src_c/scale_mmx.c: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2000-2001 Pete Shinners 4 | Copyright (C) 2007 Rene Dudfield, Richard Goedeken 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Library General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Library General Public License for more details. 15 | 16 | You should have received a copy of the GNU Library General Public 17 | License along with this library; if not, write to the Free 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | 20 | Pete Shinners 21 | pete@shinners.org 22 | */ 23 | 24 | /* Pentium MMX/SSE smoothscale routines 25 | * These are only compiled with GCC. 26 | */ 27 | #if defined(__GNUC__) 28 | /* Choose between the 32 bit and 64 bit versions. 29 | * Including source code like this may be frowned upon by some, 30 | * but the alternative is ungainly conditionally compiled code. 31 | */ 32 | # if defined(__x86_64__) 33 | # include "scale_mmx64.c" 34 | # elif defined(__i386__) 35 | # include "scale_mmx32.c" 36 | # endif 37 | #endif 38 | 39 | #if defined(_M_X64) && !defined(_NO_MMX_FOR_X86_64) 40 | #include "scale_mmx64_msvc.c" 41 | #endif 42 | -------------------------------------------------------------------------------- /docs/reST/c_api/event.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ******************************** 6 | API exported by pygame.event 7 | ******************************** 8 | 9 | src_c/event.c 10 | ============= 11 | 12 | The extsion module :py:mod:`pygame.event`. 13 | 14 | Header file: src_c/include/pygame.h 15 | 16 | 17 | .. c:type:: pgEventObject 18 | 19 | The :py:class:`pygame.event.EventType` object C struct. 20 | 21 | .. c:member:: int type 22 | 23 | The event type code. 24 | 25 | .. c:var:: pgEvent_Type 26 | 27 | The pygame event object type :py:class:`pygame.event.EventType`. 28 | 29 | .. c:function:: int pgEvent_Check(PyObject *x) 30 | 31 | Return true if *x* is a pygame event instance 32 | 33 | Will return false if *x* is a subclass of event. 34 | This is a macro. No check is made that *x* is not ``NULL``. 35 | 36 | .. c:function:: PyObject* pgEvent_New(SDL_Event *event) 37 | 38 | Return a new pygame event instance for the SDL *event*. 39 | If *event* is ``NULL`` then create an empty event object. 40 | On failure raise a Python exception and return ``NULL``. 41 | 42 | .. c:function:: PyObject* pgEvent_New2(int type, PyObject *dict) 43 | 44 | Return a new pygame event instance of SDL *type* and with 45 | attribute dictionary *dict*. 46 | If `dict` is ``NULL`` an empty attribute dictionary is created. 47 | On failure raise a Python exception and return ``NULL``. 48 | 49 | .. c:function:: int pgEvent_FillUserEvent(pgEventObject *e, SDL_Event *event) 50 | 51 | Fill SDL event *event* with information from pygame user event instance *e*. 52 | Return ``0`` on success, ``-1`` otherwise. 53 | -------------------------------------------------------------------------------- /examples/overlay.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | import pygame 5 | from pygame.compat import xrange_ 6 | 7 | SR = (800, 600) 8 | ovl = None 9 | 10 | ######################################################################## 11 | # Simple video player 12 | def vPlayer(fName): 13 | global ovl 14 | f = open(fName, "rb") 15 | fmt = f.readline().strip() 16 | res = f.readline().strip() 17 | unused_col = f.readline().strip() 18 | if fmt != "P5": 19 | print("Unknown format( len %d ). Exiting..." % len(fmt)) 20 | return 21 | 22 | w, h = [int(x) for x in res.split(" ")] 23 | h = (h * 2) / 3 24 | # Read into strings 25 | y = f.read(w * h) 26 | u = [] 27 | v = [] 28 | for _ in xrange_(0, h / 2): 29 | u.append(f.read(w / 2)) 30 | v.append(f.read(w / 2)) 31 | 32 | u = "".join(u) 33 | v = "".join(v) 34 | 35 | # Open overlay with the resolution specified 36 | ovl = pygame.Overlay(pygame.YV12_OVERLAY, (w, h)) 37 | ovl.set_location(0, 0, w, h) 38 | 39 | ovl.display((y, u, v)) 40 | while 1: 41 | pygame.time.wait(10) 42 | for ev in pygame.event.get(): 43 | if ev.type in (pygame.KEYDOWN, pygame.QUIT): 44 | return 45 | 46 | 47 | def main(fname): 48 | """play video file fname""" 49 | pygame.init() 50 | try: 51 | pygame.display.set_mode(SR) 52 | vPlayer(fname) 53 | finally: 54 | pygame.quit() 55 | 56 | 57 | # Test all modules 58 | if __name__ == "__main__": 59 | if len(sys.argv) != 2: 60 | print("Usage: play_file ") 61 | else: 62 | main(sys.argv[1]) 63 | -------------------------------------------------------------------------------- /src_c/doc/sndarray_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMESNDARRAY "pygame module for accessing sound sample data" 3 | #define DOC_PYGAMESNDARRAYARRAY "array(Sound) -> array\ncopy Sound samples into an array" 4 | #define DOC_PYGAMESNDARRAYSAMPLES "samples(Sound) -> array\nreference Sound samples into an array" 5 | #define DOC_PYGAMESNDARRAYMAKESOUND "make_sound(array) -> Sound\nconvert an array into a Sound object" 6 | #define DOC_PYGAMESNDARRAYUSEARRAYTYPE "use_arraytype (arraytype) -> None\nSets the array system to be used for sound arrays" 7 | #define DOC_PYGAMESNDARRAYGETARRAYTYPE "get_arraytype () -> str\nGets the currently active array type." 8 | #define DOC_PYGAMESNDARRAYGETARRAYTYPES "get_arraytypes () -> tuple\nGets the array system types currently supported." 9 | 10 | 11 | /* Docs in a comment... slightly easier to read. */ 12 | 13 | /* 14 | 15 | pygame.sndarray 16 | pygame module for accessing sound sample data 17 | 18 | pygame.sndarray.array 19 | array(Sound) -> array 20 | copy Sound samples into an array 21 | 22 | pygame.sndarray.samples 23 | samples(Sound) -> array 24 | reference Sound samples into an array 25 | 26 | pygame.sndarray.make_sound 27 | make_sound(array) -> Sound 28 | convert an array into a Sound object 29 | 30 | pygame.sndarray.use_arraytype 31 | use_arraytype (arraytype) -> None 32 | Sets the array system to be used for sound arrays 33 | 34 | pygame.sndarray.get_arraytype 35 | get_arraytype () -> str 36 | Gets the currently active array type. 37 | 38 | pygame.sndarray.get_arraytypes 39 | get_arraytypes () -> tuple 40 | Gets the array system types currently supported. 41 | 42 | */ -------------------------------------------------------------------------------- /src_c/include/pygame_font.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2000-2001 Pete Shinners 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Pete Shinners 20 | pete@shinners.org 21 | */ 22 | 23 | #include 24 | #include "pgplatform.h" 25 | 26 | struct TTF_Font; 27 | 28 | typedef struct { 29 | PyObject_HEAD 30 | TTF_Font* font; 31 | PyObject* weakreflist; 32 | } PyFontObject; 33 | #define PyFont_AsFont(x) (((PyFontObject*)x)->font) 34 | 35 | #ifndef PYGAMEAPI_FONT_INTERNAL 36 | 37 | #include "pgimport.h" 38 | 39 | PYGAMEAPI_DEFINE_SLOTS(font); 40 | 41 | #define PyFont_Type (*(PyTypeObject*) \ 42 | PYGAMEAPI_GET_SLOT(font, 0)) 43 | #define PyFont_Check(x) ((x)->ob_type == &PyFont_Type) 44 | 45 | #define PyFont_New (*(PyObject*(*)(TTF_Font*))\ 46 | PYGAMEAPI_GET_SLOT(font, 1)) 47 | 48 | /*slot 2 taken by FONT_INIT_CHECK*/ 49 | 50 | #define import_pygame_font() _IMPORT_PYGAME_MODULE(font) 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /docs/reST/c_api/color.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ******************************************** 6 | Class Color API exported by pygame.color 7 | ******************************************** 8 | 9 | src_c/color.c 10 | ============= 11 | 12 | This extension module defines the Python type :py:class:`pygame.Color`. 13 | 14 | Header file: src_c/include/pygame.h 15 | 16 | 17 | .. c:var:: PyTypeObject *pgColor_Type 18 | 19 | The Pygame color object type :py:class:`pygame.Color`. 20 | 21 | .. c:function:: int pgColor_Check(PyObject *obj) 22 | 23 | Return true if *obj* is an instance of type pgColor_Type, 24 | but not a pgColor_Type subclass instance. 25 | This macro does not check if *obj* is not ``NULL`` or indeed a Python type. 26 | 27 | .. c:function:: PyObject* pgColor_New(Uint8 rgba[]) 28 | 29 | Return a new :py:class:`pygame.Color` instance for the the four element array *rgba*. 30 | On failure, raise a Python exception and return ``NULL``. 31 | 32 | .. c:function:: PyObject* pgColor_NewLength(Uint8 rgba[], Uint8 length) 33 | 34 | Return a :py:class:`new pygame.Color` instance having *length* elements, 35 | with element values taken from the first *length* elements of array *rgba*. 36 | Argument *length* must be between ``1`` and ``4`` inclusive. 37 | On failure, raise a Python exception and return ``NULL``. 38 | 39 | .. c:function int pg_RGBAFromColorObj(PyObject *color, Uint8 rgba[]) 40 | 41 | Set the four element array *rgba* to the color represented by object *color*. 42 | Return ``1`` on success, ``0`` otherwise. 43 | No Python exceptions are raised. 44 | This in an extension of :c:func:`pg_RGBAFromObj` optimized for pgColor_Type 45 | instances. 46 | -------------------------------------------------------------------------------- /src_c/doc/image_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMEIMAGE "pygame module for image transfer" 3 | #define DOC_PYGAMEIMAGELOAD "load(filename) -> Surface\nload(fileobj, namehint="") -> Surface\nload new image from a file" 4 | #define DOC_PYGAMEIMAGESAVE "save(Surface, filename) -> None\nsave an image to disk" 5 | #define DOC_PYGAMEIMAGEGETEXTENDED "get_extended() -> bool\ntest if extended image formats can be loaded" 6 | #define DOC_PYGAMEIMAGETOSTRING "tostring(Surface, format, flipped=False) -> string\ntransfer image to string buffer" 7 | #define DOC_PYGAMEIMAGEFROMSTRING "fromstring(string, size, format, flipped=False) -> Surface\ncreate new Surface from a string buffer" 8 | #define DOC_PYGAMEIMAGEFROMBUFFER "frombuffer(string, size, format) -> Surface\ncreate a new Surface that shares data inside a string buffer" 9 | 10 | 11 | /* Docs in a comment... slightly easier to read. */ 12 | 13 | /* 14 | 15 | pygame.image 16 | pygame module for image transfer 17 | 18 | pygame.image.load 19 | load(filename) -> Surface 20 | load(fileobj, namehint="") -> Surface 21 | load new image from a file 22 | 23 | pygame.image.save 24 | save(Surface, filename) -> None 25 | save an image to disk 26 | 27 | pygame.image.get_extended 28 | get_extended() -> bool 29 | test if extended image formats can be loaded 30 | 31 | pygame.image.tostring 32 | tostring(Surface, format, flipped=False) -> string 33 | transfer image to string buffer 34 | 35 | pygame.image.fromstring 36 | fromstring(string, size, format, flipped=False) -> Surface 37 | create new Surface from a string buffer 38 | 39 | pygame.image.frombuffer 40 | frombuffer(string, size, format) -> Surface 41 | create a new Surface that shares data inside a string buffer 42 | 43 | */ -------------------------------------------------------------------------------- /docs/logos.html: -------------------------------------------------------------------------------- 1 | Pygame Logos 4 | 5 | 6 | 7 | 8 | 9 |

pygame logos
10 | 11 | These logos are available for use in your own game projects. 12 | Please put them up wherever you see fit. The logo was created 13 | by TheCorruptor on July 29, 2001. 14 | 15 | 16 |
17 | 18 |

19 | There is a higher resolution layered photoshop image 20 | available here. 21 | (1.3 MB)

22 | 23 |
24 |
25 | pygame_logo.gif - 676 x 200
26 |

27 |
28 | pygame_small.gif - 338 x 100
29 |

30 |
31 | pygame_tiny.gif - 200 x 60
32 |
33 | 34 |

35 |
36 | pygame_powered.gif - 250 x 100
37 |


 
38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/reST/c_api/bufferproxy.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ******************************************************** 6 | Class BufferProxy API exported by pgyame.bufferproxy 7 | ******************************************************** 8 | 9 | src_c/bufferproxy.c 10 | =================== 11 | 12 | This extension module defines Python type :py:class:`pygame.BufferProxy`. 13 | 14 | Header file: src_c/include/pygame_bufferproxy.h 15 | 16 | 17 | .. c:var:: PyTypeObject *pgBufproxy_Type 18 | 19 | The pygame buffer proxy object type pygame.BufferProxy. 20 | 21 | .. c:function:: int pgBufproxy_Check(PyObject *x) 22 | 23 | Return true if Python object *x* is a :py:class:`pygame.BufferProxy` instance, 24 | false otherwise. 25 | This will return false on :py:class:`pygame.BufferProxy` subclass instances as well. 26 | 27 | .. c:function:: PyObject* pgBufproxy_New(PyObject *obj, getbufferproc get_buffer) 28 | 29 | Return a new :py:class:`pygame.BufferProxy` instance. 30 | Argument *obj* is the Python object that has its data exposed. 31 | It may be ``NULL``. 32 | Argument *get_buffer* is the :c:type:`pg_buffer` get callback. 33 | It must not be ``NULL``. 34 | On failure raise a Python error and return ``NULL``. 35 | 36 | .. c:function:: PyObject* pgBufproxy_GetParent(PyObject *obj) 37 | 38 | Return the Python object wrapped by buffer proxy *obj*. 39 | Argument *obj* must not be ``NULL``. 40 | On failure, raise a Python error and return ``NULL``. 41 | 42 | .. c:function:: int pgBufproxy_Trip(PyObject *obj) 43 | 44 | Cause the buffer proxy object *obj* to create a :c:type:`pg_buffer` view of its parent. 45 | Argument *obj* must not be ``NULL``. 46 | Return ``0`` on success, otherwise raise a Python error and return ``-1``. 47 | -------------------------------------------------------------------------------- /src_c/cython/pygame/_sdl2/sdl2.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | # 3 | 4 | # pygame.error 5 | class error(RuntimeError): 6 | def __init__(self, message=None): 7 | if message is None: 8 | message = SDL_GetError().decode('utf8') 9 | RuntimeError.__init__(self, message) 10 | 11 | 12 | 13 | 14 | # for init_subsystem. Expose variables to python. 15 | INIT_TIMER = _SDL_INIT_TIMER 16 | INIT_AUDIO = _SDL_INIT_AUDIO 17 | INIT_VIDEO = _SDL_INIT_VIDEO 18 | INIT_JOYSTICK = _SDL_INIT_JOYSTICK 19 | INIT_HAPTIC = _SDL_INIT_HAPTIC 20 | INIT_GAMECONTROLLER = _SDL_INIT_GAMECONTROLLER 21 | INIT_EVENTS = _SDL_INIT_EVENTS 22 | # INIT_SENSOR = _SDL_INIT_SENSOR 23 | INIT_NOPARACHUTE = _SDL_INIT_NOPARACHUTE 24 | INIT_EVERYTHING = _SDL_INIT_EVERYTHING 25 | 26 | 27 | # TODO: Not sure about exposing init_subsystem in pygame. 28 | # It would be useful if you wanted to use audio without SDL_mixer. 29 | 30 | # https://wiki.libsdl.org/SDL_InitSubSystem 31 | def init_subsystem(flags): 32 | """ Use this function to initialize specific subsystems. 33 | 34 | :param int flags: any of the flags used by. 35 | 36 | * INIT_TIMER timer subsystem 37 | * INIT_AUDIO audio subsystem 38 | * INIT_VIDEO video subsystem; automatically initializes the events subsystem 39 | * INIT_JOYSTICK joystick subsystem; automatically initializes the events subsystem 40 | * INIT_HAPTIC haptic (force feedback) subsystem 41 | * INIT_GAMECONTROLLER controller subsystem; automatically initializes the joystick subsystem 42 | * INIT_EVENTS events subsystem 43 | * INIT_EVERYTHING all of the above subsystems 44 | * INIT_NOPARACHUTE compatibility; this flag is ignored 45 | """ 46 | if (SDL_InitSubSystem(flags) == -1): 47 | raise error() 48 | -------------------------------------------------------------------------------- /docs/reST/ext/headers.py: -------------------------------------------------------------------------------- 1 | from ext.utils import get_sectionname, isections 2 | from ext.indexer import tour_descinfo 3 | 4 | import os 5 | 6 | 7 | def setup(app): 8 | # This extension uses indexer collected tables. 9 | app.setup_extension('ext.indexer') 10 | 11 | # The target directory for the header files. 12 | app.add_config_value('headers_dest', '.', 'html') 13 | 14 | # Create directory tree if missing? 15 | app.add_config_value('headers_mkdirs', False, '') 16 | 17 | # Suffix to tag onto file name before the '.h' extension 18 | app.add_config_value('headers_filename_sfx', '', 'html') 19 | 20 | # Header template to use 21 | app.add_config_value('headers_template', 'header.h', 'html') 22 | 23 | # Write a header when its corresponding HTML page is written. 24 | app.connect('html-page-context', writer) 25 | 26 | 27 | def writer(app, pagename, templatename, context, doctree): 28 | if doctree is None: 29 | return 30 | 31 | env = app.builder.env 32 | dirpath = os.path.abspath(app.config['headers_dest']) 33 | if app.config['headers_mkdirs'] and not os.path.lexists(dirpath): 34 | os.makedirs(dirpath) 35 | filename_suffix = app.config['headers_filename_sfx'] 36 | items = [] 37 | for section in isections(doctree): 38 | tour_descinfo(items.append, section, env) 39 | if not items: 40 | return 41 | templates = app.builder.templates 42 | filename = '%s%s.h' % (os.path.basename(pagename), filename_suffix) 43 | filepath = os.path.join(dirpath, filename) 44 | template = app.config['headers_template'] 45 | header = open(filepath, 'w') 46 | context['hdr_items'] = items 47 | try: 48 | header.write(templates.render(template, context)) 49 | finally: 50 | header.close() 51 | del context['hdr_items'] 52 | -------------------------------------------------------------------------------- /src_c/fastevents.h: -------------------------------------------------------------------------------- 1 | #ifndef _FASTEVENTS_H_ 2 | #define _FASTEVENTS_H_ 3 | /* 4 | NET2 is a threaded, event based, network IO library for SDL. 5 | Copyright (C) 2002 Bob Pendleton 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 10 | of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free 19 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 20 | 02111-1307 USA 21 | 22 | If you do not wish to comply with the terms of the LGPL please 23 | contact the author as other terms are available for a fee. 24 | 25 | Bob Pendleton 26 | Bob@Pendleton.com 27 | */ 28 | 29 | #include "SDL.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | int FE_Init(void); // Initialize FE 36 | void FE_Quit(void); // shutdown FE 37 | 38 | void FE_PumpEvents(void); // replacement for SDL_PumpEvents 39 | int FE_PollEvent(SDL_Event *event); // replacement for SDL_PollEvent 40 | int FE_WaitEvent(SDL_Event *event); // replacement for SDL_WaitEvent 41 | int FE_PushEvent(SDL_Event *event); // replacement for SDL_PushEvent 42 | 43 | char *FE_GetError(void); // get the last error 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /examples/audiocapture.py: -------------------------------------------------------------------------------- 1 | import pygame as pg 2 | import time 3 | 4 | if pg.get_sdl_version()[0] < 2: 5 | raise SystemExit("This example requires pygame 2 and SDL2.") 6 | 7 | from pygame._sdl2 import ( 8 | get_audio_device_name, 9 | get_num_audio_devices, 10 | AudioDevice, 11 | AUDIO_F32, 12 | AUDIO_ALLOW_FORMAT_CHANGE, 13 | ) 14 | from pygame._sdl2.mixer import set_post_mix 15 | 16 | 17 | pg.mixer.pre_init(44100, 32, 2, 512) 18 | pg.init() 19 | 20 | # init_subsystem(INIT_AUDIO) 21 | names = [get_audio_device_name(x, 1) for x in range(get_num_audio_devices(1))] 22 | print(names) 23 | 24 | iscapture = 1 25 | sounds = [] 26 | sound_chunks = [] 27 | 28 | 29 | def callback(audiodevice, audiomemoryview): 30 | """ This is called in the sound thread. 31 | 32 | Note, that the frequency and such you request may not be what you get. 33 | """ 34 | # print(type(audiomemoryview), len(audiomemoryview)) 35 | # print(audiodevice) 36 | sound_chunks.append(bytes(audiomemoryview)) 37 | 38 | 39 | def postmix_callback(postmix, audiomemoryview): 40 | """ This is called in the sound thread. 41 | 42 | At the end of mixing we get this data. 43 | """ 44 | print(type(audiomemoryview), len(audiomemoryview)) 45 | print(postmix) 46 | 47 | 48 | set_post_mix(postmix_callback) 49 | 50 | audio = AudioDevice( 51 | devicename=names[0], 52 | iscapture=1, 53 | frequency=44100, 54 | audioformat=AUDIO_F32, 55 | numchannels=2, 56 | chunksize=512, 57 | allowed_changes=AUDIO_ALLOW_FORMAT_CHANGE, 58 | callback=callback, 59 | ) 60 | # start recording. 61 | audio.pause(0) 62 | 63 | print("recording with :%s:" % names[0]) 64 | time.sleep(5) 65 | 66 | 67 | print("Turning data into a pygame.mixer.Sound") 68 | sound = pg.mixer.Sound(buffer=b"".join(sound_chunks)) 69 | 70 | print("playing back recorded sound") 71 | sound.play() 72 | time.sleep(5) 73 | -------------------------------------------------------------------------------- /src_py/freetype.py: -------------------------------------------------------------------------------- 1 | """Enhanced Pygame module for loading and rendering computer fonts""" 2 | 3 | from pygame._freetype import ( 4 | Font, 5 | STYLE_NORMAL, STYLE_OBLIQUE, STYLE_STRONG, STYLE_UNDERLINE, STYLE_WIDE, 6 | STYLE_DEFAULT, 7 | init, quit, get_init, 8 | was_init, get_cache_size, get_default_font, get_default_resolution, 9 | get_error, get_version, set_default_resolution, 10 | _PYGAME_C_API, __PYGAMEinit__, 11 | ) 12 | from pygame.sysfont import match_font, get_fonts, SysFont as _SysFont 13 | 14 | 15 | def SysFont(name, size, bold=0, italic=0, constructor=None): 16 | """pygame.ftfont.SysFont(name, size, bold=False, italic=False, constructor=None) -> Font 17 | create a pygame Font from system font resources 18 | 19 | This will search the system fonts for the given font 20 | name. You can also enable bold or italic styles, and 21 | the appropriate system font will be selected if available. 22 | 23 | This will always return a valid Font object, and will 24 | fallback on the builtin pygame font if the given font 25 | is not found. 26 | 27 | Name can also be a comma separated list of names, in 28 | which case set of names will be searched in order. Pygame 29 | uses a small set of common font aliases, if the specific 30 | font you ask for is not available, a reasonable alternative 31 | may be used. 32 | 33 | if optional contructor is provided, it must be a function with 34 | signature constructor(fontpath, size, bold, italic) which returns 35 | a Font instance. If None, a pygame.freetype.Font object is created. 36 | """ 37 | if constructor is None: 38 | def constructor(fontpath, size, bold, italic): 39 | font = Font(fontpath, size) 40 | font.strong = bold 41 | font.oblique = italic 42 | return font 43 | 44 | return _SysFont(name, size, bold, italic, constructor) 45 | -------------------------------------------------------------------------------- /test/fixtures/fonts/PyGameMono-8.bdf: -------------------------------------------------------------------------------- 1 | STARTFONT 2.1 2 | FONT -FontForge-PyGameMono-Medium-R-Normal--8-80-75-75-C-80-ISO10646-1 3 | SIZE 8 75 75 4 | FONTBOUNDINGBOX 6 7 0 0 5 | COMMENT "Generated by fontforge, http://fontforge.sourceforge.net" 6 | COMMENT "Created by Lenard Lindstrom,,, with FontForge 2.0 (http://fontforge.sf.net)" 7 | STARTPROPERTIES 29 8 | FOUNDRY "FontForge" 9 | FAMILY_NAME "PyGameMono" 10 | WEIGHT_NAME "Medium" 11 | SLANT "R" 12 | SETWIDTH_NAME "Normal" 13 | ADD_STYLE_NAME "" 14 | PIXEL_SIZE 8 15 | POINT_SIZE 80 16 | RESOLUTION_X 75 17 | RESOLUTION_Y 75 18 | SPACING "C" 19 | AVERAGE_WIDTH 80 20 | CHARSET_REGISTRY "ISO10646" 21 | CHARSET_ENCODING "1" 22 | FONTNAME_REGISTRY "" 23 | CHARSET_COLLECTIONS "ISO10646-1" 24 | FONT_NAME "PyGameMono" 25 | FACE_NAME "PyGame Mono" 26 | FONT_VERSION "001.000" 27 | FONT_ASCENT 6 28 | FONT_DESCENT 2 29 | UNDERLINE_POSITION -1 30 | UNDERLINE_THICKNESS 1 31 | RAW_ASCENT 800 32 | RAW_DESCENT 200 33 | RELATIVE_WEIGHT 50 34 | RELATIVE_SETWIDTH 50 35 | FIGURE_WIDTH -1 36 | AVG_UPPERCASE_WIDTH 80 37 | ENDPROPERTIES 38 | CHARS 5 39 | STARTCHAR .notdef 40 | ENCODING 0 41 | SWIDTH 1000 0 42 | DWIDTH 8 0 43 | BBX 6 6 0 0 44 | BITMAP 45 | FC 46 | 84 47 | 84 48 | 84 49 | 84 50 | FC 51 | ENDCHAR 52 | STARTCHAR A 53 | ENCODING 65 54 | SWIDTH 1000 0 55 | DWIDTH 8 0 56 | BBX 6 7 0 0 57 | BITMAP 58 | 78 59 | 84 60 | 84 61 | FC 62 | 84 63 | 84 64 | 84 65 | ENDCHAR 66 | STARTCHAR B 67 | ENCODING 66 68 | SWIDTH 1000 0 69 | DWIDTH 8 0 70 | BBX 6 6 0 0 71 | BITMAP 72 | FC 73 | 44 74 | 78 75 | 4C 76 | 44 77 | FC 78 | ENDCHAR 79 | STARTCHAR C 80 | ENCODING 67 81 | SWIDTH 1000 0 82 | DWIDTH 8 0 83 | BBX 6 6 0 0 84 | BITMAP 85 | 78 86 | C4 87 | C0 88 | C0 89 | C4 90 | 78 91 | ENDCHAR 92 | STARTCHAR u13079 93 | ENCODING 77945 94 | SWIDTH 1000 0 95 | DWIDTH 8 0 96 | BBX 6 4 0 1 97 | BITMAP 98 | 78 99 | B4 100 | B4 101 | 78 102 | ENDCHAR 103 | ENDFONT 104 | -------------------------------------------------------------------------------- /src_c/doc/scrap_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMESCRAP "pygame module for clipboard support." 3 | #define DOC_PYGAMESCRAPINIT "init() -> None\nInitializes the scrap module." 4 | #define DOC_PYGAMESCRAPGETINIT "get_init() -> bool\nReturns True if the scrap module is currently initialized." 5 | #define DOC_PYGAMESCRAPGET "get(type) -> bytes or str or None\nGets the data for the specified type from the clipboard." 6 | #define DOC_PYGAMESCRAPGETTYPES "get_types() -> list\nGets a list of the available clipboard types." 7 | #define DOC_PYGAMESCRAPPUT "put(type, data) -> None\nPlaces data into the clipboard." 8 | #define DOC_PYGAMESCRAPCONTAINS "contains(type) -> bool\nChecks whether data for a given type is available in the clipboard." 9 | #define DOC_PYGAMESCRAPLOST "lost() -> bool\nIndicates if the clipboard ownership has been lost by the pygame application." 10 | #define DOC_PYGAMESCRAPSETMODE "set_mode(mode) -> None\nSets the clipboard access mode." 11 | 12 | 13 | /* Docs in a comment... slightly easier to read. */ 14 | 15 | /* 16 | 17 | pygame.scrap 18 | pygame module for clipboard support. 19 | 20 | pygame.scrap.init 21 | init() -> None 22 | Initializes the scrap module. 23 | 24 | pygame.scrap.get_init 25 | get_init() -> bool 26 | Returns True if the scrap module is currently initialized. 27 | 28 | pygame.scrap.get 29 | get(type) -> bytes or str or None 30 | Gets the data for the specified type from the clipboard. 31 | 32 | pygame.scrap.get_types 33 | get_types() -> list 34 | Gets a list of the available clipboard types. 35 | 36 | pygame.scrap.put 37 | put(type, data) -> None 38 | Places data into the clipboard. 39 | 40 | pygame.scrap.contains 41 | contains(type) -> bool 42 | Checks whether data for a given type is available in the clipboard. 43 | 44 | pygame.scrap.lost 45 | lost() -> bool 46 | Indicates if the clipboard ownership has been lost by the pygame application. 47 | 48 | pygame.scrap.set_mode 49 | set_mode(mode) -> None 50 | Sets the clipboard access mode. 51 | 52 | */ -------------------------------------------------------------------------------- /src_c/include/pygame_bufferproxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2000-2001 Pete Shinners 4 | Copyright (C) 2007 Rene Dudfield, Richard Goedeken 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Library General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Library General Public License for more details. 15 | 16 | You should have received a copy of the GNU Library General Public 17 | License along with this library; if not, write to the Free 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | 20 | Pete Shinners 21 | pete@shinners.org 22 | */ 23 | 24 | /* Bufferproxy module C api. */ 25 | #if !defined(PG_BUFPROXY_HEADER) 26 | #define PG_BUFPROXY_HEADER 27 | 28 | #include 29 | 30 | typedef PyObject *(*_pgbufproxy_new_t)(PyObject *, getbufferproc); 31 | typedef PyObject *(*_pgbufproxy_get_obj_t)(PyObject *); 32 | typedef int (*_pgbufproxy_trip_t)(PyObject *); 33 | 34 | #ifndef PYGAMEAPI_BUFPROXY_INTERNAL 35 | 36 | #include "pgimport.h" 37 | 38 | PYGAMEAPI_DEFINE_SLOTS(bufferproxy); 39 | 40 | #define pgBufproxy_Type (*(PyTypeObject*) \ 41 | PYGAMEAPI_GET_SLOT(bufferproxy, 0) ) 42 | 43 | #define pgBufproxy_Check(x) ((x)->ob_type == &pgBufproxy_Type) 44 | 45 | #define pgBufproxy_New (*(_pgbufproxy_new_t) \ 46 | PYGAMEAPI_GET_SLOT(bufferproxy, 1)) 47 | 48 | #define pgBufproxy_GetParent \ 49 | (*(_pgbufproxy_get_obj_t) \ 50 | PYGAMEAPI_GET_SLOT(bufferproxy, 2)) 51 | 52 | #define pgBufproxy_Trip (*(_pgbufproxy_trip_t) \ 53 | PYGAMEAPI_GET_SLOT(bufferproxy, 3)) 54 | 55 | #define import_pygame_bufferproxy() _IMPORT_PYGAME_MODULE(bufferproxy) 56 | 57 | #endif /* ~PYGAMEAPI_BUFPROXY_INTERNAL */ 58 | 59 | #endif /* ~defined(PG_BUFPROXY_HEADER) */ 60 | -------------------------------------------------------------------------------- /examples/moveit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | This is the full and final example from the Pygame Tutorial, 5 | "How Do I Make It Move". It creates 10 objects and animates 6 | them on the screen. 7 | 8 | Note it's a bit scant on error checking, but it's easy to read. :] 9 | Fortunately, this is python, and we needn't wrestle with a pile of 10 | error codes. 11 | """ 12 | 13 | 14 | # import everything 15 | import os, pygame 16 | from pygame.locals import * 17 | 18 | main_dir = os.path.split(os.path.abspath(__file__))[0] 19 | 20 | # our game object class 21 | class GameObject: 22 | def __init__(self, image, height, speed): 23 | self.speed = speed 24 | self.image = image 25 | self.pos = image.get_rect().move(0, height) 26 | 27 | def move(self): 28 | self.pos = self.pos.move(self.speed, 0) 29 | if self.pos.right > 600: 30 | self.pos.left = 0 31 | 32 | 33 | # quick function to load an image 34 | def load_image(name): 35 | path = os.path.join(main_dir, "data", name) 36 | return pygame.image.load(path).convert() 37 | 38 | 39 | # here's the full code 40 | def main(): 41 | pygame.init() 42 | screen = pygame.display.set_mode((640, 480)) 43 | 44 | player = load_image("player1.gif") 45 | background = load_image("liquid.bmp") 46 | 47 | # scale the background image so that it fills the window and 48 | # successfully overwrites the old sprite position. 49 | background = pygame.transform.scale2x(background) 50 | background = pygame.transform.scale2x(background) 51 | 52 | screen.blit(background, (0, 0)) 53 | 54 | objects = [] 55 | for x in range(10): 56 | o = GameObject(player, x * 40, x) 57 | objects.append(o) 58 | 59 | while 1: 60 | for event in pygame.event.get(): 61 | if event.type in (QUIT, KEYDOWN): 62 | return 63 | 64 | for o in objects: 65 | screen.blit(background, o.pos, o.pos) 66 | for o in objects: 67 | o.move() 68 | screen.blit(o.image, o.pos) 69 | 70 | pygame.display.update() 71 | 72 | 73 | if __name__ == "__main__": 74 | main() 75 | -------------------------------------------------------------------------------- /src_c/scrap_sdl2.c: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #include "SDL_clipboard.h" 3 | 4 | #define PYGAME_SCRAP_FREE_STRING 1 5 | 6 | char *pygame_scrap_plaintext_type = "text/plain;charset=utf-8"; 7 | char **pygame_scrap_types; 8 | 9 | int 10 | pygame_scrap_contains(char *type) 11 | { 12 | return (strcmp(type, pygame_scrap_plaintext_type) == 0) && SDL_HasClipboardText(); 13 | } 14 | 15 | char * 16 | pygame_scrap_get(char *type, unsigned long *count) 17 | { 18 | char *retval = NULL; 19 | char *clipboard = NULL; 20 | 21 | if (!pygame_scrap_initialized()) { 22 | PyErr_SetString(pgExc_SDLError, "scrap system not initialized."); 23 | return NULL; 24 | } 25 | 26 | if (strcmp(type, pygame_scrap_plaintext_type) == 0) { 27 | clipboard = SDL_GetClipboardText(); 28 | if (clipboard != NULL) { 29 | *count = strlen(clipboard); 30 | retval = strdup(clipboard); 31 | SDL_free(clipboard); 32 | return retval; 33 | } 34 | } 35 | return NULL; 36 | } 37 | 38 | char ** 39 | pygame_scrap_get_types(void) 40 | { 41 | if (!pygame_scrap_initialized()) { 42 | PyErr_SetString(pgExc_SDLError, "scrap system not initialized."); 43 | return NULL; 44 | } 45 | 46 | return pygame_scrap_types; 47 | } 48 | 49 | int 50 | pygame_scrap_init(void) 51 | { 52 | SDL_Init(SDL_INIT_VIDEO); 53 | 54 | pygame_scrap_types = malloc(sizeof(char *) * 2); 55 | if (!pygame_scrap_types) { 56 | return 0; 57 | } 58 | 59 | pygame_scrap_types[0] = pygame_scrap_plaintext_type; 60 | pygame_scrap_types[1] = NULL; 61 | 62 | _scrapinitialized = 1; 63 | return _scrapinitialized; 64 | } 65 | 66 | int 67 | pygame_scrap_lost(void) 68 | { 69 | return 1; 70 | } 71 | 72 | int 73 | pygame_scrap_put(char *type, int srclen, char *src) 74 | { 75 | if (!pygame_scrap_initialized()) { 76 | PyErr_SetString(pgExc_SDLError, "scrap system not initialized."); 77 | return 0; 78 | } 79 | 80 | if (strcmp(type, pygame_scrap_plaintext_type) == 0) { 81 | if (SDL_SetClipboardText(src) == 0) { 82 | return 1; 83 | } 84 | } 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /docs/reST/c_api/surface.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ************************************************ 6 | Class Surface API exported by pygame.surface 7 | ************************************************ 8 | 9 | src_c/surface.c 10 | =============== 11 | 12 | This extension module defines Python type :py:class:`pygame.Surface`. 13 | 14 | Header file: src_c/include/pygame.h 15 | 16 | 17 | .. c:type:: pgSurfaceObject 18 | 19 | A :py:class:`pygame.Surface` instance. 20 | 21 | .. c:var:: PyTypeObject *pgSurface_Type 22 | 23 | The :py:class:`pygame.Surface` Python type. 24 | 25 | .. c:function:: int pgSurface_Check(PyObject *x) 26 | 27 | Return true if *x* is a :py:class:`pygame.Surface` instance 28 | 29 | Will return false if *x* is a subclass of `Surface`. 30 | This is a macro. No check is made that *x* is not *NULL*. 31 | 32 | .. c:function:: PyObject* pgSurface_New(SDL_Surface *s) 33 | 34 | Return a new new pygame surface instance for SDL surface *s*. 35 | Return *NULL* on error. 36 | 37 | .. c:function:: SDL_Surface* pgSurface_AsSurface(PyObject *x) 38 | 39 | Return a pointer the SDL surface represented by the pygame Surface instance 40 | *x*. 41 | 42 | This is a macro. Argument *x* is assumed to be a Surface, or subclass of 43 | Surface, instance. 44 | 45 | .. c:function:: int pgSurface_Blit(PyObject *dstobj, PyObject *srcobj, SDL_Rect *dstrect, SDL_Rect *srcrect, int the_args) 46 | 47 | Blit the *srcrect* portion of Surface *srcobj* onto Surface *dstobj* at *srcobj* 48 | 49 | Argument *the_args* indicates the type of blit to perform: 50 | Normal blit (``0``), ``PYGAME_BLEND_ADD``, ``PYGAME_BLEND_SUB``, 51 | ``PYGAME_BLEND_SUB``, ``PYGAME_BLEND_MULT``, ``PYGAME_BLEND_MIN``, 52 | ``PYGAME_BLEND_MAX``, ``PYGAME_BLEND_RGBA_ADD``, ``PYGAME_BLEND_RGBA_SUB``, 53 | ``PYGAME_BLEND_RGBA_MULT``, ``PYGAME_BLEND_RGBA_MIN``, 54 | ``PYGAME_BLEND_RGBA_MAX``, and ``PYGAME_BLEND_PREMULTIPLIED``. 55 | Argument *dstrect* is updated to the actual area on *dstobj* affected 56 | by the blit. 57 | 58 | The C version of the :py:meth:`pygame.Surface.blit` method. 59 | Return ``1`` on success, ``0`` on an exception. 60 | -------------------------------------------------------------------------------- /src_c/cython/pygame/_sdl2/mixer.pyx: -------------------------------------------------------------------------------- 1 | from . import error 2 | import traceback 3 | 4 | #https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC79 5 | 6 | # void (*mix_func)(void *udata, Uint8 *stream, int len), 7 | # // make a passthru processor function that does nothing... 8 | # void noEffect(void *udata, Uint8 *stream, int len) 9 | # { 10 | # // you could work with stream here... 11 | # } 12 | # ... 13 | # // register noEffect as a postmix processor 14 | # Mix_SetPostMix(noEffect, NULL); 15 | 16 | 17 | cdef void recording_cb(void* userdata, Uint8* stream, int len) nogil: 18 | """ This is called in a thread made by SDL. 19 | So we need the python GIL to do python stuff. 20 | """ 21 | cdef Uint8 [:] a_memoryview 22 | with gil: 23 | a_memoryview = stream 24 | try: 25 | # The userdata is the audio device. 26 | # The audio device is needed in some apps 27 | (userdata).callback(userdata, a_memoryview) 28 | except: 29 | traceback.print_exc() 30 | raise 31 | 32 | # ctypedef void (*cfptr)(int) 33 | # cdef cfptr myfunctionptr = &myfunc 34 | 35 | 36 | 37 | 38 | cdef class _PostMix: 39 | # def __cinit__(self): 40 | 41 | def __init__(self, callback): 42 | self._callback = callback 43 | self.userdata = self 44 | self.callback = recording_cb; 45 | Mix_SetPostMix(self.callback, self.userdata) 46 | 47 | def __dealloc__(self): 48 | Mix_SetPostMix(NULL, NULL) 49 | 50 | @property 51 | def callback(self): 52 | """ called in the sound thread with (audiodevice, memoryview) 53 | """ 54 | return self._callback 55 | 56 | 57 | _postmix = None 58 | cpdef set_post_mix(mix_func): 59 | """ Hook a processor function mix_func to the postmix stream for 60 | post processing effects. You may just be reading the data and displaying 61 | it, or you may be altering the stream to add an echo. 62 | 63 | 64 | """ 65 | global _postmix 66 | if mix_func is None: 67 | _postmix = None 68 | Mix_SetPostMix(NULL, NULL) 69 | else: 70 | _postmix = _PostMix(mix_func) 71 | -------------------------------------------------------------------------------- /docs/reST/ref/touch.rst: -------------------------------------------------------------------------------- 1 | .. include:: common.txt 2 | 3 | :mod:`pygame._sdl2.touch` 4 | ========================= 5 | 6 | .. module:: pygame._sdl2.touch 7 | :synopsis: pygame module to work with touch input 8 | 9 | | :sl:`pygame module to work with touch input` 10 | 11 | .. versionadded:: 2 This module requires SDL2. 12 | 13 | .. function:: get_num_devices 14 | 15 | | :sl:`get the number of touch devices` 16 | | :sg:`get_num_devices() -> int` 17 | 18 | Return the number of available touch devices. 19 | 20 | .. ## pygame._sdl2.touch.get_num_devices ## 21 | 22 | .. function:: get_device 23 | 24 | | :sl:`get the a touch device id for a given index` 25 | | :sg:`get_device(index) -> touchid` 26 | 27 | :param int index: This number is at least 0 and less than the 28 | :func:`number of devices `. 29 | 30 | Return an integer id associated with the given ``index``. 31 | 32 | .. ## pygame._sdl2.touch.get_device ## 33 | 34 | .. function:: get_num_fingers 35 | 36 | | :sl:`the number of active fingers for a given touch device` 37 | | :sg:`get_num_fingers(touchid) -> int` 38 | 39 | Return the number of fingers active for the touch device 40 | whose id is `touchid`. 41 | 42 | .. ## pygame._sdl2.touch.get_num_fingers ## 43 | 44 | .. function:: get_finger 45 | 46 | | :sl:`get information about an active finger` 47 | | :sg:`get_finger(touchid, index) -> int` 48 | 49 | :param int touchid: The touch device id. 50 | :param int index: The index of the finger to return 51 | information about, between 0 and the 52 | :func:`number of active fingers `. 53 | 54 | Return a dict for the finger ``index`` active on ``touchid``. 55 | The dict contains these keys: 56 | 57 | :: 58 | 59 | id the id of the finger (an integer). 60 | x the normalized x position of the finger, between 0 and 1. 61 | y the normalized y position of the finger, between 0 and 1. 62 | pressure the amount of pressure applied by the finger, between 0 and 1. 63 | 64 | .. ## pygame._sdl2.touch.get_finger ## 65 | 66 | .. ## pygame._sdl2.touch ## 67 | -------------------------------------------------------------------------------- /src_c/doc/mouse_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMEMOUSE "pygame module to work with the mouse" 3 | #define DOC_PYGAMEMOUSEGETPRESSED "get_pressed() -> (button1, button2, button3)\nget the state of the mouse buttons" 4 | #define DOC_PYGAMEMOUSEGETPOS "get_pos() -> (x, y)\nget the mouse cursor position" 5 | #define DOC_PYGAMEMOUSEGETREL "get_rel() -> (x, y)\nget the amount of mouse movement" 6 | #define DOC_PYGAMEMOUSESETPOS "set_pos([x, y]) -> None\nset the mouse cursor position" 7 | #define DOC_PYGAMEMOUSESETVISIBLE "set_visible(bool) -> bool\nhide or show the mouse cursor" 8 | #define DOC_PYGAMEMOUSEGETVISIBLE "get_visible() -> bool\nget the current visibility state of the mouse cursor" 9 | #define DOC_PYGAMEMOUSEGETFOCUSED "get_focused() -> bool\ncheck if the display is receiving mouse input" 10 | #define DOC_PYGAMEMOUSESETCURSOR "set_cursor(size, hotspot, xormasks, andmasks) -> None\nset the image for the system mouse cursor" 11 | #define DOC_PYGAMEMOUSEGETCURSOR "get_cursor() -> (size, hotspot, xormasks, andmasks)\nget the image for the system mouse cursor" 12 | 13 | 14 | /* Docs in a comment... slightly easier to read. */ 15 | 16 | /* 17 | 18 | pygame.mouse 19 | pygame module to work with the mouse 20 | 21 | pygame.mouse.get_pressed 22 | get_pressed() -> (button1, button2, button3) 23 | get the state of the mouse buttons 24 | 25 | pygame.mouse.get_pos 26 | get_pos() -> (x, y) 27 | get the mouse cursor position 28 | 29 | pygame.mouse.get_rel 30 | get_rel() -> (x, y) 31 | get the amount of mouse movement 32 | 33 | pygame.mouse.set_pos 34 | set_pos([x, y]) -> None 35 | set the mouse cursor position 36 | 37 | pygame.mouse.set_visible 38 | set_visible(bool) -> bool 39 | hide or show the mouse cursor 40 | 41 | pygame.mouse.get_visible 42 | get_visible() -> bool 43 | get the current visibility state of the mouse cursor 44 | 45 | pygame.mouse.get_focused 46 | get_focused() -> bool 47 | check if the display is receiving mouse input 48 | 49 | pygame.mouse.set_cursor 50 | set_cursor(size, hotspot, xormasks, andmasks) -> None 51 | set the image for the system mouse cursor 52 | 53 | pygame.mouse.get_cursor 54 | get_cursor() -> (size, hotspot, xormasks, andmasks) 55 | get the image for the system mouse cursor 56 | 57 | */ -------------------------------------------------------------------------------- /docs/howto_release_pygame.txt: -------------------------------------------------------------------------------- 1 | 2 | Here are some steps for making a new release of pygame. So everyone knows what needs to be done to make a release work smoothly. 3 | 4 | 5 | == release steps == 6 | 7 | * declare next release as coming soon to developers, and mailing list. 8 | * declare feature freeze. 9 | * check with people on different platforms that tests are working. 10 | * ask platform people to sign off for their platform building, and testing ok. 11 | * WHATSNEW document is updated, with any changes. 12 | - hg log -r 'ancestors(default) - ancestors(release_1_9_1release)' 13 | * declare tar ball set, by making a branch in hg with the pygame version as rc1. eg 1.7.1.rc1 14 | - files to change version string: lib/version.py setup.py readme.html readme.rst 15 | * second round of testing goes on the new release branch. If any changes need to be made, all platforms need to be tested again and signed off. The pygame rc version is incremented and a new rc tar ball is released. eg 1.7.1.rc2. 16 | * if no changes needed to be made to the rc release, then the version is changed. eg from 1.7.1.rc1 to 1.7.1.release 17 | * a release tag is made. 18 | - hg tag release_1_9_1rc1 19 | * release person uploads final sources tarball to website. 20 | * documentation is remade, and uploaded to website, not before sources. 21 | * release binaries, not before sources. 22 | * announce to the mailing list, and the world that a new pygame is released. 23 | * the version of pygame is incremented by 1 and pre appended. eg 1.7.1 goes to 1.7.2.dev 24 | * For a full description of Python version numbering standards see: 25 | * https://www.python.org/dev/peps/pep-0440/ 26 | 27 | == Some definitions and explanations. == 28 | 29 | release person := person who is in charge of doing release. Should be one person. 30 | 31 | platform people := people responsible for each platform. eg macosx, windows, linux, freebsd etc. 32 | 33 | testing pygame := at least all the examples run ok. Also test major pygames, solarwolf, and pyddr work. Try to run other gamelets, and games that you know of. Try to test with different parts installed/uninstalled etc. 34 | 35 | rc releases := these are release candidates. If no changes need to be made, then the pygame version is changed and it can be released. 36 | 37 | pre releases := these are snap shots from hg. 38 | 39 | -------------------------------------------------------------------------------- /examples/dropevent.py: -------------------------------------------------------------------------------- 1 | import pygame as pg 2 | 3 | if pg.get_sdl_version() < (2, 0, 0): 4 | raise Exception("This example requires SDL2.") 5 | 6 | pg.init() 7 | 8 | 9 | def main(): 10 | 11 | Running = True 12 | surf = pg.display.set_mode((640, 480)) 13 | font = pg.font.SysFont("Arial", 24) 14 | clock = pg.time.Clock() 15 | 16 | spr_file_text = font.render("Feed me some file or image!", 1, (255, 255, 255)) 17 | spr_file_text_rect = spr_file_text.get_rect() 18 | spr_file_text_rect.center = surf.get_rect().center 19 | 20 | spr_file_image = None 21 | spr_file_image_rect = None 22 | 23 | while Running: 24 | for ev in pg.event.get(): 25 | if ev.type == pg.QUIT: 26 | Running = False 27 | elif ev.type == pg.DROPBEGIN: 28 | print(ev) 29 | print("File drop begin!") 30 | elif ev.type == pg.DROPCOMPLETE: 31 | print(ev) 32 | print("File drop complete!") 33 | elif ev.type == pg.DROPTEXT: 34 | print(ev) 35 | spr_file_text = font.render(ev.text, 1, (255, 255, 255)) 36 | spr_file_text_rect = spr_file_text.get_rect() 37 | spr_file_text_rect.center = surf.get_rect().center 38 | elif ev.type == pg.DROPFILE: 39 | print(ev) 40 | spr_file_text = font.render(ev.file, 1, (255, 255, 255)) 41 | spr_file_text_rect = spr_file_text.get_rect() 42 | spr_file_text_rect.center = surf.get_rect().center 43 | 44 | # Try to open the file if it's an image 45 | filetype = ev.file[-3:] 46 | if filetype in ["png", "bmp", "jpg"]: 47 | spr_file_image = pg.image.load(ev.file).convert() 48 | spr_file_image.set_alpha(127) 49 | spr_file_image_rect = spr_file_image.get_rect() 50 | spr_file_image_rect.center = surf.get_rect().center 51 | 52 | surf.fill((0, 0, 0)) 53 | surf.blit(spr_file_text, spr_file_text_rect) 54 | if spr_file_image: 55 | surf.blit(spr_file_image, spr_file_image_rect) 56 | 57 | pg.display.flip() 58 | clock.tick(30) 59 | 60 | pg.quit() 61 | 62 | 63 | if __name__ == "__main__": 64 | main() 65 | -------------------------------------------------------------------------------- /test/key_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pygame 3 | import pygame.key 4 | 5 | 6 | class KeyModuleTest(unittest.TestCase): 7 | @classmethod 8 | def setUpClass(cls): 9 | pygame.init() 10 | 11 | @classmethod 12 | def tearDownClass(cls): 13 | pygame.quit() 14 | 15 | def setUp(cls): 16 | # This makes sure pygame is always initialized before each test (in 17 | # case a test calls pygame.quit()). 18 | if not pygame.get_init(): 19 | pygame.init() 20 | 21 | def test_import(self): 22 | 'does it import' 23 | import pygame.key 24 | 25 | def todo_test_get_focused(self): 26 | 27 | # __doc__ (as of 2008-08-02) for pygame.key.get_focused: 28 | 29 | # pygame.key.get_focused(): return bool 30 | # true if the display is receiving keyboard input from the system 31 | # 32 | # This is true when the display window has keyboard focus from the 33 | # system. If the display needs to ensure it does not lose keyboard 34 | # focus, it can use pygame.event.set_grab() to grab all input. 35 | # 36 | 37 | self.fail() 38 | 39 | def test_get_pressed(self): 40 | states = pygame.key.get_pressed() 41 | self.assertEqual(states[pygame.K_RIGHT], 0) 42 | 43 | def test_name(self): 44 | self.assertEqual(pygame.key.name(pygame.K_RETURN), "return") 45 | self.assertEqual(pygame.key.name(pygame.K_0), "0") 46 | self.assertEqual(pygame.key.name(pygame.K_SPACE), "space") 47 | 48 | def test_set_and_get_mods(self): 49 | pygame.key.set_mods(pygame.KMOD_CTRL) 50 | self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL) 51 | 52 | pygame.key.set_mods(pygame.KMOD_ALT) 53 | self.assertEqual(pygame.key.get_mods(), pygame.KMOD_ALT) 54 | pygame.key.set_mods(pygame.KMOD_CTRL | pygame.KMOD_ALT) 55 | self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL | pygame.KMOD_ALT) 56 | 57 | def test_set_and_get_repeat(self): 58 | self.assertEqual(pygame.key.get_repeat(), (0, 0)) 59 | 60 | pygame.key.set_repeat(10, 15) 61 | self.assertEqual(pygame.key.get_repeat(), (10, 15)) 62 | 63 | pygame.key.set_repeat() 64 | self.assertEqual(pygame.key.get_repeat(), (0, 0)) 65 | 66 | 67 | if __name__ == '__main__': 68 | unittest.main() 69 | -------------------------------------------------------------------------------- /src_c/doc/time_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMETIME "pygame module for monitoring time" 3 | #define DOC_PYGAMETIMEGETTICKS "get_ticks() -> milliseconds\nget the time in milliseconds" 4 | #define DOC_PYGAMETIMEWAIT "wait(milliseconds) -> time\npause the program for an amount of time" 5 | #define DOC_PYGAMETIMEDELAY "delay(milliseconds) -> time\npause the program for an amount of time" 6 | #define DOC_PYGAMETIMESETTIMER "set_timer(eventid, milliseconds) -> None\nset_timer(eventid, milliseconds, once) -> None\nrepeatedly create an event on the event queue" 7 | #define DOC_PYGAMETIMECLOCK "Clock() -> Clock\ncreate an object to help track time" 8 | #define DOC_CLOCKTICK "tick(framerate=0) -> milliseconds\nupdate the clock" 9 | #define DOC_CLOCKTICKBUSYLOOP "tick_busy_loop(framerate=0) -> milliseconds\nupdate the clock" 10 | #define DOC_CLOCKGETTIME "get_time() -> milliseconds\ntime used in the previous tick" 11 | #define DOC_CLOCKGETRAWTIME "get_rawtime() -> milliseconds\nactual time used in the previous tick" 12 | #define DOC_CLOCKGETFPS "get_fps() -> float\ncompute the clock framerate" 13 | 14 | 15 | /* Docs in a comment... slightly easier to read. */ 16 | 17 | /* 18 | 19 | pygame.time 20 | pygame module for monitoring time 21 | 22 | pygame.time.get_ticks 23 | get_ticks() -> milliseconds 24 | get the time in milliseconds 25 | 26 | pygame.time.wait 27 | wait(milliseconds) -> time 28 | pause the program for an amount of time 29 | 30 | pygame.time.delay 31 | delay(milliseconds) -> time 32 | pause the program for an amount of time 33 | 34 | pygame.time.set_timer 35 | set_timer(eventid, milliseconds) -> None 36 | set_timer(eventid, milliseconds, once) -> None 37 | repeatedly create an event on the event queue 38 | 39 | pygame.time.Clock 40 | Clock() -> Clock 41 | create an object to help track time 42 | 43 | pygame.time.Clock.tick 44 | tick(framerate=0) -> milliseconds 45 | update the clock 46 | 47 | pygame.time.Clock.tick_busy_loop 48 | tick_busy_loop(framerate=0) -> milliseconds 49 | update the clock 50 | 51 | pygame.time.Clock.get_time 52 | get_time() -> milliseconds 53 | time used in the previous tick 54 | 55 | pygame.time.Clock.get_rawtime 56 | get_rawtime() -> milliseconds 57 | actual time used in the previous tick 58 | 59 | pygame.time.Clock.get_fps 60 | get_fps() -> float 61 | compute the clock framerate 62 | 63 | */ -------------------------------------------------------------------------------- /docs/reST/c_api/rect.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ****************************************** 6 | Class Rect API exported by pygame.rect 7 | ****************************************** 8 | 9 | src_c/rect.c 10 | ============ 11 | 12 | This extension module defines Python type :py:class:`pygame.Rect`. 13 | 14 | Header file: src_c/include/pygame.h 15 | 16 | .. c:type:: GAME_Rect 17 | 18 | .. c:member:: int x 19 | 20 | Horizontal position of the top-left corner. 21 | 22 | .. c:member:: int y 23 | 24 | Vertical position of the top-left corner. 25 | 26 | .. c:member:: int w 27 | 28 | Width. 29 | 30 | .. c:member:: int h 31 | 32 | Height. 33 | 34 | A rectangle at (*x*, *y*) and of size (*w*, *h*). 35 | 36 | SDL 2: equivalent to SDL_Rect. 37 | 38 | .. c:type:: pgRectObject 39 | 40 | .. c:member:: GAME_Rect r 41 | 42 | The Pygame rectangle type instance. 43 | 44 | .. c:var:: PyTypeObject *pgRect_Type 45 | 46 | The Pygame rectangle object type pygame.Rect. 47 | 48 | .. c:function:: GAME_Rect pgRect_AsRect(PyObject *obj) 49 | 50 | A macro to access the GAME_Rect field of a :py:class:`pygame.Rect` instance. 51 | 52 | .. c:function:: PyObject* pgRect_New(SDL_Rect *r) 53 | 54 | Return a new :py:class:`pygame.Rect` instance from the SDL_Rect *r*. 55 | On failure, raise a Python exception and return *NULL*. 56 | 57 | .. c:function:: PyObject* pgRect_New4(int x, int y, int w, int h) 58 | 59 | Return a new pygame.Rect instance with position (*x*, *y*) and 60 | size (*w*, *h*). 61 | On failure raise a Python exception and return *NULL*. 62 | 63 | .. c:function:: GAME_Rect* pgRect_FromObject(PyObject *obj, GAME_Rect *temp) 64 | 65 | Translate a Python rectangle representation as a Pygame :c:type:`GAME_Rect`. 66 | A rectangle can be a length 4 sequence integers (x, y, w, h), 67 | or a length 2 sequence of position (x, y) and size (w, h), 68 | or a length 1 tuple containing a rectangle representation, 69 | or have a method *rect* that returns a rectangle. 70 | Pass a pointer to a locally declared c:type:`GAME_Rect` as *temp*. 71 | Do not rely on this being filled in; use the function's return value instead. 72 | On success return a pointer to a :c:type:`GAME_Rect` representation 73 | of the rectangle. 74 | One failure may raise a Python exception before returning *NULL*. 75 | -------------------------------------------------------------------------------- /test/fixtures/fonts/PyGameMono-18-75dpi.bdf: -------------------------------------------------------------------------------- 1 | STARTFONT 2.1 2 | FONT -FontForge-PyGameMono-Medium-R-Normal--19-180-75-75-M-190-ISO10646-1 3 | SIZE 18 75 75 4 | FONTBOUNDINGBOX 15 17 0 0 5 | COMMENT "Generated by fontforge, http://fontforge.sourceforge.net" 6 | COMMENT "Created by Lenard Lindstrom,,, with FontForge 2.0 (http://fontforge.sf.net)" 7 | STARTPROPERTIES 29 8 | FOUNDRY "FontForge" 9 | FAMILY_NAME "PyGameMono" 10 | WEIGHT_NAME "Medium" 11 | SLANT "R" 12 | SETWIDTH_NAME "Normal" 13 | ADD_STYLE_NAME "" 14 | PIXEL_SIZE 19 15 | POINT_SIZE 180 16 | RESOLUTION_X 75 17 | RESOLUTION_Y 75 18 | SPACING "M" 19 | AVERAGE_WIDTH 190 20 | CHARSET_REGISTRY "ISO10646" 21 | CHARSET_ENCODING "1" 22 | FONTNAME_REGISTRY "" 23 | CHARSET_COLLECTIONS "ISO10646-1" 24 | FONT_NAME "PyGameMono" 25 | FACE_NAME "PyGame Mono" 26 | FONT_VERSION "001.000" 27 | FONT_ASCENT 15 28 | FONT_DESCENT 4 29 | UNDERLINE_POSITION -2 30 | UNDERLINE_THICKNESS 1 31 | RAW_ASCENT 800 32 | RAW_DESCENT 200 33 | RELATIVE_WEIGHT 50 34 | RELATIVE_SETWIDTH 50 35 | FIGURE_WIDTH -1 36 | AVG_UPPERCASE_WIDTH 190 37 | ENDPROPERTIES 38 | CHARS 5 39 | STARTCHAR .notdef 40 | ENCODING 0 41 | SWIDTH 1000 0 42 | DWIDTH 19 0 43 | BBX 15 15 0 0 44 | BITMAP 45 | FFFE 46 | FFFE 47 | FC7E 48 | F01E 49 | E00E 50 | C006 51 | C006 52 | C006 53 | C006 54 | C006 55 | E00E 56 | F01E 57 | FC7E 58 | FFFE 59 | FFFE 60 | ENDCHAR 61 | STARTCHAR A 62 | ENCODING 65 63 | SWIDTH 1000 0 64 | DWIDTH 19 0 65 | BBX 15 17 0 0 66 | BITMAP 67 | 0FE0 68 | 3FF8 69 | 783C 70 | F01E 71 | E00E 72 | E00E 73 | F01E 74 | F83E 75 | FFFE 76 | FFFE 77 | FC7E 78 | 701C 79 | 701C 80 | 600C 81 | 600C 82 | 4004 83 | 4004 84 | ENDCHAR 85 | STARTCHAR B 86 | ENCODING 66 87 | SWIDTH 1000 0 88 | DWIDTH 19 0 89 | BBX 15 15 0 0 90 | BITMAP 91 | FFF8 92 | 7FFC 93 | 780E 94 | 3006 95 | 3006 96 | 380E 97 | 3FF8 98 | 3FF8 99 | 3FF8 100 | 380E 101 | 3006 102 | 3006 103 | 7C1E 104 | 7FFC 105 | FFF8 106 | ENDCHAR 107 | STARTCHAR C 108 | ENCODING 67 109 | SWIDTH 1000 0 110 | DWIDTH 19 0 111 | BBX 15 15 0 0 112 | BITMAP 113 | 03E0 114 | 0FF8 115 | 3C1C 116 | 7806 117 | 7000 118 | E000 119 | E000 120 | E000 121 | E000 122 | E000 123 | 7000 124 | 7806 125 | 3C1C 126 | 0FF8 127 | 03E0 128 | ENDCHAR 129 | STARTCHAR u13079 130 | ENCODING 77945 131 | SWIDTH 1000 0 132 | DWIDTH 19 0 133 | BBX 15 7 0 4 134 | BITMAP 135 | 0FE0 136 | 3838 137 | 638C 138 | E38E 139 | 638C 140 | 3838 141 | 0FE0 142 | ENDCHAR 143 | ENDFONT 144 | -------------------------------------------------------------------------------- /docs/reST/c_api/mixer.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../common.txt 2 | 3 | .. highlight:: c 4 | 5 | ******************************** 6 | API exported by pygame.mixer 7 | ******************************** 8 | 9 | src_c/mixer.c 10 | ============= 11 | 12 | Python types and module startup/shutdown functions defined in the 13 | :py:mod:`pygame.mixer` extension module. 14 | 15 | Header file: src_c/include/pygame_mixer.h 16 | 17 | 18 | .. c:type:: pgSoundObject 19 | 20 | The :py:class:`pygame.mixer.Sound` instance C structure. 21 | 22 | .. c:var:: PyTypeObject *pgSound_Type 23 | 24 | The :py:class:`pygame.mixer.Sound` Python type. 25 | 26 | .. c:function:: PyObject* pgSound_New(Mix_Chunk *chunk) 27 | 28 | Return a new :py:class:`pygame.mixer.Sound` instance for the SDL mixer chunk *chunk*. 29 | On failure, raise a Python exception and return ``NULL``. 30 | 31 | .. c:function:: int pgSound_Check(PyObject \*obj) 32 | 33 | Return true if *obj* is an instance of type :c:data:`pgSound_Type`, 34 | but not a :c:data:`pgSound_Type` subclass instance. 35 | A macro. 36 | 37 | .. c:function:: Mix_Chunk* pgSound_AsChunk(PyObject *x) 38 | 39 | Return the SDL :c:type:`Mix_Chunk` struct associated with the 40 | :c:data:`pgSound_Type` instance *x*. 41 | A macro that does no ``NULL`` or Python type check on *x*. 42 | 43 | .. c:type:: pgChannelObject 44 | 45 | The :py:class:`pygame.mixer.Channel` instance C structure. 46 | 47 | .. c:var:: PyTypeObject *pgChannel_Type 48 | 49 | The :py:class:`pygame.mixer.Channel` Python type. 50 | 51 | .. c:function:: PyObject* pgChannel_New(int channelnum) 52 | 53 | Return a new :py:class:`pygame.mixer.Channel` instance for the SDL mixer 54 | channel *channelnum*. 55 | On failure, raise a Python exception and return ``NULL``. 56 | 57 | .. c:function:: int pgChannel_Check(PyObject \*obj) 58 | 59 | Return true if *obj* is an instance of type :c:data:`pgChannel_Type`, 60 | but not a :c:data:`pgChannel_Type` subclass instance. 61 | A macro. 62 | 63 | .. c:function:: Mix_Chunk \*pgChannel_AsInt(PyObject \*x) 64 | 65 | Return the SDL mixer music channel number associated with :c:type:`pgChannel_Type` instance *x*. 66 | A macro that does no ``NULL`` or Python type check on *x*. 67 | 68 | .. c:function:: void pgMixer_AutoInit(void) 69 | 70 | Initialize the :py:mod:`pygame.mixer` module and start the SDL mixer. 71 | 72 | .. c:function:: void pgMixer_AutoQuit(void) 73 | 74 | Stop all playing channels and close the SDL mixer. 75 | -------------------------------------------------------------------------------- /src_c/doc/key_doc.h: -------------------------------------------------------------------------------- 1 | /* Auto generated file: with makeref.py . Docs go in docs/reST/ref/ . */ 2 | #define DOC_PYGAMEKEY "pygame module to work with the keyboard" 3 | #define DOC_PYGAMEKEYGETFOCUSED "get_focused() -> bool\ntrue if the display is receiving keyboard input from the system" 4 | #define DOC_PYGAMEKEYGETPRESSED "get_pressed() -> bools\nget the state of all keyboard buttons" 5 | #define DOC_PYGAMEKEYGETMODS "get_mods() -> int\ndetermine which modifier keys are being held" 6 | #define DOC_PYGAMEKEYSETMODS "set_mods(int) -> None\ntemporarily set which modifier keys are pressed" 7 | #define DOC_PYGAMEKEYSETREPEAT "set_repeat() -> None\nset_repeat(delay) -> None\nset_repeat(delay, interval) -> None\ncontrol how held keys are repeated" 8 | #define DOC_PYGAMEKEYGETREPEAT "get_repeat() -> (delay, interval)\nsee how held keys are repeated" 9 | #define DOC_PYGAMEKEYNAME "name(key) -> string\nget the name of a key identifier" 10 | #define DOC_PYGAMEKEYSTARTTEXTINPUT "start_text_input() -> None\nstart handling IME compositions" 11 | #define DOC_PYGAMEKEYSTOPTEXTINPUT "stop_text_input() -> None\nstop handling IME compositions" 12 | #define DOC_PYGAMEKEYSETTEXTINPUTRECT "set_text_input_rect(Rect) -> None\ncontrols the position of the candidate list" 13 | 14 | 15 | /* Docs in a comment... slightly easier to read. */ 16 | 17 | /* 18 | 19 | pygame.key 20 | pygame module to work with the keyboard 21 | 22 | pygame.key.get_focused 23 | get_focused() -> bool 24 | true if the display is receiving keyboard input from the system 25 | 26 | pygame.key.get_pressed 27 | get_pressed() -> bools 28 | get the state of all keyboard buttons 29 | 30 | pygame.key.get_mods 31 | get_mods() -> int 32 | determine which modifier keys are being held 33 | 34 | pygame.key.set_mods 35 | set_mods(int) -> None 36 | temporarily set which modifier keys are pressed 37 | 38 | pygame.key.set_repeat 39 | set_repeat() -> None 40 | set_repeat(delay) -> None 41 | set_repeat(delay, interval) -> None 42 | control how held keys are repeated 43 | 44 | pygame.key.get_repeat 45 | get_repeat() -> (delay, interval) 46 | see how held keys are repeated 47 | 48 | pygame.key.name 49 | name(key) -> string 50 | get the name of a key identifier 51 | 52 | pygame.key.start_text_input 53 | start_text_input() -> None 54 | start handling IME compositions 55 | 56 | pygame.key.stop_text_input 57 | stop_text_input() -> None 58 | stop handling IME compositions 59 | 60 | pygame.key.set_text_input_rect 61 | set_text_input_rect(Rect) -> None 62 | controls the position of the candidate list 63 | 64 | */ -------------------------------------------------------------------------------- /src_py/pkgdata.py: -------------------------------------------------------------------------------- 1 | """ 2 | pkgdata is a simple, extensible way for a package to acquire data file 3 | resources. 4 | 5 | The getResource function is equivalent to the standard idioms, such as 6 | the following minimal implementation: 7 | 8 | import sys, os 9 | 10 | def getResource(identifier, pkgname=__name__): 11 | pkgpath = os.path.dirname(sys.modules[pkgname].__file__) 12 | path = os.path.join(pkgpath, identifier) 13 | return file(os.path.normpath(path), mode='rb') 14 | 15 | When a __loader__ is present on the module given by __name__, it will defer 16 | getResource to its get_data implementation and return it as a file-like 17 | object (such as StringIO). 18 | """ 19 | 20 | __all__ = ['getResource'] 21 | import sys 22 | import os 23 | from pygame.compat import get_BytesIO 24 | BytesIO = get_BytesIO() 25 | 26 | try: 27 | from pkg_resources import resource_stream, resource_exists 28 | except ImportError: 29 | def resource_exists(package_or_requirement, resource_name): 30 | return False 31 | def resource_stream(package_of_requirement, resource_name): 32 | raise NotImplementedError 33 | 34 | def getResource(identifier, pkgname=__name__): 35 | """ 36 | Acquire a readable object for a given package name and identifier. 37 | An IOError will be raised if the resource can not be found. 38 | 39 | For example: 40 | mydata = getResource('mypkgdata.jpg').read() 41 | 42 | Note that the package name must be fully qualified, if given, such 43 | that it would be found in sys.modules. 44 | 45 | In some cases, getResource will return a real file object. In that 46 | case, it may be useful to use its name attribute to get the path 47 | rather than use it as a file-like object. For example, you may 48 | be handing data off to a C API. 49 | """ 50 | if resource_exists(pkgname, identifier): 51 | return resource_stream(pkgname, identifier) 52 | 53 | mod = sys.modules[pkgname] 54 | fn = getattr(mod, '__file__', None) 55 | if fn is None: 56 | raise IOError("%s has no __file__!" % repr(mod)) 57 | path = os.path.join(os.path.dirname(fn), identifier) 58 | if sys.version_info < (3, 3): 59 | loader = getattr(mod, '__loader__', None) 60 | if loader is not None: 61 | try: 62 | data = loader.get_data(path) 63 | except IOError: 64 | pass 65 | else: 66 | return BytesIO(data) 67 | return open(os.path.normpath(path), 'rb') 68 | -------------------------------------------------------------------------------- /src_c/include/pygame_mixer.h: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2000-2001 Pete Shinners 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Pete Shinners 20 | pete@shinners.org 21 | */ 22 | 23 | #ifndef PGMIXER_H 24 | #define PGMIXER_H 25 | 26 | #include 27 | #include 28 | 29 | #include "pgcompat.h" 30 | 31 | struct Mix_Chunk; 32 | 33 | typedef struct { 34 | PyObject_HEAD 35 | Mix_Chunk *chunk; 36 | Uint8 *mem; 37 | PyObject *weakreflist; 38 | } pgSoundObject; 39 | 40 | typedef struct { 41 | PyObject_HEAD 42 | int chan; 43 | } pgChannelObject; 44 | 45 | #define pgSound_AsChunk(x) (((pgSoundObject*)x)->chunk) 46 | #define pgChannel_AsInt(x) (((pgChannelObject*)x)->chan) 47 | 48 | #include "pgimport.h" 49 | 50 | #ifndef PYGAMEAPI_MIXER_INTERNAL 51 | 52 | PYGAMEAPI_DEFINE_SLOTS(mixer); 53 | 54 | #define pgSound_Type (*(PyTypeObject*) \ 55 | PYGAMEAPI_GET_SLOT(mixer, 0)) 56 | 57 | #define pgSound_Check(x) ((x)->ob_type == &pgSound_Type) 58 | 59 | #define pgSound_New (*(PyObject*(*)(Mix_Chunk*)) \ 60 | PYGAMEAPI_GET_SLOT(mixer, 1)) 61 | 62 | #define pgSound_Play (*(PyObject*(*)(PyObject*, PyObject*)) \ 63 | PYGAMEAPI_GET_SLOT(mixer, 2)) 64 | 65 | #define pgChannel_Type (*(PyTypeObject*) \ 66 | PYGAMEAPI_GET_SLOT(mixer, 3)) 67 | #define pgChannel_Check(x) ((x)->ob_type == &pgChannel_Type) 68 | 69 | #define pgChannel_New (*(PyObject*(*)(int)) \ 70 | PYGAMEAPI_GET_SLOT(mixer, 4)) 71 | 72 | #define pgMixer_AutoInit (*(PyObject*(*)(PyObject*, PyObject*)) \ 73 | PYGAMEAPI_GET_SLOT(mixer, 5)) 74 | 75 | #define pgMixer_AutoQuit (*(void(*)(void)) \ 76 | PYGAMEAPI_GET_SLOT(mixer, 6)) 77 | 78 | #define import_pygame_mixer() _IMPORT_PYGAME_MODULE(mixer) 79 | 80 | #endif /* PYGAMEAPI_MIXER_INTERNAL */ 81 | 82 | #endif /* ~PGMIXER_H */ 83 | -------------------------------------------------------------------------------- /src_c/scrap_mac.c: -------------------------------------------------------------------------------- 1 | /* 2 | pygame - Python Game Library 3 | Copyright (C) 2006, 2007 Rene Dudfield, Marcus von Appen 4 | 5 | Originally written and put in the public domain by Sam Lantinga. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Library General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Library General Public License for more details. 16 | 17 | You should have received a copy of the GNU Library General Public 18 | License along with this library; if not, write to the Free 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | static PyObject * 23 | mac_scrap_call(char *name, PyObject *args) 24 | { 25 | static PyObject *mac_scrap_module = NULL; 26 | PyObject *method; 27 | PyObject *result; 28 | 29 | if (!mac_scrap_module) 30 | mac_scrap_module = PyImport_ImportModule("pygame.sdlmain_osx"); 31 | if (!mac_scrap_module) 32 | return NULL; 33 | 34 | method = PyObject_GetAttrString(mac_scrap_module, name); 35 | if (!method) 36 | return NULL; 37 | result = PyObject_CallObject(method, args); 38 | Py_DECREF(method); 39 | return result; 40 | } 41 | 42 | static PyObject * 43 | _scrap_init(PyObject *self, PyObject *args) 44 | { 45 | return mac_scrap_call("ScrapInit", args); 46 | } 47 | 48 | static PyObject * 49 | _scrap_get_scrap(PyObject *self, PyObject *args) 50 | { 51 | return mac_scrap_call("ScrapGet", args); 52 | } 53 | 54 | static PyObject * 55 | _scrap_put_scrap(PyObject *self, PyObject *args) 56 | { 57 | return mac_scrap_call("ScrapPut", args); 58 | } 59 | 60 | static PyObject * 61 | _scrap_lost_scrap(PyObject *self, PyObject *args) 62 | { 63 | return mac_scrap_call("ScrapLost", args); 64 | } 65 | 66 | static PyObject * 67 | _scrap_get_types(PyObject *self, PyObject *args) 68 | { 69 | return mac_scrap_call("ScrapGetTypes", args); 70 | } 71 | 72 | static PyObject * 73 | _scrap_contains(PyObject *self, PyObject *args) 74 | { 75 | return mac_scrap_call("ScrapContains", args); 76 | } 77 | 78 | static PyObject * 79 | _scrap_set_mode(PyObject *self, PyObject *args) 80 | { 81 | return mac_scrap_call("ScrapSetMode", args); 82 | } 83 | -------------------------------------------------------------------------------- /src_c/cython/pygame/_sdl2/audio.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | # 3 | 4 | from sdl2 cimport * 5 | 6 | cdef extern from "SDL.h" nogil: 7 | # https://wiki.libsdl.org/SDL_OpenAudioDevice 8 | # https://wiki.libsdl.org/SDL_CloseAudioDevice 9 | # https://wiki.libsdl.org/SDL_AudioSpec 10 | # https://wiki.libsdl.org/SDL_AudioFormat 11 | 12 | ctypedef Uint32 SDL_AudioDeviceID 13 | ctypedef Uint16 SDL_AudioFormat 14 | ctypedef void (*SDL_AudioCallback)(void *userdata, Uint8 *stream, int len) 15 | 16 | ctypedef struct SDL_AudioSpec: 17 | int freq 18 | SDL_AudioFormat format 19 | Uint8 channels 20 | Uint8 silence 21 | Uint16 samples 22 | Uint16 padding 23 | Uint32 size 24 | SDL_AudioCallback callback 25 | void *userdata 26 | 27 | int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) 28 | 29 | int SDL_GetNumAudioDevices(int iscapture) 30 | 31 | const char *SDL_GetAudioDeviceName(int index, int iscapture) 32 | 33 | SDL_AudioDeviceID SDL_OpenAudioDevice(const char *device, int iscapture, const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, int allowed_changes) 34 | 35 | cdef int _SDL_AUDIO_ALLOW_FREQUENCY_CHANGE "SDL_AUDIO_ALLOW_FREQUENCY_CHANGE" 36 | cdef int _SDL_AUDIO_ALLOW_FORMAT_CHANGE "SDL_AUDIO_ALLOW_FORMAT_CHANGE" 37 | cdef int _SDL_AUDIO_ALLOW_CHANNELS_CHANGE "SDL_AUDIO_ALLOW_CHANNELS_CHANGE" 38 | cdef int _SDL_AUDIO_ALLOW_ANY_CHANGE "SDL_AUDIO_ALLOW_ANY_CHANGE" 39 | 40 | 41 | # https://wiki.libsdl.org/SDL_PauseAudioDevice 42 | void SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on) 43 | void SDL_CloseAudioDevice(SDL_AudioDeviceID dev) 44 | 45 | cdef Uint16 _AUDIO_U8 "AUDIO_U8" 46 | cdef Uint16 _AUDIO_S8 "AUDIO_S8" 47 | cdef Uint16 _AUDIO_U16LSB "AUDIO_U16LSB" 48 | cdef Uint16 _AUDIO_S16LSB "AUDIO_S16LSB" 49 | cdef Uint16 _AUDIO_U16MSB "AUDIO_U16MSB" 50 | cdef Uint16 _AUDIO_S16MSB "AUDIO_S16MSB" 51 | cdef Uint16 _AUDIO_U16 "AUDIO_U16" 52 | cdef Uint16 _AUDIO_S16 "AUDIO_S16" 53 | cdef Uint16 _AUDIO_S32LSB "AUDIO_S32LSB" 54 | cdef Uint16 _AUDIO_S32MSB "AUDIO_S32MSB" 55 | cdef Uint16 _AUDIO_S32 "AUDIO_S32" 56 | cdef Uint16 _AUDIO_F32LSB "AUDIO_F32LSB" 57 | cdef Uint16 _AUDIO_F32MSB "AUDIO_F32MSB" 58 | cdef Uint16 _AUDIO_F32 "AUDIO_F32" 59 | 60 | cdef class AudioDevice: 61 | cdef SDL_AudioDeviceID _deviceid 62 | cdef SDL_AudioSpec desired 63 | cdef SDL_AudioSpec obtained 64 | cdef int _iscapture 65 | cdef object _callback 66 | cdef object _devicename 67 | -------------------------------------------------------------------------------- /src_py/_camera_opencv_highgui.py: -------------------------------------------------------------------------------- 1 | 2 | import pygame 3 | import numpy 4 | 5 | import opencv 6 | #this is important for capturing/displaying images 7 | from opencv import highgui 8 | 9 | 10 | 11 | def list_cameras(): 12 | """ 13 | """ 14 | # -1 for opencv means get any of them. 15 | return [-1] 16 | 17 | def init(): 18 | pass 19 | 20 | def quit(): 21 | pass 22 | 23 | 24 | class Camera: 25 | 26 | def __init__(self, device = 0, size = (640,480), mode = "RGB"): 27 | """ 28 | """ 29 | self.camera = highgui.cvCreateCameraCapture(device) 30 | if not self.camera: 31 | raise ValueError ("Could not open camera. Sorry.") 32 | 33 | 34 | def set_controls(self, **kwargs): 35 | """ 36 | """ 37 | 38 | 39 | def set_resolution(self, width, height): 40 | """Sets the capture resolution. (without dialog) 41 | """ 42 | # nothing to do here. 43 | pass 44 | def query_image(self): 45 | return True 46 | 47 | def stop(self): 48 | pass 49 | 50 | def start(self): 51 | # do nothing here... since the camera is already open. 52 | pass 53 | 54 | def get_buffer(self): 55 | """Returns a string containing the raw pixel data. 56 | """ 57 | return self.get_surface().get_buffer() 58 | 59 | def get_image(self, dest_surf = None): 60 | return self.get_surface(dest_surf) 61 | 62 | def get_surface(self, dest_surf = None): 63 | camera = self.camera 64 | 65 | im = highgui.cvQueryFrame(camera) 66 | #convert Ipl image to PIL image 67 | #print type(im) 68 | if im: 69 | xx = opencv.adaptors.Ipl2NumPy(im) 70 | #print type(xx) 71 | #print xx.iscontiguous() 72 | #print dir(xx) 73 | #print xx.shape 74 | xxx = numpy.reshape(xx, (numpy.product(xx.shape),)) 75 | 76 | if xx.shape[2] != 3: 77 | raise ValueError("not sure what to do about this size") 78 | 79 | pg_img = pygame.image.frombuffer(xxx, (xx.shape[1],xx.shape[0]), "RGB") 80 | 81 | # if there is a destination surface given, we blit onto that. 82 | if dest_surf: 83 | dest_surf.blit(pg_img, (0,0)) 84 | return dest_surf 85 | #return pg_img 86 | 87 | 88 | 89 | if __name__ == "__main__": 90 | 91 | # try and use this camera stuff with the pygame camera example. 92 | import pygame.examples.camera 93 | 94 | pygame.camera.Camera = Camera 95 | pygame.camera.list_cameras = list_cameras 96 | pygame.examples.camera.main() 97 | 98 | 99 | -------------------------------------------------------------------------------- /test/util/svn_log_to_whatsnew.py: -------------------------------------------------------------------------------- 1 | """ 2 | reads a svn log, and generates output for the WHATSNEW. 3 | 4 | Should still edit the WHATSNEW to make it more human readable. 5 | 6 | 7 | 8 | """ 9 | import sys,os,glob,textwrap 10 | lines = sys.stdin.readlines() 11 | 12 | out= [] 13 | state = "none" 14 | for l in lines: 15 | if "-------" in l: 16 | state = "revision date line" 17 | continue 18 | if state == "revision date line": 19 | parts = l.split("|") 20 | out.append({}) 21 | out[-1]['revision'] = parts[0].strip().replace("r", "") 22 | out[-1]['username'] = parts[1].strip() 23 | out[-1]['date'] = parts[2].strip() 24 | date_parts = parts[2].strip().split("(") 25 | out[-1]['day_month_year'] = day, month, year = date_parts[1][:-1].split(",")[1].split() 26 | 27 | 28 | out[-1]['message'] = "" 29 | state = "message" 30 | elif state == "message": 31 | out[-1]['message'] += l + "\n" 32 | 33 | import pprint 34 | #pprint.pprint(out) 35 | 36 | 37 | # group revisions on the same day into one block. 38 | previous = [] 39 | for o in (out + [None]): 40 | 41 | if o and previous and o['day_month_year'] == previous[-1]['day_month_year']: 42 | previous.append(o) 43 | continue 44 | else: 45 | 46 | if not previous: 47 | previous.append(o) 48 | continue 49 | 50 | day, month, year = previous[-1]['day_month_year'] 51 | revs = [int(p['revision']) for p in previous] 52 | if len(revs) == 1: 53 | revisions = revs[0] 54 | else: 55 | revisions = "%s-%s" % (min(revs), max(revs)) 56 | 57 | print "[SVN %s] %s %s, %s" % (revisions, month, day, year) 58 | 59 | # uniqify the messages, keep order. 60 | messages = [p['message'][2:] for p in previous] 61 | unique_messages = [] 62 | for m in messages: 63 | if m not in unique_messages: 64 | unique_messages.append(m) 65 | 66 | 67 | 68 | for msg in reversed(unique_messages): 69 | #msg = p['message'][2:] 70 | 71 | for i in range(4): 72 | if msg and msg[-1] == "\n": 73 | msg = msg[:-1] 74 | 75 | lines = textwrap.wrap(msg, 74) 76 | if lines: 77 | if lines[-1][-1:] != ".": 78 | lines[-1] += "." 79 | 80 | for i, l in enumerate(lines): 81 | if i == 0: 82 | print " %s" % (l[:1].upper() + l[1:]) 83 | if i != 0: 84 | print " %s" % l 85 | 86 | print "" 87 | 88 | previous = [o] 89 | 90 | 91 | 92 | 93 | --------------------------------------------------------------------------------