Mercurial > qqw
changeset 22:e562c0e14754
add hatta plugin
| author | sheep@ghostwheel |
|---|---|
| date | Sat, 06 Mar 2010 11:23:57 +0100 |
| parents | 38727d1dce97 |
| children | b6b5b8d0078e |
| files | dw.js qqw.py |
| diffstat | 2 files changed, 147 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/dw.js Sat Mar 06 11:16:13 2010 +0100 +++ b/dw.js Sat Mar 06 11:23:57 2010 +0100 @@ -1,6 +1,6 @@ var Game = function () { var module = {}; - module.baseurl = ''; - module.key = { + module.baseurl = baseurl || ''; + module.key = map_key || { ' ': { 'block': true, 'wall': true,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qqw.py Sat Mar 06 11:23:57 2010 +0100 @@ -0,0 +1,145 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import sys +sys.path.insert(0, '/home/sheep/lib/hatta/') + +import hatta +import werkzeug +import mimetypes +try: + import json +except ImportError: + import simplejson as json + +mimetypes.add_type('text/x-map', '.map') + +class WikiPageMap(hatta.WikiPageText): + map_key ={ + ' ': { + 'block': True, + 'wall': True, + }, + ':': { + 'tileset': "wall.png", + 'tile_x': 0, + 'tile_y': 3, + }, + '`': { + 'tileset': "wall.png", + 'tile_x': 2, + 'tile_y': 3, + }, + 'W': { + 'block': True, + 'wall': 'W', + 'tileset': "wall.png", + }, + 'X': { + 'block': True, + 'wall': 'X', + 'tileset': "ground.png", + }, + '.': { + 'tileset': "ground.png", + 'tile_x': 0, + 'tile_y': 3, + }, + ',': { + 'tileset': "ground.png", + 'tile_x': 1, + 'tile_y': 3, + }, + ';': { + 'tileset': "ground.png", + 'tile_x': 2, + 'tile_y': 3, + }, + '"': { + 'tileset': "ground.png", + 'tile_x': 3, + 'tile_y': 3, + }, + '=': { + 'tileset': "ground.png", + 'tile_x': 1, + 'tile_y': 1, + }, + '0': { + 'tileset': "ground.png", + 'tile_x': 0, + 'tile_y': 3, + }, + '1': { + 'tileset': "wall.png", + 'tile_x': 3, + 'tile_y': 3, + 'url': 'map.html' + }, + '2': { + 'tile': ':', + 'sprite': "ladder.png", + 'url': 'index.html#3', + }, + '3': { + 'tileset': "wall.png", + 'tile_x': 1, + 'tile_y': 3, + 'url': 'map.html#2', + }, + 'S': { + 'tile': '.', + 'block': True, + 'sprite': "skeleton.png", + }, + 'Z': { + 'tile': ':', + 'block': True, + 'sprite': "zombie.png", + }, + 'x': { + 'tile': '.', + 'block': True, + 'sprite': "caution.png", + }, + 'b': { + 'tile': ':', + 'sprite': "box.png", + 'block': True, + }, + 'h': { + 'tile': ':', + 'sprite': "hammer.png", + }, + 'l': { + 'tile': 'W', + 'sprite': "light.png", + 'block': True, + 'noshadow': True, + 'wall': 'W', + }, + } + + def content_iter(self, lines): + yield u"""\ +<style>@import url(+download/dw.css);</style><div id="game"><div id="field"> +<div id="map"></div><div id="sprites"></div><div id="overlays"></div> +</div></div><pre id="mapdef">""" + for line in lines: + yield werkzeug.html(line) + yield """</pre><script>""" + yield """var baseurl = '+download/';""" + yield """var map_key = %s;""" % json.dumps(self.map_key) + yield """</script><script src="+download/dw.js"></script>""" + + +config = hatta.WikiConfig( + front_page='map.map', + pages_path='/home/sheep/www/qqw/docs', +) +wiki = hatta.Wiki(config) +wiki.mime_map['text/x-map'] = WikiPageMap +application = wiki.application + +if __name__=="__main__": + hatta.main(config, wiki)
