Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

birds.py 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import bge
  2. import random
  3. def bird(cont):
  4. own = cont.owner
  5. if 'inited' not in own:
  6. own.worldPosition = own['start'].worldPosition
  7. own['inited'] = True
  8. act = cont.actuators['Steering']
  9. act.target = own['end']
  10. act.velocity = 2
  11. cont.activate(act)
  12. if own.getDistanceTo(own['end']) < 1:
  13. own.endObject()
  14. def main(cont, scene):
  15. def build_bird_list(scene,own):
  16. own['bird_list'] = []
  17. for x in scene.objects:
  18. if 'bird_target' in x.name:
  19. own['bird_list'].append(x)
  20. def do_birds(scene, own, cont):
  21. if own['bird_list'] != []:
  22. if own['life'] % 50 == 0:
  23. num = random.randint(0,2)
  24. if num == 1:
  25. top = len(own['bird_list']) - 1
  26. start = random.randint(0, top)
  27. end = start
  28. while end == start:
  29. end = random.randint(0, top)
  30. obj = scene.addObject('bird_cont', own['bird_list'][start], 0)
  31. obj['start'] = own['bird_list'][start]
  32. obj['end'] = own['bird_list'][end]
  33. obj.worldPosition = obj['start'].worldPosition
  34. def life(own):
  35. if 'life' in own:
  36. own['life'] += 1
  37. else:
  38. own['life'] = 0
  39. own = cont.owner
  40. if 'binited' not in own:
  41. build_bird_list(scene, own)
  42. own['binited'] = True
  43. life(own)
  44. do_birds(scene, own, cont)