Posts

Showing posts from May, 2007

Making Pygames more easily runnable.

Image
There are a few things which would allow pygames to be run more easily. I had a little chat with Phil the other day about where pygame could be heading. So these are some of the things we talked about. In case anyone else is interested.

First though, the why. Why should pygames be easier to run? So all of the people making games can have their friends and family play them. So they can get more feedback about them. People like feedback - feedback is an engine which drives people to work on something for fun. They create things in a way, and want to show the world. Or sometimes people make things to just show their friends and family. Or their peers. However do you want opinionated, uneducated game players giving you feedback? Isn't a nice little community of game developers a worthwhile thing? I don't want to lose our nice little pygame community of artistic folks. People interested in making small games, rather than working on engines - and 3D MMORPG web browser…

Validating XML with a DTD and python.

Image
Below is a way to validate an XML file using python and an external DTD.

Are there any other ways to do XML DTD validation with python?

A DTD is one way of specifying how an XML should be formed - a schema for XML documents.


from xml.parsers.xmlproc import xmlproc
from xml.parsers.xmlproc import xmlval
from xml.parsers.xmlproc import xmldtd

def validate_xml(xml_filename, dtd_filename):
"""Validate a given XML file with a given external DTD.
If the XML file is not valid, an exception will be
printed with an error message.
"""
dtd = xmldtd.load_dtd(dtd_filename)
parser = xmlproc.XMLProcessor()
parser.set_application(xmlval.ValidatingApp(dtd, parser))
parser.dtd = dtd
parser.ent = dtd
parser.parse_resource(xml_filename)


if __name__ == "__main__":
import sys
xml_filename, dtd_filename = sys.argv[1], sys.argv[2]
validate_xml(xml_filename, dtd_filename)






Written by a Melbourne web developer. Available for your p…

Pygame weekly mini sprint 2007/05/30

These are my notes from this weeks pygame mini sprint.

Fixed some documentation. mask, scrap, font modules.

Fixed the mask.set_at get_at functions to raise a nice exception. Thanks piman!

surface.fill() now takes the same BLEND_ADD BLEND_SUB etc flags that
surface.blit() takes. Which makes fade to white, and fade to black
type operations simple and fast. Thanks Marcus!!

Added the GL_SWAP_CONTROL constant from SDL. Thanks Eyal Lotem!

Added the new blitters from Marcus. These speed up the blend functions
and the alpha blit function.

Added a -warnings flag to setup.py for extra warnings with gcc.

A fix from Marcus for the scrap module in X11.

DR0ID has been working on a new sprite module which has a number of features. Including support for layers, and blend modes. It's supposed to be quite quick, and automatically detect if dirty rectangles will be faster, or a full screen update. DR0ID wants to make it compatible with the pygame.sprite.RenderUpdates so that people…

Pretty print xml with python - indenting xml.

Image
Here's a fairly simple way to pretty print xml with python. By pretty printing XML, I mean indenting XML with python nicely.

from xml.dom.ext import PrettyPrint
from xml.dom.ext.reader.Sax import FromXmlFile
import sys
doc = FromXmlFile(sys.argv[1])
PrettyPrint(doc, sys.stdout)


Are there any other ways to pretty print xml with python?

How do you pretty print xml with your favourite xml API? Pretty printing xml with ElementTree anyone?

UPDATE: there's a few other ways listed in the comments.



Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.

Pygame weekly mini sprint 2007/05/16

Image
This week there were a number of patches, and bug reports to the mailing list.

Marcus got to most of them - fixing up some 64bit issues, as well as some crashes with hardware surfaces inside the transform module. Thanks to John Myers, John Poppleweel, and Christopher Stone.

Marcus also added some more warnings for gcc. Which you can enable with the command:
python setup.py build -bigw

Marcus then went through and got rid of a bunch of problems that the warnings showed.


I committed sprite changes that John Krukoff proposed in an email to the mailing list last week. They allowed the sprite module to be extended with regards to collision detection. We fixed up a slight performance problem with it for the existing type of collision detection it does.

I started to look at adding the bitmask collision stuff into the sprite module - and then noticed we weren't using a lot of its functionality. Then we got onto discussing collision response... and I wrote another big email to the mailing l…

Pygame weekly mini sprint 2007/05/09

Image
In this weeks pygame mini sprint a few things got done.


Marcus has been working on the scrap module some more this week. He got image pasting working with the gimp. As well as got images working on windows. In the process of trying to get it working on MacOSX a mac got broken! oh noes!! Hopefully Bob can step up and do his MacOSX magic once more.


I worked on getting the bitmask library from Ulf Ekstrom integrated into pygame.

Pixel perfect collision detection is what it is good for. Since it is in C it runs very quickly too. The demo looks really cool, with things bouncing off each other.

It's in subversion now, but there's still a few things I need to do.

- make constructor which takes a surface.
- a 'make_from_surface' method in C. should take a threshold for alpha.
- complete the documentation (now in src/mask.doc)
- complete the unittests (test/test/mask_test.py)
- make set_at and get_at raise IndexError when wrong index is given.
- double check the reference counti…

Consistent variable names across different languages - for Webs.

Image
A dynamic website is often made up of at least three parts:
- html
- a server side programming language (eg python, php)
- a database

(* note, in the current web world, there's more than three. You probably have CSS, javascript, json, xmlprc, rss, and possibly many other encodings of a variable name.)


Why do people still use different variable names for the same data? The html form variable name, the programming variable name, and the database variable name.

Say you have a form which asks people to type their name in and their favourite colour.

<form>
First name <input type="text" name="first_name">
Favourite colour <input type="text" name="colour">
<input type="submit" name="submit" value="What is your favourite Colour?">
</form>


First name
Favourite colour



Now in the server side programming language they convert that to 'firstName' for some weird reason. That's one change that …

Pygame weekly mini sprint 2007/05/02

Image
Today I worked through the list of patches, and bug reports.

[BUG] fromstring,tostring work for alpha. Thanks Brian Fisher.
[BUG] Surf.set_clip(None) works correctly. Thanks Diego Essaya.
Scrap changes from Marcus so windows/osx compile.
Added scancode attribute to keyboard events. Thanks Quentin Smith.
[BUG] movie_set_display hangs on movie file-like object. Thanks Martin.

So there's a few new unittests in there for these bugs/patches too.

I think I'll finish my way through the remaining bugs, and patches next week. After that I want to resurrect movieext. movieext is a half finished module that uses ffmpeg to display movies. Also there are heaps of doc comments to look through. About 300 spam ones I reckon - but there's good stuff in there too. I also need to set my windows development environment up again. I'm hoping to fully document it this time, so that other people can get a windows pygame dev environment set up easily.

Marcus is trying to con…

One Speaker Per Child (OSPC) project.

Image
100 speakers. One for each person at a party.

Here's six mini usb sound cards attached to some usb hubs and extension cables.



The plan is to hook up 100 speakers to 50 sound cards attached to a bunch of linux computers connected via the network. Then using the OSC protocol to get them to act as one massive speaker system.

The cool thing is that there'll also be 50 microphone inputs.

I'm not sure what kind of limits I'll run into yet. It'll be interesting to see how many sound cards I can attach to each computer. Hopefully all 50 sound cards on one computer!




Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.