Untitled
Anonymous
plain_text
02/27/2026 4:04 AM
1.6 KB
24
Indexable
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
# 1. Setup the World
# A green floor to mimic the grass
ground = Entity(model='plane', collider='box', scale=64, color=color.lime, texture='white_cube')
# 2. Add the Player
# This prefab handles WASD movement, jumping (Space), and Mouse look automatically
player = FirstPersonController()
player.cursor.visible = True # Show the crosshair
# 3. Add some "Loot" (Gold Cubes)
loot_box = Entity(model='cube', color=color.gold, scale=1, position=(5, 0.5, 5), collider='box')
# 4. Shooting Mechanic
def input(key):
if key == 'left mouse down':
# Check if we hit something when clicking
if mouse.hovered_entity:
# If we hit the loot box, "collect" it (destroy it)
if mouse.hovered_entity == loot_box:
print("Loot collected! +50 Shield")
destroy(loot_box)
else:
# Basic hit effect (make the object blink)
mouse.hovered_entity.blink(color.red)
# 5. The "Storm" UI
storm_text = Text(text='Storm Closing in 3:00', origin=(0, 2), y=0.4, color=color.red)
Sky() # Add a sky background
app.run()Editor is loading...
Leave a Comment