Advertisement
Sanjin1

Untitled

Sep 10th, 2021
1,177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.12 KB | None | 0 0
  1. from ursina import *
  2. from random import *
  3. #create a first person player
  4. from ursina.prefabs.first_person_controller import FirstPersonController
  5.  
  6.  
  7. app = Ursina()
  8.  
  9. player = FirstPersonController(collider ='box', speed = 10)
  10. #create a plane (ground to walk on)
  11. ground = Entity(model = 'plane',
  12.                 scale = (50,1,50),
  13.                 texture = 'white_cube',
  14.                 color = color.white.tint(-0.2),
  15.                 collider = 'box',
  16.                 texture_scale = (50,50))
  17.  
  18.  
  19. #create a lime green target cube at a random location
  20. target = Entity(model = 'cube',
  21.                 scale = (1,1,1),
  22.                 position = (randint(-25,25) + 0.5, 0.5, randint(-25,25) + 0.5),
  23.                 collider = 'box',
  24.                 color = color.green)
  25.  
  26. #obstacles to jump on they obscure the view
  27. for i in range(100):
  28.     obstacles = Entity(model = 'cube',
  29.                     scale = (randint(1,3),randint(1,3),randint(1,3)),
  30.                     position = (randint(-25,25) + 0.5, 0.5, randint(-25,25) + 0.5),
  31.                     collider = 'box',
  32.                     color = color.yellow.tint(-0.3),
  33.                     texture = 'brick')
  34.  
  35. #obstacles that end you
  36. lava_blocks = []
  37. for i in range(25):
  38.     lava = Entity(model = 'cube',
  39.                     scale = (randint(1,3),randint(1,3),randint(1,3)),
  40.                     position = (randint(-25,25) + 0.5, 0.5, randint(-25,25) + 0.5),
  41.                     collider = 'box',
  42.                     color = color.red,
  43.                     texture = 'brick')
  44.     lava_blocks.append(lava)
  45.  
  46. def update():
  47.     hit_info = player.intersects()
  48.     if hit_info.hit:
  49.         if hit_info.entity == target:
  50.             message = Text(text = 'YOU WIN', origin = (0,0), background = True, color=color.blue)
  51.             application.pause()
  52.             mouse.locked = False
  53.         if hit_info.entity in lava_blocks:
  54.             message = Text(text = 'YOU LOSE', origin = (0,0), background = True, color=color.blue)
  55.             application.pause()
  56.             mouse.locked = False
  57.  
  58.  
  59. app.run()
  60.  
  61. #https://us02web.zoom.us/j/87097598132?pwd=b2ViWmwzcGZOak1QcUFRYTI4YnZIUT09
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement