Esempio n. 1
0
    def make_receiver_boxes(self):
        y_coord = Config.window_height - Config.wall_padding - Config.packet_height
        x_start = 0 + Config.wall_padding

        i = 0
        for x_coord in Utils.frange(
                x_start,
                Config.wall_padding + (num_of_packets * Config.packet_width) +
            (num_of_packets * Config.packet_padding),
                Config.packet_padding + Config.packet_width):

            # First make the border for the packet
            border = Components.Box(
                x_coord - Config.border_width, y_coord - Config.border_width,
                Config.packet_width + 2 * Config.border_width,
                Config.packet_height + 2 * Config.border_width,
                Config.border_color)
            self.border_sprite_list.add(border)

            # Make the new receiver box
            new_recbox = Components.ReceiverBox(x_coord, y_coord)
            self.receiver_list.add(new_recbox)
            self.receiver_map[i] = new_recbox

            # Make the ACK packet (with it's coordinates the same as the receiver box)
            ack_packet = Components.AckPacket(x_coord, y_coord)
            self.ack_list.add(ack_packet)
            self.ack_map[i] = ack_packet
            i += 1
Esempio n. 2
0
    def make_transmitter_boxes(self):
        y_coord = 0 + Config.wall_padding
        x_start = 0 + Config.wall_padding

        i = 0
        for x_coord in Utils.frange(
                x_start,
                Config.wall_padding + (num_of_packets * Config.packet_width) +
            (num_of_packets * Config.packet_padding),
                Config.packet_padding + Config.packet_width):

            # First make the border for the packet
            border = Components.Box(
                x_coord - Config.border_width, y_coord - Config.border_width,
                Config.packet_width + 2 * Config.border_width,
                Config.packet_height + 2 * Config.border_width,
                Config.border_color)
            self.border_sprite_list.add(border)

            # Make the transmitter box
            new_transbox = Components.TransmitterBox(x_coord, y_coord)
            self.transmitter_list.add(new_transbox)
            self.transmitter_map[i] = new_transbox

            # Make the packet (with it's coordinates the same as the transmitter box)
            new_packet = Components.Packet(x_coord, y_coord)
            self.packet_list.add(new_packet)
            self.packet_map[i] = new_packet
            i += 1