Sanjin1

Untitled

Sep 14th, 2021
1,058
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from ursina import *
  2. from ursina.prefabs.first_person_controller import FirstPersonController
  3. from random import *
  4.  
  5. app = Ursina()
  6.  
  7.  
  8. #create a player
  9. player = FirstPersonController(collider = 'box', speed = 5)
  10.  
  11. #create a floor
  12. floor = Entity(model = 'plane',
  13.                scale = (100,2,100),
  14.                collider = 'box',
  15.                texture = 'white_cube',
  16.                texture_scale = (50,50),
  17.                color = color.white.tint(-0.2))
  18.  
  19. target = Entity(model = 'cube',
  20.                 scale = (2,2,2),
  21.                 collider = 'box',
  22.                 position = (randint(-50,50), 1, randint(-50,50) ),
  23.                 color = color.green)
  24.        
  25. jumpy_block = Entity(model = 'cube',
  26.                 scale = (5,2,5),
  27.                 collider = 'box',
  28.                 position = (-20,1,20),
  29.                 color = color.pink)
  30.  
  31. obstacles = []
  32. for i in range(100):
  33.     obstacle = Entity(model = 'cube',
  34.                     scale = (2,2,2),
  35.                     collider = 'box',
  36.                     position = (randint(-50,50), 1, randint(-50,50) ),
  37.                     color = color.yellow.tint(-0.2),
  38.                     texture = 'brick')
  39.  
  40.  
  41. def update():
  42.     hit_info = player.intersects()
  43.     if hit_info.hit:
  44.         if hit_info.entity == jumpy_block:
  45.             player.jump_height = 50
  46.             player.speed = 50
  47.         else:
  48.             player.jump_height = 2
  49.             player.speed = 5
  50.            
  51.         if hit_info.entity == target:
  52.             message = Text(text = 'YOU WIN', origin = (0,0), background = True, color = color.green)
  53.             mouse.locked = False
  54.             application.pause()
  55.     if held_keys['c']:
  56.         mouse.locked = False
  57.         application.pause()
  58.        
  59.  
  60. app.run()
RAW Paste Data