Giter Site home page Giter Site logo

lordmauve / pgzero Goto Github PK

View Code? Open in Web Editor NEW
512.0 29.0 189.0 3.72 MB

A zero-boilerplate games programming framework for Python 3, based on Pygame.

Home Page: https://pygame-zero.readthedocs.io/

License: GNU Lesser General Public License v3.0

Python 100.00%
pygame education game-framework python3 python-game-development

pgzero's Introduction

GitHub Test Status

PyPI

PyPI - Downloads

Read the Docs

Pygame Zero

A zero-boilerplate games programming framework for Python 3, based on Pygame.

Some examples

Pygame Zero consists of a runner pgzrun that will run a Pygame Zero script with a full game loop and a range of useful builtins.

Here's some of the neat stuff you can do. Note that each of these is a self-contained script. There's no need for any imports or anything else in the file.

Draw graphics (assuming there's a file like images/dog.png or images/dog.jpg):

def draw():
    screen.clear()
    screen.blit('dog', (10, 50))

Play the sound sounds/eep.wav when you click the mouse:

def on_mouse_down():
    sounds.eep.play()

Draw an "actor" object (with the sprite images/alien.png) that moves across the screen:

alien = Actor('alien')
alien.pos = 10, 10

def draw():
    screen.clear()
    alien.draw()

def update():
    alien.x += 1
    if alien.left > WIDTH:
        alien.right = 0

Installation

See installation instructions.

Documentation

The full documentation is at http://pygame-zero.readthedocs.org/.

Read the tutorial at http://pygame-zero.readthedocs.org/en/latest/introduction.html for a taste of the other things that Pygame Zero can do.

Contributing

The project is hosted on Github:

https://github.com/lordmauve/pgzero

If you want to help out with the development of Pygame Zero, you can find some instructions on setting up a development version in the docs:

http://pygame-zero.readthedocs.org/en/latest/contributing.html

pgzero's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pgzero's Issues

numpy "bug" - reproduced when running examples/basic/ptext.py (if versions the same I suppose)

Originally reported by: Steve Clement (Bitbucket: SteveClement, GitHub: SteveClement)


Dear all,

When you run ptext.py example you get this error:

TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'

Not sure how safe my fix is, but it works. Should I do a pull request?
Also not sure there are other locations where you need to do unsafe casts…

It can be fixed as follows

#!patch

--- /usr/local/lib/python3.5/site-packages/pgzero/ptext.py.orig	2016-12-02 16:05:29.000000000 +0100
+++ /usr/local/lib/python3.5/site-packages/pgzero/ptext.py	2016-12-02 16:04:50.000000000 +0100
@@ -201,7 +201,8 @@
 			lineheight=lineheight, cache=cache)
 		surf = surf0.copy()
 		array = pygame.surfarray.pixels_alpha(surf)
-		array *= alpha
+		import numpy
+		numpy.multiply(array, alpha, out=array, casting="unsafe")
 	elif spx is not None:
 		surf0 = getsurf(text, fontname, fontsize, width, widthem, color=color,
 			background=(0,0,0,0), antialias=antialias, gcolor=gcolor, align=align,
@@ -255,8 +256,8 @@
 			for lsurf in lsurfs:
 				array = pygame.surfarray.pixels3d(lsurf)
 				for j in (0, 1, 2):
-					array[:,:,j] *= 1.0 - m
-					array[:,:,j] += m * gcolor[j]
+					numpy.multiply(array[:,:,j], 1.0 - m, out=array[:,:,j], casting="unsafe")
+					numpy.multiply(array[:,:,j], m * gcolor[j], out=array[:,:,j], casting="unsafe")
 				del array

 		if len(lsurfs) == 1 and gcolor is None:

My versions

  • numpy==1.11.2
  • pgzero==1.1
  • pygame==1.9.2b8
  • Python 3.5.2
  • Darwin Steves-iMac.local 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64 (MacOS Sierra)

Run output

#!bash

~/Desktop/code/pgzeroBB/examples/basic  ☿ 179@default  pgzrun ptext.py
Traceback (most recent call last):
  File "/usr/local/bin/pgzrun", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/site-packages/pgzero/runner.py", line 89, in main
    PGZeroGame(mod).run()
  File "/usr/local/lib/python3.5/site-packages/pgzero/game.py", line 219, in run
    draw()
  File "ptext.py", line 115, in draw
    gcolor="#442200"
  File "/usr/local/lib/python3.5/site-packages/pgzero/screen.py", line 61, in text
    ptext.draw(*args, surf=self._surf, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pgzero/ptext.py", line 320, in draw
    ocolor, owidth, scolor, shadow, gcolor, alpha, align, lineheight, angle, cache)
  File "/usr/local/lib/python3.5/site-packages/pgzero/ptext.py", line 229, in getsurf
    lineheight=lineheight, cache=cache)
  File "/usr/local/lib/python3.5/site-packages/pgzero/ptext.py", line 258, in getsurf
    array[:,:,j] *= 1.0 - m
TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'

No support for framebuffer rendering in pygamezero ?

Originally reported by: [email protected] (Bitbucket: bcopy, GitHub: bcopy)


On touchscreens, Pygame can render directly to framebuffer.
However, the Pygamezero runner seems to have a problem with screen setup :

File "/usr/local/lib/python3.4/dist-packages/pgzero/runner.py", line 81, in main
pygame.display.set_mode((100, 100), DISPLAY_FLAGS)
pygame.error: Couldn't set console screen info

Setting the usual SDL enviroment variables to point Pygame to the framebuffer in the usual way does not work for Pygamezero :

pgtest.py

#!python
WIDTH = 300
HEIGHT = 300
def draw():
    screen.fill((128, 0, 0))

Running the above script (even as sudo) with :

#!shell
SDL_VIDEODRIVER=fbcon SDL_FBDEV=/dev/fb0 pgzrun pgztest.py 

Gives the following :

#!shell
Traceback (most recent call last):
  File "/usr/local/bin/pgzrun", line 9, in <module>
    load_entry_point('pgzero==1.1', 'console_scripts', 'pgzrun')()
  File "/usr/local/lib/python3.4/dist-packages/pgzero/runner.py", line 81, in main
    pygame.display.set_mode((100, 100), DISPLAY_FLAGS)
pygame.error: Couldn't set console screen info


I was wondering whether one could use pygamezero without the pgzrun runner utility (and perhaps bypass this forceful mode setting ?).


music object

Originally reported by: David Bern (Bitbucket: drobban, GitHub: drobban)


Trying to use music object to play music.
This is the Traceback I get when trying to pgzrun the examples/basic/music.py, identical traceback when trying to use music in other projects.

Traceback (most recent call last):
File "/usr/local/bin/pgzrun", line 9, in
load_entry_point('pgzero==1.1rc1', 'console_scripts', 'pgzrun')()
File "/usr/local/lib/python3.4/site-packages/pgzero/runner.py", line 42, in main
PGZeroGame(mod).run()
File "/usr/local/lib/python3.4/site-packages/pgzero/game.py", line 195, in run
self.dispatch_event(event)
File "/usr/local/lib/python3.4/site-packages/pgzero/game.py", line 131, in dispatch_event
handler(event)
File "/usr/local/lib/python3.4/site-packages/pgzero/game.py", line 125, in
return lambda event: handler(**prep_args(event))
File "music.py", line 28, in on_mouse_down
music.play(t)
File "/usr/local/lib/python3.4/site-packages/pgzero/music.py", line 51, in play
_play(name, -1)
File "/usr/local/lib/python3.4/site-packages/pgzero/music.py", line 40, in _play
_music.load(path)
pygame.error


actor.py : image and rect

Originally reported by: William Bell (Bitbucket: williamhbell, GitHub: williamhbell)


Hi,

In the current version of pgzero in PyPI, the Actor class (actor.py) contains:

    @property
    def image(self):
        return self._image_name

    @image.setter
    def image(self, image):
        self._image_name = image
        p = self.pos
        self._surf = loaders.images.load(image)
        self.width, self.height = self._surf.get_size()
        self._calc_anchor()
        self.pos = p

However, image is already a public data member of the class. The value of "image" is set in the constructor, whereas the value of self._image_name is not. Would it be possible to fix this and use __image_name in the constructor?

The Actor class is quite handy. However, it does not expose the image objects or their rect objects. Therefore, putting together a collision using Actors seems a bit messy. Would it be possible to expose the rect objects? Or perhaps handle collisions between actors as a function? (I am very happy to contribute code, since I would like to use this library to teach some Python programming in the short term future.)

Thanks and best regards,

Will


Keyboard issues

Originally reported by: Sean McManus (Bitbucket: sean2015, GitHub: sean2015)


Hello. There are some discrepancies with the keyboard documentation here:
http://pygame-zero.readthedocs.org/en/latest/hooks.html#buttons-and-keys

DELETE doesn't appear to work.
Letters require lower case

I'm also experiencing some strange behaviour with some letter keys. For example:

This works:
if keyboard.RIGHT:
x += 1
elif keyboard.LEFT:
x -= 1
if keyboard.UP:
y -= 1
elif keyboard.DOWN:
y += 1

But the following results in a strange jumping motion (the sprite goes up when you press u, but falls down again as if there were gravity implemented, so it acts as if d were being pressed too).
if keyboard.RIGHT:
x += 1
elif keyboard.LEFT:
x -= 1
elif keyboard.u:
y -= 1
elif keyboard.d:
y += 1

I've seen a similar issue with take/drop game code where pressing a letter key take makes the player take and immediately drop an object (it acts as if two keys had been pressed), but using F1/F2 doesn't.

This is a small snippet from a long (350+ lines) program, so I can't rule out other dependencies. But I see this behaviour change when this is the only thing I change in the program. I wonder if there if the keyboard code is returning True when it shouldn't?


10 classic games

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


The Raspberry Pi foundation would like a collection of 10 example games written with Pygame Zero to form the basis of course material. These games need to be licensed for possible commercial use by the Raspberry Pi foundation as well as CC-BY-SA, under which they will be included in the Pygame Zero distribution.

The games need to be written as clearly as possible, with plenty of docstrings and comments, so that the way they work is obvious. However any working implementations of games would be gratefully received, and can be improved afterwards.

Below is a suggested list of games that could be created as example games, as well as the contributors who have made an offer to complete these games. This list is not exhaustive, but large, open-ended game projects are much less suitable than simple reimplementations of classic games.


Support anchor offset for Actor class (enables rotation)

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


The Actor class can be positioned by assigning to pos. pos currently refers to the top-left of the sprite. We should support an anchor parameter that allows pos to refer to the anchor position of the sprite.

This would also open up the Actor class to rotation around this anchor.

Open question: should the anchor default to the top-left for backwards compatibility? Or the center, which would be more suitable if we later add rotation?


Can't run asteroids example

Originally reported by: Nigel Morse (Bitbucket: musmuris, GitHub: musmuris)


Not sure what I'm doing wrong - but if I get the examples I get an error trying to run Asteroids:

#!

C:\dev\pygamezero\examples\asteroids>pgzrun main.py
Traceback (most recent call last):
  File "C:\Program Files\Python35\Scripts\pgzrun-script.py", line 9, in <module>
    load_entry_point('pgzero==1.1', 'console_scripts', 'pgzrun')()
  File "c:\program files\python35\lib\site-packages\pgzero\runner.py", line 88, in main
    exec(code, mod.__dict__)
  File "main.py", line 7, in <module>
    from space import create_star_scape
ImportError: No module named 'space'

Thumbs.db on windows

Originally reported by: Michael Grazebrook (Bitbucket: mgrazebrook, GitHub: mgrazebrook)


Thumbs.db (note the capital) is created invisibly on Windows when you view a folder in the file manager. Because it has a capital, pgzero rejects it:

pgzero.loaders.InvalidCase

It's hard for a beginner to debug as the file isn't visible in the file manager (or indeed using bash with 'ls' though 'ls -a' works).

Though to your credit the error message is excellent!


Problem in Introductory Tutorial

Originally reported by: David Ames (Bitbucket: amos1969, GitHub: amos1969)


Working through the initial Introductory Tutorial, when I get to the Handling Clicks section, add the code and run it (using pgzrun and python3 -m pgzero ...) the output from the print statements is hidden from the user. I see no output on the command line whatsoever (Linux(LMDE), Konsole, running with Python3.4 and Pygame 1.9.2a0).

Either the tutorial needs modifying in some way or a way not to suppress the print statement (and I assume the rest of the output to stdout or its' equivalent - errors will display (stderr?)) needs to be added.

Cheers

Dave Ames


test_keyboard.py fails

Originally reported by: Anonymous


When running tests, test_keyboard.py fails in the assert_warning context manager.

#!

/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/contextlib.py:66: in __exit__
    next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @contextmanager
    def assert_warning():
        with warnings.catch_warnings(record=True) as w:
            # warnings.simplefilter("always")
            yield
>       assert len(w) > 0, \
            "Expected a warning, but no warnings received."
E       AssertionError: Expected a warning, but no warnings received.
E       assert 0 > 0
E        +  where 0 = len([])

test/test_keyboard.py:16: AssertionError

Notes on the tutorial

Originally reported by: Andrew McCarthy (Bitbucket: a_mccarthy, GitHub: Unknown)


Some nit-picks on the tutorial that might confuse beginners:

  • The acceptable range for red/green/blue values is not given.

  • The difference between the draw() and update() functions is not described. Code works in either block.

  • While trying to click the alien, the mouse pointer is only visible when moving. (While testing on Raspberry Pi)

  • "(but the sound will play repeatedly)" is confusing - suggests sound will play in a loop. Perhaps remove this?

  • After the "refactor", the new set_alien_hurt() function has sound and image lines reversed. After adding the "clock.schedule..." the order is reversed back again.

  • The schedule_unique method accepts integers. Perhaps use 1 instead of 1.0, or maybe instead give a fractional value like 0.5 to demonstrate the precision available?


Poor error messages when handlers aren't defined to take the correct arguments

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


While we introspect the handlers at startup time, we do not compare their argument specs to the known argument specs of Pygame's event objects.

If a parameter is mispelled the error will only occur at the moment the event fires, and with an opaque traceback such as:

Traceback (most recent call last):                                          
  File "/home/mauve/.virtualenvs/pgzero/bin/pgzrun", line 9, in <module>       
    load_entry_point('pgzero==1.0beta1', 'console_scripts', 'pgzrun')()        
  File "/home/mauve/dev/pgzero/pgzero/runner.py", line 36, in main             
    PGZeroGame(mod).run()                                                      
  File "/home/mauve/dev/pgzero/pgzero/game.py", line 167, in run               
    self.dispatch_event(event)                                                 
  File "/home/mauve/dev/pgzero/pgzero/game.py", line 108, in dispatch_event    
    handler(event)                                                             
  File "/home/mauve/dev/pgzero/pgzero/game.py", line 103, in <lambda>          
    return lambda event: handler(**prep_args(event))                           
  File "/home/mauve/dev/pgzero/pgzero/game.py", line 102, in prep_args         
    return {name: get(event) for name, get in param_handlers}                  
  File "/home/mauve/dev/pgzero/pgzero/game.py", line 102, in <dictcomp>        
    return {name: get(event) for name, get in param_handlers}                  
AttributeError: 'Event' object has no attribute 'buttonz'  

We should fail fast in case of an error like this, with a more helpful error message.


Crash when pressing Ctrl + Menu Key

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


When I press Ctrl + Menu Key, Pygame Zero crashes with the traceback:

Traceback (most recent call last):                                          
  File "/home/mauve/.virtualenvs/pgzero/bin/pgzrun", line 9, in <module>       
    load_entry_point('pgzero==1.0.2', 'console_scripts', 'pgzrun')()           
  File "/home/mauve/.virtualenvs/pgzero/lib/python3.4/site-packages/pgzero/runner.py", line 38, in main
    PGZeroGame(mod).run()                                                      
  File "/home/mauve/.virtualenvs/pgzero/lib/python3.4/site-packages/pgzero/game.py", line 173, in run 
    self.dispatch_event(event)                                                 
  File "/home/mauve/.virtualenvs/pgzero/lib/python3.4/site-packages/pgzero/game.py", line 109, in dispatch_event
    handler(event)                                                             
  File "/home/mauve/.virtualenvs/pgzero/lib/python3.4/site-packages/pgzero/game.py", line 103, in <lambda>
    return lambda event: handler(**prep_args(event))                           
  File "/home/mauve/.virtualenvs/pgzero/lib/python3.4/site-packages/pgzero/game.py", line 102, in prep_args
    return {name: get(event) for name, get in param_handlers}                  
  File "/home/mauve/.virtualenvs/pgzero/lib/python3.4/site-packages/pgzero/game.py", line 102, in <dictcomp>
    return {name: get(event) for name, get in param_handlers}                  
  File "/home/mauve/.virtualenvs/pgzero/lib/python3.4/site-packages/pgzero/game.py", line 92, in <lambda>
    return lambda event: mapper(getter(event))                                 
  File "/usr/lib/python3.4/enum.py", line 222, in __call__                     
    return cls.__new__(cls, value)                                             
  File "/usr/lib/python3.4/enum.py", line 457, in __new__                      
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))           
ValueError: 314 is not a valid keys  

Feature request : Support for Scratch-style Actor-centric multithreading

Originally reported by: [email protected] (Bitbucket: bcopy, GitHub: bcopy)


It would be very useful to agree on a naming convention that would allow Actor-centric execution threads, similar to what is being done in scratch.

Young users focus primarily on what happens to an actor, but can't handle the concept of multi-threading in the UPDATE() method - Adopting a naming convention would help a lot.

Other features that would help the transition from Scratch :

  • Actor messaging (to exchange simple signals) and associated event handling
  • Actor rotation, zooming, flipping (c.f. currently open issues #3 and #36 )

Have the game exit wait on playing sounds

Originally reported by: Tim Golden (Bitbucket: TJG, GitHub: TJG)


At present if you play a "death" or "win" sound followed immediately by exit(), the sound cuts off so you effectively don't hear it. You can stick a time.sleep(1) etc. in there, but if feels awkward.

Obviously, playing sounds isn't the only thing which might want to wait; you might want a closing splash screen or some other animation.

I'm not sure whether the best thing is to stick with the time.sleep() solution, which has the merit of being obvious, to introduce some sort of on_game_exit event which is triggered from within update() but which, say, waits for sounds to play out. Or whether to make use of the sound endevent. Or something else.


Sprite sheet support with animated frames

Originally reported by: Sam Washburn (Bitbucket: p1xl, GitHub: p1xl)


Hi! My 8 year old son is using pgz to learn to program. It's kind of frustrating doing image animations; a lot of typing and data structures for him to wrap his little head around.

Any hope in having sprite sheet support?

He wants to make an actor "run", but him and I both get bogged down going into details that I think are above his head at this point.


Disallow assigning attributes on Rect class

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


Issue #11 "Cannot assign attributes on Rect object" was a bad idea.

I immediately hit a case where someone (@tjg) had written bat.centrex instead of bat.centerx - and this fails silently once again.

Now we have a spellchecker we could spellcheck this and fail with an appropriate error.

There's also a concern about incompatibility with Pygame itself - if users have been used to assigning attributes to Rect objects, it may cause confusion when using Rect objects from Pygame itself which do not allow this.


Spell checker

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


In #4, Dave was confused because his misnamed function was not being picked up by the Pygame Zero runtime.

To mitigate this danger, we could include a spell checker that identifies names in the module namespace, which look like misspellings of the names we expect. The spellchecker would emit warnings at startup time, but would not otherwise affect the program's behaviour.

The names we could spellcheck are a relatively small list, including:

  • draw update and the on_mouse_*, on_key_* hooks
  • Parameters names for those functions
  • TITLE, WIDTH, HEIGHT and ICON

There is a fairly succinct example code for a spellchecker here, which should be adapted to also catch:

  • Case problems
  • Missing underscores

Allow screen.blit() to accept an image name

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


In issue #28 I experimented with removing the magic name-based loading of images in Actor.

This was to reconcile the fact that there are currently two ways of loading/drawing images in Pygame Zero:

Actor('alien')

and

screen.blit(images.alien, ...)

when there should be just one. However removing the former approach appears to make the code less readable and beginner-friendly. Thus we should investigate the alternative approach, to use string image names in more places and thus improve consistency in this way, for example, allowing

screen.blit('alien', ...)

Add a way of invoking pgzrun on the current file from within Idle

Originally reported by: David Ames (Bitbucket: amos1969, GitHub: amos1969)


Hi

I think I mentioned this before. Most of the schools I have been in restrict access to the command line for "security" reasons, they also often prevent the running of .bat files, and other similar scripts for the same reason.

In addition the vast majority of schools use Idle as their Python IDE (anything more advanced tends to be overkill). In order to use pgzrun within a school environment it is therefore going to be necessary to create a way of running the current python file through the runner from within Idle. Is it possible to create a function of some kind which will invoke the runner on the current file, when it is run as a Python script (ie when F5 is pressed in Idle).

Something as simple as putting: pgzrun() as the first function call in the current file perhaps.

I hope that makes sense. As a relatively technically minded teacher I was unable to convince the technicians in school to allow me to use the command line, as they said it was a potential security issue.

Cheers


"holdenwebs" game ready for incorporation

Originally reported by: Steve Holden (Bitbucket: holdenweb, GitHub: holdenweb)


At the June 2015 London Python Dojo a team of five of us built this as a sample game.

Unfortunately I was absent for introductions, so I haven't yet credited the rest of the team.

I've tweaked it a bit since, and IMO it now represents a fair proposition to be incorporated as something that beginning programmers can play around with.

Take a look at https://github.com/holdenweb/holdenwebs and see if you agree. Feel free to change the name of the game if you would like.


Support high dpi (retina) displays

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


On high resolution displays, Pygame games designed for low dpi displays come out incredibly tiny. We should detect such displays and apply suitable scaling.

Pygame_sdl2 has some support for high dpi displays though it looks like this just returns a larger surface corresponding to the physical display. We would need to honour the WIDTH and HEIGHT attributes in the game and upscale before painting the screen.

This may be slow, so we could look at doing the upscaling in hardware (eg. with Pixel Buffer Objects or Buffer Object Streaming).


MIDI/Tone Generator

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


Pygame's sound system is good for playing pre-canned .wav files, but it would be nice to have notes and beeps to play with. The main factor in the choice between generated tones and MIDI notes is how easily we can provide the support in a cross-platform way. Most approaches to tone generation seem to require numpy, and MIDI needs software synth support which isn't common in modern OSes.

The Ubuntu python3-pygame package depends on numpy so this should be installed if our instructions were followed. The package only 'suggests' timidity, so MIDI support probably won't come as standard.

OS X doesn't seem to include a MIDI software synth for CoreMIDI and I can't find any details on how to get one. Our OS X install instructions are very hand-rolled, so could be updated to specify numpy.

I can't tell what the MIDI landscape is on Windows. Our Windows instructions currently specify a .msi. numpy support would be an extra download, which is hard to justify if it's only for an optional feature.


Change constructor of Actor to accept Surface, deprecate passing image name to load

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


Currently Actors are constructed by passing the name of a surface:

a = Actor('alien')

This is inconsistent with our other approaches to loading images using the images built-in. It also precludes passing generated surfaces for Actors.

We should change the API to prefer

a = Actor(images.alien)

and deprecate the passing of a string (and warn about the deprecation). Naturally we should change all the documentation and examples to follow this change.


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.