コード例 #1
0
ファイル: gen.py プロジェクト: CodeSturgeon/mr-mazer
 def get(self):
     db.delete(Tile.all())
     db.delete(Avatar.all())
     cleared = make_maze(20, 20)
     for t in cleared:
         view = []
         for vy in range(t[1] - view_radius, t[1] + view_radius + 1):
             for vx in range(t[0] - view_radius, t[0] + view_radius + 1):
                 if (vx, vy) in cleared:
                     shape = get_shape(vx, vy, cleared)
                     view.append({'x': vx, 'y': vy, 'shape': shape})
         shape = get_shape(t[0], t[1], cleared)
         key = db.Key.from_path(
             'Maze', 'bogart',
             'Tile', '%d-%d' % (t[0], t[1])
         )
         Tile(
             key=key,
             x=t[0],
             y=t[1],
             shape=shape,
             view_blob=json.dumps(view)
         ).put()
     Avatar(x=0, y=0, name='jack').put()
     self.response.out.write('Generator %s' % cleared)
コード例 #2
0
ファイル: dumper.py プロジェクト: CodeSturgeon/mr-mazer
  def get(self):
    width = 20
    height = 20
    paths = Tile.all()
    maze_tiles = {}
    for path in paths:
        maze_tiles[(path.x, path.y)] = ' '

    lines = []

    tenline = ['  *']
    unitline = ['  *']
    for ten in range(0,width,10):
        tenline.append(str(ten)[0]*10)
        unitline.append(''.join(map(str,range(10))))
    lines.append(''.join(tenline))
    lines.append(''.join(unitline))
    lines.append('***'+'*'*width)

    for y in range(height):
        line = []
        line.append('%02d*'%y)
        for x in range(width):
            line.append(maze_tiles.get((x,y), '#'))
        line.append('*')
        lines.append(''.join(line))
    lines.append('   '+'*'*width)
    self.response.headers['Content-type'] = 'text/plain'
    self.response.out.write('\n'.join(lines))
コード例 #3
0
ファイル: gen.py プロジェクト: CodeSturgeon/reddit-maze
 def get(self):
   db.delete(Tile.all())
   db.delete(Avatar.all())
   cleared = make_maze(20,20)
   for t in cleared:
       view = []
       for vy in range(t[1]-view_radius,t[1]+view_radius+1):
           for vx in range(t[0]-view_radius,t[0]+view_radius+1):
               if (vx,vy) in cleared:
                   view.append({'x':vx, 'y':vy})
       Tile(x=t[0], y=t[1], view_blob=pickle.dumps(view, 2)).put()
   Avatar(x=0,y=0,name='jack').put()
   self.response.out.write('Generator %s'%cleared)
コード例 #4
0
ファイル: pinky_tests.py プロジェクト: CodeSturgeon/mr-mazer
 def testInsertEntity(self):
     t = Tile(x=0, y=1, shape=0, view_blob='blob')
     t.put()
     self.assertEqual(1, len(Tile.all().fetch(2)))