Пример #1
0
    def moveBy(self, x, y, z):
        #Atualiza tempo de voo
        self.flyingTime += 1

        #Caso não esteja alinhado com o norte do mapa, realinhar
        if self.northAligned == False:
            print("Realign")
            self.rotation = -self.rotation
            self.dx = 0
            self.dy = 0
            self.dz = 0
            self.northAligned = True

        #Caso esteja alinhado com o norte do mapa...
        else:
            print("Aligned")
            self.dx = x
            self.dy = y
            self.dz = z

            self.absY += y

            print("Movimento nesta iteração: x:%d y:%d z:%d" %(x, y, z))
            print("AbsY:", self.absY)

            #Calcula diferença entre o ponto central do drone e o ponto inicial(0, 80, 0)
            self.pontoCentral.x += x
            self.pontoCentral.y += y
            self.pontoCentral.z += z

            #Atualiza limites seguros
            self.northLimit -= self.dz
            self.southLimit += self.dz
            self.eastLimit -= self.dx
            self.westLimit += self.dx

            #Converter (dx, dy, dz) em (frontal, normal, rotation)
            self.frontalVector = f.convertXZIntoFrontalVector(self.dx, self.dz)
            self.rotation = f.convertXZIntoRotationAngle(self.dx, self.dz)

            if self.rotation != 0:
                self.northAligned = False

        self.atualizaCombustivel()
Пример #2
0
    def atualizaCombustivel(self):
        #Combustível
        self.energy -= f.convertXZIntoFrontalVector(self.dx, self.dz)

        #Gasta energia p/ subir
        if self.dy > 0:
            self.energy -= self.dy

        #Gasta energia se for para ficar parado
        elif self.dy == 0 and self.dx == 0 and self.dz == 0:
            self.energy -= 1

        #Conseiderando que deixar o drone em queda livre o faça cair 1dm/unidade de tempo
        elif self.dy < -1:
            self.energy += self.dy

        print("Energy:", self.energy)

        #Se o drone ficar sem combustivel
        if self.energy <= 0:
            print("Manhê!!! O droninho caiu!!!")