Chciałbym zrobić że gdy gladiator lub gladiator2 poruszy się w lewo, to obraca się w lewo, a gdy poruszy się w prawo, to obraca się w prawo. Oto kod:
from ursina import*
def update():
if held_keys['left arrow']:
gladiator.x -= 1 * 0.1
if held_keys['right arrow']:
gladiator.x += 1 * 0.1
if held_keys['down arrow']:
gladiator.y -= 1 * 0.1
if held_keys['up arrow']:
gladiator.y += 1 * 0.1
if held_keys['a']:
gladiator2.x -= 1 * 0.1
if held_keys['d']:
gladiator2.x += 1 * 0.1
if held_keys['s']:
gladiator2.y -= 1 * 0.1
if held_keys['w']:
gladiator2.y += 1 * 0.1
app = Ursina()
window.borderless = False
window.title = 'Arena'
window.fullscreen = True
gladiator_texture = load_texture(r'assets\gladiator-left.gif')
gladiator = Entity(model='quad', texture=gladiator_texture, scale=(4, 4), position=(3, 0))
gladiator2_texture = load_texture(r'assets\gladiator - right.gif')
gladiator2 = Entity(model='quad', texture=gladiator2_texture, scale=(4, 4), position=(-3, 0))
arena_texture = load_texture(r'assets\Download.jpg')
arena = Entity(model='quad', texture=arena_texture, scale=(15, 10))
app.run()