Advertisement
acidxp4in

funciones

May 30th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | None | 0 0
  1. import pygame, sys
  2.  
  3. from pygame.locals import *
  4. from random import choice, randint
  5. from configuracion import *
  6. from constantes import *
  7. from utilidades import *
  8.  
  9. def completar_tablero(cursor,tablero,barco_actual,sentido):
  10.     (x,y),r=cursor
  11.     a,b=(-1,-1)
  12.     l=[(3,33),(36,66),(69,99),(102,132),(135,165),(168,198),(201,231),(234,264),(267,297),(300,330)]
  13.     if ((200<x) and (x<530)) and ((50<y) and (y<380)):
  14.         (x,y)=(x-200,y-50)
  15.         for i in range(len(l)):
  16.             c,d=l[i]
  17.             if c<=y<d:
  18.                 a=i
  19.             if c<=x<d:
  20.                 b=i
  21.         if b==-1 or a==-1:
  22.             return (-1,-1)
  23.         for A in range(barco_actual) :
  24.             if sentido=='NORTE' :          
  25.                 if (tablero[a][b+A]==0) and (A+barco_actual)<10 :
  26.                     tablero[a][b+A]=-barco_actual
  27.                 else :
  28.                     return (-1,-1)
  29.             if sentido=='OESTE' :
  30.                 if (tablero[a+A][b]==0) and (A+barco_actual)<10 :
  31.                     tablero[a+A][b]=-barco_actual
  32.                 else :
  33.                     return (-1,-1)  
  34.         return (a,b)
  35.     else:
  36.         return (-1,-1)
  37.    
  38. def actualizar_info_posicion (fila, columna, barco_actual):
  39.     if fila==-1 and columna==-1 :
  40.         return False
  41.     else:
  42.         #Falta cambiar los barquitos que aparecen abajo en la pantalla
  43.         return True
  44.  
  45. def posicionar_barcos_enemigos(t):
  46.     i=1
  47.     while i<=5 :
  48.         x=randint(0,9)
  49.         y=randint(0,9)
  50.         z=choice('01')
  51.         for b in range(i) :
  52.             if z=='0' :
  53.                 tablero[x][y+b]=-i
  54.             if z=='1' :
  55.                 tablero[x+b][y]=-i
  56.         i+=1
  57.     return None
  58.    
  59. def procesar_disparo(cursor, tablero, tablero2, dx, dy):
  60.    
  61.     return []
  62.  
  63. def disparo_enemigo(tablero, tablero2):
  64.    
  65.     return []
  66.  
  67.  
  68. def actualizar_tablero(info_disparos, disparos, jugada):
  69.              
  70.     return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement