Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from configuraciones import *
  5. from utilidades import *
  6.  
  7. def mover_pinguino(posicion, direccion, radio,frozzi_speed_factor):
  8. x = posicion[0]
  9. y = posicion[1]
  10. if direccion == 'N':
  11. y -= frozzi_speed_factor
  12. if direccion == 'S':
  13. y += frozzi_speed_factor
  14. if direccion == 'E':
  15. x += frozzi_speed_factor
  16. if direccion == 'O':
  17. x -= frozzi_speed_factor
  18. if x+radio>719:
  19. x = 719-radio
  20. if x-radio<0:
  21. x=radio
  22. if y<500:
  23. y=500
  24. if y+radio>599:
  25. y = 599-radio
  26. return (x,y)
  27.  
  28. def crear_proyectil(tipo,frozzi, proyectiles_elementos):
  29. x = frozzi["posicion"][0]
  30. y = frozzi["posicion"][1]
  31. frozzi["municion"] -=1
  32. proyectiles_elementos[tipo].add( (x,y) )
  33. return
  34.  
  35. def detectar_colision_borde_proyectil(coordenada,direccion):
  36. return (coordenada[1] == 0 and direccion == "N") or (coordenada[1] == 600 and direccion == "S")
  37.  
  38. def mover_proyectiles(elementos,proyectiles_elementos,radios,speed_factor):
  39. aux_bolas = set()
  40. aux_copos = set()
  41. aux_peces = set()
  42. for bola in proyectiles_elementos["bolas_fuego"]:
  43. x = bola[0]
  44. y = bola[1]
  45. if (0<=x<=720 and 0<=y<=600):
  46. aux_bolas.add( (x,y+speed_factor["bolas_fuego"]))
  47.  
  48. for bola in proyectiles_elementos["copos_nieve"]:
  49. x = bola[0]
  50. y = bola[1]
  51. if (0<=x<=720 and 0<=y<=600):
  52. aux_copos.add( (x,y-speed_factor["copos_nieve"]))
  53.  
  54. for bola in proyectiles_elementos["peces"]:
  55. x = bola[0]
  56. y = bola[1]
  57. if (0<=x<=720 and 0<=y<=600):
  58. aux_peces.add( (x,y+speed_factor["peces"]))
  59.  
  60.  
  61. proyectiles_elementos["bolas_fuego"] = aux_bolas
  62. proyectiles_elementos["copos_nieve"] = aux_copos
  63. proyectiles_elementos["peces"] = aux_peces
  64. return
  65.  
  66. def detectar_colisiones(frozzi,radios,elementos,proyectiles_elementos):
  67. f_x = frozzi["posicion"][0]
  68. f_y = frozzi["posicion"][1]
  69. for copo in list(proyectiles_elementos["copos_nieve"]):
  70. a=copo[0]
  71. b=copo[1]
  72. for bola in list(proyectiles_elementos["bolas_fuego"]):
  73. x = bola[0]
  74. y = bola[1]
  75. if (x-a)**2 + (y-b)**2 < radios["bolas_fuego"]**2:
  76. if copo in proyectiles_elementos["copos_nieve"]:
  77. proyectiles_elementos["copos_nieve"].remove(copo)
  78. if bola in proyectiles_elementos["bolas_fuego"]:
  79. proyectiles_elementos["bolas_fuego"].remove(bola)
  80. frozzi["bolas_fuego"] +=1
  81. for bola in list(proyectiles_elementos["bolas_fuego"]):
  82. x = bola[0]
  83. y = bola[1]
  84. if ((-f_x + x)**2 + (-f_y + y)**2 < radios["frozzi"]**2 ):
  85. proyectiles_elementos["bolas_fuego"].remove(bola)
  86. frozzi["vidas"] -=1
  87. for pez in list(proyectiles_elementos["peces"]):
  88. x = pez[0]
  89. y = pez[1]
  90. if ((-f_x + x)**2 + (-f_y + y)**2 < radios["frozzi"]**2 ):
  91. proyectiles_elementos["peces"].remove(pez)
  92. frozzi["peces"] +=1
  93. return dict()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement