VIDEO when ever my enemy hitbox collides with the player rect the y position seems to change I'm not sure why its changing and it looks glitchy and messy is there a way I could possibly fix this problem?
so first this line of code checks if hitting is True or Not if its true then if the player collides with the launch1.rec then start moving my boss arms towards the player
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
here if the player is not colliding with the launc1 hitbox then keep the boss arms floating
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
next I checked if my hittings2 is true and the player collidest with the boss arms hitbox to tricker the attack then make attack1 = True
if hittings2:
if playerman.rect.colliderect(arms1.sing1):
attack1 = True
if my attack1 is true then move my boss arms1 a little high and if its grader then 190 turn it off and make attack2 true which will make my boss arms move down and turn of both hittings2 and hittings
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
then here I checked if the attacks2 is true and its not colliding with the collidtest3 rects bottom then keep dropping it down
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
then these 2 block of lines of code below will restart my attacks
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
all the logic that moves the enemy and attack the player in one line
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
from Enemy Arms y Pos Glitches On Attack Pygame How To Fix?
No comments:
Post a Comment