Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def completar_tablero (cursor, tablero, barco_actual, sentido):
- (x,y),radio=cursor
- a,b=(-1,-1)
- cuadrado=[(3,33),(36,66),(69,99),(102,132),(165,195),(198,228),(231,261),(264,294),(297,227),(300,330)]
- if x>200 and x<530 and y>50 and y<350:
- (x,y)=(x-200,y-50)
- for i in range(len(cuadrado)):
- c,d=cuadrado[i]
- if c<=x<d :
- a=i
- if c<=y<d :
- b=i
- if a==-1 or b==-1 :
- return (-1,-1)
- for j in range(barco_actual) :
- if sentido=='NORTE' :
- print a+barco_actual
- if a+barco_actual>10 or tablero[a+j][b]!= 0 :
- return (-1,-1)
- elif sentido=='OESTE' :
- print b+barco_actual
- if b+barco_actual>10 or tablero[a][b+j]!= 0 :
- return(-1,-1)
- for k in range(barco_actual):
- if sentido=='NORTE':
- tablero[a+k][b]=-barco_actual
- elif sentido=='OESTE':
- tablero[a][b+k]=-barco_actual
- return (a,b)
- else:
- return (-1,-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement