Advertisement
rishabbansal21

Covid Fighter Part-2

Jun 4th, 2021
1,242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. from ursina import *
  2. import random
  3.  
  4. app = Ursina()
  5. shoot = False
  6. v = 0
  7.  
  8. def update():
  9.     global doctor, shoot, vaccine_list, v
  10.  
  11.     if held_keys['right arrow']:
  12.         doctor.x += 0.007
  13.     if held_keys['left arrow']:
  14.         doctor.x -= 0.007
  15.  
  16.     if shoot:
  17.         vaccine_list[v].y += 0.015
  18.  
  19.         if vaccine_list[v].y > 0.2:
  20.             destroy(vaccine_list[v])
  21.             shoot = False
  22.  
  23.     for i in virus_list:
  24.         i.y -= 0.001
  25.  
  26. def input(key):
  27.     global shoot, vaccine_list, v
  28.     st = -0.8
  29.     if key == "space":
  30.         shoot = True
  31.         v += 1
  32.         vaccine_list.append(duplicate(vaccine, x=doctor.x, y=st))
  33.  
  34.  
  35. Entity(model="quad", scale=70, texture="back.jpg")
  36.  
  37. back_size = 22
  38. back = Entity(model='quad', color=color.rgba(255,255,255,0), scale=(12,18),
  39.               position=(back_size//2, back_size//2, -0.01))
  40.  
  41.  
  42. doctor = Entity(model="cube", parent=back, texture='doctor.png', scale=0.2,
  43.                 position=(0,-0.75,0))
  44.  
  45.  
  46. vaccine = Entity(model="quad", parent=back, texture='vaccine.png', scale=0.1,
  47.                  position=(2,2))
  48. vaccine_list = [duplicate(vaccine, y=2,x=2)]
  49.  
  50.  
  51. virus = Entity(model="quad", parent=back, texture='virus.png', scale=0.15,
  52.                position=(2,2))
  53. virus_list = []
  54.  
  55. for i in range(5):
  56.     virus_list.append(duplicate(virus, x=random.randint(-45,45)/100, y=random.randint(-3,-1)/100))
  57.  
  58. camera.position = (back_size//2, -15, -11)
  59. camera.rotation_x = -60
  60. app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement