Sanjin1

Untitled

Sep 14th, 2021
1,047
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.  
  32. def update():
  33.     hit_info = player.intersects()
  34.     if hit_info.hit:
  35.         if hit_info.entity == jumpy_block:
  36.             player.jump_height = 50
  37.             player.speed = 50
  38.         else:
  39.             player.jump_height = 2
  40.             player.speed = 5
  41.            
  42.         if hit_info.entity == target:
  43.             message = Text(text = 'YOU WIN', origin = (0,0), background = True, color = color.green)
  44.             mouse.locked = False
  45.             application.pause()
  46.  
  47. app.run()
RAW Paste Data