Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ursina import *
- from random import *
- #create a first person player
- from ursina.prefabs.first_person_controller import FirstPersonController
- app = Ursina()
- player = FirstPersonController(collider ='box', speed = 10)
- #create a plane (ground to walk on)
- ground = Entity(model = 'plane',
- scale = (50,1,50),
- texture = 'white_cube',
- color = color.white.tint(-0.2),
- collider = 'box',
- texture_scale = (50,50))
- #create a lime green target cube at a random location
- target = Entity(model = 'cube',
- scale = (1,1,1),
- position = (randint(-25,25) + 0.5, 0.5, randint(-25,25) + 0.5),
- collider = 'box',
- color = color.green)
- #obstacles to jump on they obscure the view
- for i in range(100):
- obstacles = Entity(model = 'cube',
- scale = (randint(1,3),randint(1,3),randint(1,3)),
- position = (randint(-25,25) + 0.5, 0.5, randint(-25,25) + 0.5),
- collider = 'box',
- color = color.yellow.tint(-0.3),
- texture = 'brick')
- #obstacles that end you
- lava_blocks = []
- for i in range(25):
- lava = Entity(model = 'cube',
- scale = (randint(1,3),randint(1,3),randint(1,3)),
- position = (randint(-25,25) + 0.5, 0.5, randint(-25,25) + 0.5),
- collider = 'box',
- color = color.red,
- texture = 'brick')
- lava_blocks.append(lava)
- def update():
- hit_info = player.intersects()
- if hit_info.hit:
- if hit_info.entity == target:
- message = Text(text = 'YOU WIN', origin = (0,0), background = True, color=color.blue)
- application.pause()
- mouse.locked = False
- if hit_info.entity in lava_blocks:
- message = Text(text = 'YOU LOSE', origin = (0,0), background = True, color=color.blue)
- application.pause()
- mouse.locked = False
- app.run()
- #https://us02web.zoom.us/j/87097598132?pwd=b2ViWmwzcGZOak1QcUFRYTI4YnZIUT09
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement