Sanjin1

Untitled

Sep 14th, 2021
861
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), 50, randint(-50,50) ),
  23.                 color = color.green,
  24.                 dy = -0.5)
  25.        
  26. jumpy_block = Entity(model = 'cube',
  27.                 scale = (5,2,5),
  28.                 collider = 'box',
  29.                 position = (-20,1,20),
  30.                 color = color.pink)
  31.  
  32. obstacles = []
  33. for i in range(500):
  34.     obstacle = Entity(model = 'cube',
  35.                     scale = (randint(1,6),randint(1,6),randint(1,6)),
  36.                     collider = 'box',
  37.                     position = (randint(-50,50), 1, randint(-50,50) ),
  38.                     color = color.yellow.tint(-0.2),
  39.                     texture = 'brick')
  40.     obstacles.append(obstacle)
  41.  
  42. first_run = True
  43.  
  44. def update():
  45.     target.y += target.dy
  46.     hit_info = target.intersects()
  47.     if hit_info.hit:
  48.         target.dy = 0
  49.        
  50.    
  51.     hit_info = player.intersects()
  52.     if hit_info.hit:
  53.         if hit_info.entity == jumpy_block:
  54.             player.jump_height = 50
  55.             player.speed = 50
  56.         else:
  57.             player.jump_height = 2
  58.             player.speed = 5
  59.            
  60.         if hit_info.entity == target:
  61.             message = Text(text = 'YOU WIN', origin = (0,0), background = True, color = color.green)
  62.             mouse.locked = False
  63.             application.pause()
  64.            
  65.        
  66.     if held_keys['c']:
  67.         mouse.locked = False
  68.         application.pause()
  69.        
  70.  
  71. app.run()
RAW Paste Data