def move(self,dx,dy):
     previous_rect = self.rect           #remember in case undo is necessary
     self.rect = self.rect.move(dx,dy)
     legs2 = transportation.transportation()
     legs2.together()
     if self.rect.collidelist(list_rect_obstacles) != -1:#if collision exists
         print 'mode  -->I collided with wall(s)',\
               self.rect.collidelistall(list_rect_obstacles)
         self.rect = previous_rect                   #undo the move
         self.collided = True
     else:                   #if there was no collision
         if leave_trace:     #update trace list
             tr = self.rect.inflate(trace_decrease, trace_decrease)
             list_traces.append(Trace(tr, 90+self.azi-trace_arc, 90+self.azi+trace_arc))
r_visual_range   = 200      #measured from robot center
r_visual_angle   = 30       #in degrees, must divide 90 exactly!
r_visual_granularity = 5    #must be < wall_thickness for walls to be detected correctly!


#import everything
import os, pygame
from pygame.locals import *
import math
import random
import transportation

main_dir = os.path.split(os.path.abspath(__file__))[0]
screen = pygame.display.set_mode((display_cols, display_rows))
list_traces = list()
legs = transportation.transportation()

class Trace():
    def __init__(self, from_rect, start_angle, stop_angle):
        self.rect       = from_rect
        self.start_angle= start_angle
        self.stop_angle = stop_angle

class Obstacle(pygame.Rect):       #for now just colored rectangles
    def __init__(self, x_topleft, y_topleft, width, height, color):
        self.x_topleft  = x_topleft
        self.y_topleft  = y_topleft
        self.width      = width
        self.height     = height
        self.color      = pygame.Color(color)