예제 #1
0
파일: gamemodule.py 프로젝트: enibundo/tron
    def registerNewPlayer(self, protocol, frame):
        red = trames.getData(frame, 0)
        green = trames.getData(frame, 1)
        blue = trames.getData(frame, 2)
        nickname = trames.getData(frame, 3)
        
        myid = self.nextId()

        if myid==0:
            posx, posy, d = (100, 100, 4) # a droite
        if myid==1:
            posx, posy, d = (900, 100, 1)
        if myid==2:
            posx, posy, d = (100, 900, 2)
        if myid==3:
            posx, posy, d = (900, 900, 3)
        newPlayer= user.User(protocol, myid, nickname, red, green, blue, posx, posy, d, 1) 
        self.addPlayer(newPlayer)
        return newPlayer
예제 #2
0
 def recOFrame(self, frame):
     order = trames.getData(frame, 0)
     old_direction = self.user.getDirection()
     
     if not order=="idle":
         if (old_direction==1 and order=="left") or (old_direction==2 and order=="right"):
             new_direction=3
         if (old_direction==1 and order=="right") or (old_direction==2 and order=="left"):
             new_direction=4
         if (old_direction==3 and order=="left") or (old_direction==4 and order=="right"):
             new_direction=2
         if (old_direction==3 and order=="right") or (old_direction==4 and order=="left"):
             new_direction=1
         self.user.setDirection(new_direction)