from ursina import * from ursina.prefabs.first_person_controller import FirstPersonController import math app = Ursina() # Golf Course ground = Entity(model='plane', scale=40, color=color.green, collider='box') # Hole hole = Entity(model='sphere', color=color.black, scale=0.5, position=(10, 0.25, 10)) # Ball ball = Entity(model='sphere', color=color.white, scale=0.5, position=(0, 0.25, 0), collider='sphere') ball_velocity = Vec3(0, 0, 0) friction = 0.98 shooting = False start_drag = None # Camera camera.position = (0, 15, -20) camera.rotation_x = 30 def update(): global ball_velocity # Move the ball if ball_velocity.length() > 0.01: ball.position += ball_velocity * time.dt ball_velocity *= friction else: ball_velocity = Vec3(0, 0, 0) # Check if ball is in hole if distance(ball.position, hole.position) < 0.5: print("🏁 You scored!") ball.position = Vec3(0, 0.25, 0) ball_velocity = Vec3(0, 0, 0) def input(key): global shooting, start_drag, ball_velocity if key == 'left mouse down': start_drag = mouse.world_point if key == 'left mouse up' and start_drag: end_drag = mouse.world_point if end_drag: power = start_drag - end_drag ball_velocity = Vec3(power.x, 0, power.z) * 5 start_drag = None app.run()