rishabbansal21

Learn 3D Games in Python | Ursina Engine | Part-6 Buttons

May 13th, 2021 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. from ursina import *
  2. import random
  3.  
  4. dx = 0.05
  5.  
  6. def update():
  7.     global dx
  8.     ball.x += dx
  9.  
  10. def ball_pos():
  11.     global dx
  12.     dx *= -1
  13.  
  14. def hello():
  15.     print_on_screen("Hello", position=(random.randint(-3,3)*-0.1,random.randint(-3,3)*-0.1))
  16.  
  17. app = Ursina()
  18.  
  19. ball = Entity(model="sphere", position=(0,2,0))
  20. b = Button(color=color.azure, scale=0.25, text='Submit', text_color=color.green, text_origin=(0,0), icon="sword")
  21.  
  22. b.tooltip=Tooltip("Click Here")
  23. #mouse.visible=False
  24.  
  25. b.on_click = ball_pos
  26.  
  27. app.run()
Add Comment
Please, Sign In to add comment