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()
- frame_counter = 0
- player = FirstPersonController(collider ='box', speed = 5, y=5)
- #create a plane (ground to walk on)
- ground = Entity(model = 'plane',
- scale = (100,2,100),
- 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, 20, randint(-25,25) + 0.5),
- collider = 'box',
- color = color.green)
- #obstacles to jump on they obscure the view
- for i in range(1000):
- obstacles = Entity(model = 'cube',
- scale = (randint(1,3),randint(1,10),randint(1,3)),
- position = (randint(-50,50) + 0.5, 0.5, randint(-50,50) + 0.5),
- collider = 'box',
- color = color.yellow.tint(-0.3),
- texture = 'brick')
- #obstacles that end you
- lava_blocks = []
- lava_blocks.append(target)
- def update():
- global frame_counter, lava_blocks
- frame_counter += 1
- if frame_counter % 180 == 0:
- lava = Entity(model = 'cube',
- scale = (randint(1,3),randint(1,3),randint(1,3)),
- position = (randint(-25,25) + 0.5, 100, randint(-25,25) + 0.5),
- collider = 'box',
- color = color.red)
- lava_blocks.append(lava)
- for block in lava_blocks:
- hit_info = block.intersects()
- if hit_info.hit == False:
- block.y -= 0.2
- hit_info = player.intersects()
- if hit_info.hit:
- if hit_info.entity in lava_blocks:
- if hit_info.entity == target:
- message = Text(text = 'YOU WIN', origin = (0,0), background = True, color=color.blue)
- else:
- message = Text(text = 'YOU LOSE', origin = (0,0), background = True, color=color.blue)
- application.pause()
- mouse.locked = False
- sky = Sky()
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement