Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ursina import *
- import random
- app = Ursina()
- shoot = False
- v = 0
- score = 0
- hit = False
- over = False
- def update():
- global doctor, shoot, vaccine_list, virus_list, score, hit, over, v
- if not(over):
- if held_keys['right arrow']:
- doctor.x += 0.007
- if held_keys['left arrow']:
- doctor.x -= 0.007
- if shoot:
- vaccine_list[v].y += 0.015
- if vaccine_list[v].y > 0.3 or hit:
- destroy(vaccine_list[v])
- shoot = False
- hit = False
- hit_info = vaccine_list[v].intersects()
- if hit_info.hit:
- hit = True
- score += 1
- if hit_info.entity in virus_list:
- j = virus_list.index(hit_info.entity)
- destroy(virus_list[j])
- virus_list[j] = duplicate(virus, x=random.randint(-45,45)/100, y=random.randint(-3,-1)/100)
- for i in virus_list:
- i.y -= 0.001
- if i.y< -0.8:
- over = True
- print_on_screen("SCORE: "+str(score), position=(-0.8,0.5))
- elif over == True:
- for i in vaccine_list:
- destroy(i)
- for i in virus_list:
- destroy(i)
- destroy(doctor)
- print_on_screen("GAME OVER!", position=(-0.05,0.2))
- print_on_screen("FINAL SCORE: "+str(score), position=(-0.07,0.15))
- def input(key):
- global shoot, vaccine_list, v
- st = -0.8
- if key == "space":
- shoot = True
- v += 1
- vaccine_list.append(duplicate(vaccine, x=doctor.x, y=st))
- Entity(model="quad", scale=70, texture="back.jpg")
- back_size = 22
- back = Entity(model='quad', color=color.rgba(255,255,255,0), scale=(12,18),
- position=(back_size//2, back_size//2, -0.01))
- doctor = Entity(model="cube", parent=back, texture='doctor.png', scale=0.2,
- position=(0,-0.75,0))
- vaccine = Entity(model="quad", parent=back, texture='vaccine.png', scale=0.1,
- position=(2,2), collider="box")
- vaccine_list = [duplicate(vaccine, y=2,x=2)]
- virus = Entity(model="quad", parent=back, texture='virus.png', scale=0.15,
- position=(2,2), collider="box")
- virus_list = []
- for i in range(5):
- virus_list.append(duplicate(virus, x=random.randint(-45,45)/100, y=random.randint(-3,-1)/100))
- camera.position = (back_size//2, -15, -11)
- camera.rotation_x = -60
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement