コード例 #1
0
    def __init__(self,name,position=vector.Threevec(),velocity=vector.Threevec()):
        FlyingObject.__init__(self,name,position,velocity)

        heading = math.pi/2.0-velocity.phi
        if heading<0.0:
            heading+=2.0*math.pi

        # Set the command info from current parameters
        self.commandHeading = heading
        self.commandSpeed = abs(velocity)
        self.commandAltitude = position.z

        # Set the desired info from current parameters, except speed.
        self.desiredHeading = heading
        self.desiredSpeed = ControllableAirplane.vcruise
        self.desiredAltitude = ControllableAirplane.alt_cruise
コード例 #2
0
    def drawCanvas(self,event=None):
        self.canvas.delete(Tkinter.ALL)
        width = self.canvas.winfo_width()
        height = self.canvas.winfo_height()
        circ_radiusa = (width-10)/2
        circ_radiusb = (height-10)/2
        circ_radius = circ_radiusa
        if circ_radius>circ_radiusb:
            circ_radius=circ_radiusb

        self.canvas.create_oval(5,5,5+2*circ_radius,5+2*circ_radius)

        center_x = 5+circ_radius
        center_y = 5+circ_radius
        scale = RADAR_RADIUS/circ_radius

        for o in self.airplane_list:
            pos = o.getPosition()
            land_pos = vector.Threevec(pos.x,pos.y,0.0) # Get the land position
            if abs(land_pos)<RADAR_RADIUS:
                x_pos = land_pos.x/scale+center_x
                y_pos = -land_pos.y/scale+center_y
                color = "black"
                if o in self.crash_list:
                    color = "red"
                elif o in self.warning_list:
                    color = "orange"

                self.canvas.create_oval(x_pos-2,y_pos-2,x_pos+2,y_pos+2,fill=color)
                self.canvas.create_text(x_pos,y_pos,anchor=Tkinter.SW,fill=color,text="  "+o.getName())
                self.canvas.create_text(x_pos,y_pos,anchor=Tkinter.NW,fill=color,text="  %.fm"%pos.z)
コード例 #3
0
 def __init__(self,name,position=vector.Threevec(),velocity=vector.Threevec()):
     self.name = name
     self.position = position
     self.velocity = velocity