February 16, 2024/275 阅读
角色移动与越位检测——双人竞技
#场景搭建
import ybc_game
ybc_game.size(1200,600)
ybc_game.title('击剑达人')
bg=ybc_game.actor(''bg')
zy=ybc_game.actor('zy',[300,380])
boss=ybc_game.actor('boss',[900,380])
def update():
bg.draw()
zy.draw()
boss.draw()
ybc_game.go()
角色左右移动,x坐标发生变化
越位检测
if 角色1.x >/< 角色2.x:
角色1.x = 角色2.x