Example #1
0
 def test_actor(self):
     actor = Actor("Player")
     self.assertEqual(actor.name, "Player")
     self.game.add(actor)
     self.assertEqual(actor.game, self.game)
     
     # test event queue
     actor.says("hello world")
     self.assertEqual(len(self.game.events), 1)
     self.assertEqual(self.game.events[0][1], actor)
     self.game.handle_events()
Example #2
0
    def test_left(self):
        """ Create an actor with a left animation cycle """
        instructions = []
        a = Actor("Randy Harrison")
        a.x, a.y = 150, 480 #start
        x,y = 840, 450  #destination
        action = Action(a, "left")
        a.actions[action.name] = action
        action.deltas = [(-10,0), (-16,0), (-20,0), (-15,0), (-10,0)]
        instructions.append("background:0,0,0")        
        instructions.append("colour:100,100,100")
        instructions.append("width:5")
        instructions.extend("node:%s, %s"%i for i in HORSESHOE_WALKAREA.polygon.vertexarray)
#        instructions.extend(HORSESHOE_WALKAREA.polygon.vertexarray)
        walkareas = [HORSESHOE_WALKAREA]
        walkactions = [action.name]
        nodes = a._goto_astar(x,y, walkactions, walkareas)
        
#        nodes = square_off_nodes(nodes, HORSESHOE_WALKAREA) #calculate right angle nodes
        import astar
        n = astar.MAP_NODES
        instructions.append("colour:25,0,25")
        instructions.extend("node:%s,%s"%x for x in n)
        
        nodes = [(x,y) for x,y in nodes]
        instructions.append("width:8")
        instructions.append("colour:155,0,85")
        instructions.append("background:55,0,25")        
#        for x in nodes: 
        instructions.extend("node:%s,%s"%x for x in nodes)
        instructions.append("moveto:%s,%s"%nodes[0])
        instructions.append("colour:55,0,35")
        instructions.extend("lineto:%s,%s"%x for x in nodes[1:])
#        print("node(%s)"%x for x in nodes)
        print(instructions)
        draw(instructions, "testastar3.png")