[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame and bulletml



thanks!  - i have now this code stored in my Pygame folder for testing
them as far i can get at least as comfortable with Pygame as i think i
were being on sdlBasic - really thanks - i'm really very curious about
how easy on Pygame we can get those shower of bullets as from Kenta
Cho games! :-)

------

On Tue, Jul 29, 2008 at 6:18 PM, Paul Pigg <masterpigg@xxxxxxxxx> wrote:
> I don't know bulletML and don't have plans for using it, but xml didn't seem
> to hard to work with when I needed to.  Here's a quick contrived example
> based on the "fire" example xml on the website, just to give you a quick
> idea of the api.  On it's own, it's not too useful.
>
> --Paul
>
> import xml.dom.minidom
>
> # Note that I put some whitespace in the XML, which is parsed as Text
> s='<fire>  <direction type="absolute">270</direction>  <speed>2</speed>
> <bulletRef label="rocket"/>  </fire>'
>
> dom = xml.dom.minidom.parseString(s)
> doc = dom.documentElement
> assert doc.tagName == 'fire'
>
> print doc.tagName
>
> for child in doc.childNodes:
>     if hasattr(child, 'tagName'): # isinstance(child,
> xml.dom.minidom.Element) also works...
>
>         if child.tagName == 'direction':
>             outstr = '  direction = ' + child.childNodes[0].data
>             if child.hasAttribute('type'):
>                 outstr += ', type = ' + child.getAttributeNode('type').value
>             print outstr
>
>         elif child.tagName == 'speed':
>             print '  speed = ' + child.childNodes[0].data
>
>         elif child.tagName == 'bulletRef':
>             if child.hasAttribute('label'):
>                 print '  bulletRef label = ' +
> child.getAttributeNode('label').value
>
>
> """
> prints:
>
> fire
>   direction = 270, type = absolute
>   speed = 2
>   bulletRef label = rocket
>
> """
>
>
>
>
> On Tue, Jul 29, 2008 at 1:31 AM, Paulo Silva <nitrofurano@xxxxxxxxx> wrote:
>>
>> thanks, but if someone may have some ready snippet, please let us know...
>> :-)
>>
>> On Tue, Jul 29, 2008 at 4:37 AM, Jake b <ninmonkeys@xxxxxxxxx> wrote:
>> > Python can read xml. I don't know of a bulletml specific python lib.
>> >
>> >
>> > --
>> > Jake
>> >
>
>