Advertisement
Guest User

Untitled

a guest
May 30th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. def completar_tablero (cursor, tablero, barco_actual, sentido):
  2. (x,y),radio=cursor
  3. a,b=(-1,-1)
  4. cuadrado=[(3,33),(36,66),(69,99),(102,132),(165,195),(198,228),(231,261),(264,294),(297,227),(300,330)]
  5. if x>200 and x<530 and y>50 and y<350:
  6. (x,y)=(x-200,y-50)
  7. for i in range(len(cuadrado)):
  8. c,d=cuadrado[i]
  9. if c<=x<d :
  10. a=i
  11. if c<=y<d :
  12. b=i
  13. if a==-1 or b==-1 :
  14. return (-1,-1)
  15. for j in range(barco_actual) :
  16. if sentido=='NORTE' :
  17. print a+barco_actual
  18. if a+barco_actual>10 or tablero[a+j][b]!= 0 :
  19. return (-1,-1)
  20. elif sentido=='OESTE' :
  21. print b+barco_actual
  22. if b+barco_actual>10 or tablero[a][b+j]!= 0 :
  23. return(-1,-1)
  24. for k in range(barco_actual):
  25. if sentido=='NORTE':
  26. tablero[a+k][b]=-barco_actual
  27. elif sentido=='OESTE':
  28. tablero[a][b+k]=-barco_actual
  29. return (a,b)
  30. else:
  31. return (-1,-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement