# My Projectiles Stop Shooting Problem How To Fix?

Stack Overflow Asked by Habib Ismail on November 19, 2020

VIDEO When my player distance is a little farther than the knife they stop shooting at the player I am not sure why? How could I fix it and make sure it shoots where ever the player distance is. Like I don’t want it to stop shooting when the player is a little farther away from the projectile I am not sure if I have a range for it to shoot the player or maybe when my player scrolls
when it stops shooting at the player the shooting sound still plays but my projectiles aren’t shooting and that causes my sound to keep playing rapidly.

This is how my enemies shoot:


for shootss in shootsright:
shootss.x += shootss.xspeed
shootss.y += shootss.yspeed

if shootss.x > 700 or shootss.x < 0 or shootss.y > 500 or shootss.y < 0:
shootsright.pop(shootsright.index(shootss))
shootss.lookAt((playerman.x,playerman.y))

if box1.health > 25:
if len(shootsright) < 1:
for enemyshoot in enemyshooting:
BULLET_SPEED = 10
start_x = round(enemyshoot.x+enemyshoot.width+-35)
start_y = round(enemyshoot.y + enemyshoot.height+-25)
target_x = playerman.x+playerman.width//2
target_y = playerman.y+playerman.width//2
delta_x, delta_y = target_x - start_x, target_y - start_y
distance = math.sqrt(delta_x ** 2 + delta_y ** 2)
dir_x = BULLET_SPEED * delta_x / distance
dir_y = BULLET_SPEED * delta_y / distance
distance = math.sqrt(dir_x**2 + dir_y**2)
knifesound.play()
if distance > 0:
shootsright.append(enemyboolss(start_x,start_y,(0,0,0),dir_x, dir_y))



This is the class for the projectile:



class projectile(object):
def __init__(self, x, y, dirx, diry, color):
self.x = x
self.y = y
self.dirx = dirx
self.diry = diry
self.isJump = False
self.slash = pygame.transform.scale(self.slash,(self.slash.get_width()//6,self.slash.get_height()//6))
self.rect  = self.slash.get_rect()
self.rect.topleft = ( self.x, self.y )
self.speed = 18
self.color = color
self.hitbox = (self.x + -18, self.y, 46,60)
def move(self):
self.x += self.dirx * self.speed
self.y += self.diry * self.speed
def draw(self, window):
self.rect.topleft = (round(self.x), round(self.y))

window.blit(self.slash, self.rect)
self.hitbox = (self.x + -18, self.y, 30,30)



my full code: script

Your screen is 800x800, but the knife code is checking 700x500. The knife projectile is created but immediately removed from the knife list at the next loop:

if shootss.x > 700 or shootss.x < 0 or shootss.y > 500 or shootss.y < 0:
shootsright.pop(shootsright.index(shootss))
shootss.lookAt((playerman.x,playerman.y))


This causes the knife flash but no movement for knives past 700. After setting the check to 800, the knives worked correctly including sound.

Correct answer by Mike67 on November 19, 2020

## Related Questions

### XSRF-TOKEN not added to cookies by Angular (Client side) when .NET core API returns a response with an XSRF-TOKEN

1  Asked on January 11, 2021 by amit-singh-rawat

### Why an infinite loop forms in the piece of JavaScript code below?

1  Asked on January 11, 2021 by jay-sinha

### Seperate strings with regex and panda

1  Asked on January 11, 2021 by sara-daniel

1  Asked on January 11, 2021 by gram77

### Using LIKE with multiple columns in a table

3  Asked on January 10, 2021 by soldfor

### Does the value of global variable persist in multiple API calls

2  Asked on January 10, 2021 by shubroto-shuvo

### React Component not rendering to HTML

1  Asked on January 10, 2021 by red-apple

### Human::name’ should be initialized in the member initialization list [-Werror=effc++]|

0  Asked on January 10, 2021 by unicornbutt

### How can I count a pandas dataframe over duplications

4  Asked on January 10, 2021 by toby-chamberlain

### split list elements into sublists based on character in list element

3  Asked on January 10, 2021

### javascript .eval() gives me undifined

2  Asked on January 10, 2021 by nourza

### Vuejs-nuxt (SSR Mode) not able to get UserUUID through getter inside plugins. It shows undefined for GetUserUUID

1  Asked on January 10, 2021 by ritesh-naik

### Loop for column names in python

3  Asked on January 10, 2021 by essegn

### Javascript Regex, Add space before and after math operators if there is none

1  Asked on January 10, 2021 by mister-sircode

### How to force the redirection to a new window or tab in a mobile phone browser?

2  Asked on January 10, 2021

### How to produce mAP metrics of a test image with bounding box coordinates and ground truth coordinates from COCO json in Tensorflow?

0  Asked on January 10, 2021 by alperen-aksu

### Return array of values from object based on array

2  Asked on January 9, 2021 by user4584963

### How do I get out of ‘screen’ without typing ‘exit’?

5  Asked on January 9, 2021 by meder-omuraliev

### XSLT transform: Conditional copy of a child node based on a set of criteria

1  Asked on January 9, 2021 by shuaipeng-zhang

### How can I regroup ‘sublists’ in a list with Python?

2  Asked on January 9, 2021 by zhengrong