Advertisement
Sanjin1

Untitled

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