敌人武器y姿势在攻击Pygame时闪光如何修复



视频当我的敌人命中框与玩家发生碰撞时,y的位置似乎发生了变化。我不确定为什么它会发生变化,看起来有故障和混乱。有办法解决这个问题吗?

因此,首先这行代码检查击球是真是假,如果是真的,然后如果玩家与发射1相撞。rec,然后开始将我的老板手臂移向玩家


if hitting:
if playerman.rect.colliderect(launch1.rect):
if arms1.x < playerman.x  - 170:
arms1.x += playerman.speed
if arms1.x > playerman.x - 190:
arms1.x -= playerman.speed
arms1.y = math.cos(math.radians(arms1.time)) * 95
arms1.time += 1

在这里,如果玩家没有与发射命中框碰撞,那么保持老板的手臂浮动


if not playerman.rect.colliderect(launch1.rect) and not attacks2 and not pausemove:
arms1.y =  math.cos(math.radians(arms1.time)) * 95
arms1.time += 1

接下来我检查了我的击球2是否是真的,玩家与老板的手臂碰撞以欺骗攻击,然后进行攻击1=真


if hittings2:
if playerman.rect.colliderect(arms1.sing1):
attack1 = True

如果我的攻击1是真的,那么把我的老板手臂1移得高一点,如果它的分级机190把它关掉,把攻击2变成真的,这会让我老板手臂向下移动,同时转动打击2和打击

if attack1:
hittings2 = False
arms1.y = math.cos(math.radians(arms1.time3)) * 95
arms1.time3 += 1
if arms1.time3 >= 190:
attack1 = False
arms1.time3 = 0
attacks2 = True
hittings2 = False
hitting = False 

然后在这里我检查了attacks2是否为真,它是否与collidtest3矩形底部碰撞,然后继续将其放入

if attacks2:
if not arms1.rect.bottom > collidtest3.rect.bottom:
arms1.y += math.cos(math.radians(arms1.time)) * 15
arms1.time += 1
if arms1.time >= 190:
arms1.time = 0

然后下面这两行代码将重新启动我的攻击

if arms1.rect.colliderect(collidtest3.rect):
pausemove = True
attacks2 = False
attack1 = False
if pausemove:
if attack1timer < 270:
attack1timer += 1
arms1.y -= 1
hittings2 = False
else:
hitting = True
hittings2 = True
pausemove = False
attack1timer = 0
if attack1:
arms1.time = 0

在一行中移动敌人并攻击玩家的所有逻辑

if hitting:
if playerman.rect.colliderect(launch1.rect):
if arms1.x < playerman.x  - 170:
arms1.x += playerman.speed
if arms1.x > playerman.x - 190:
arms1.x -= playerman.speed
arms1.y = math.cos(math.radians(arms1.time)) * 95
arms1.time += 1

if not playerman.rect.colliderect(launch1.rect) and not attacks2 and not pausemove:
arms1.y =  math.cos(math.radians(arms1.time)) * 95
arms1.time += 1
if hittings2:
if playerman.rect.colliderect(arms1.sing1):
attack1 = True

if attack1:
hittings2 = False
arms1.y = math.cos(math.radians(arms1.time3)) * 95
arms1.time3 += 1
if arms1.time3 >= 190:
attack1 = False
arms1.time3 = 0
attacks2 = True
hittings2 = False
hitting = False 

if attacks2:
if not arms1.rect.bottom > collidtest3.rect.bottom:
arms1.y += math.cos(math.radians(arms1.time)) * 15
arms1.time += 1
if arms1.time >= 190:
arms1.time = 0

if arms1.rect.colliderect(collidtest3.rect):
pausemove = True
attacks2 = False
attack1 = False

if pausemove:
if attack1timer < 270:
attack1timer += 1
arms1.y -= 1
hittings2 = False
else:
hitting = True
hittings2 = True
pausemove = False
attack1timer = 0
if attack1:
arms1.time = 0

很难说,因为你还没有解释什么都是。手臂上挂着的绿色部分吗?如果是这样的话,那么我认为问题就在这里,你将手臂1.y移动cos(手臂1.time(的位置。击球似乎是在进行任何碰撞检查之前设置的,所以我不明白它设置在哪里。

if hitting:
if playerman.rect.colliderect(launch1.rect):
if arms1.x < playerman.x  - 170:
arms1.x += playerman.speed
if arms1.x > playerman.x - 190:
arms1.x -= playerman.speed
arms1.y = math.cos(math.radians(arms1.time)) * 95
arms1.time += 1

最新更新