I have made a simple 2D game, but when the hero shoots, some of the bullets move faster then others, especially the bullets that come out from the hero's corners (the shape of hero is simple box).
Here is how I wrote the shooting code (I wrote that line just to make sure the bullets go into the right direction). I am using Python 3.5.2.
Run the code and keep shooting randomly everywhere, and you will see that some of them are faster.
import pygame
from pygame.locals import*
import os
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (0,25)
pygame.init()
x=pygame.display.set_mode((1360,705))
clock = pygame.time.Clock()
kx=[]
ky=[]
kx1=[]
ky1=[]
while True :
x.fill((0,0,0))
for event in pygame.event.get():
if event.type==QUIT :
pygame.quit()
quit()
if event.type== pygame.MOUSEBUTTONDOWN and event.button == 1:
xvx=pygame.mouse.get_pos()
xa=(int(xvx[0]))
ya=(int(xvx[1]))
wox=(xa-680)
woy=(ya-352)
ox=wox/70
oy=woy/70
while True :
if xa >= 700 or xa <=660 or ya>=372 or ya<=332 :
xa=xa-ox
ya=ya-oy
else :
break
pygame.draw.line(x,(255,150,100),(xa,ya),(680,352))
kx.append(xa-1)
ky.append(ya-1)
kx1.append(680)
ky1.append(352)
for i in range (len(kx)):
wox=(kx[i]-kx1[i])
woy=(ky[i]-ky1[i])
ox=wox/20
oy=woy/20
kx[i]=kx[i]+ox
ky[i]=ky[i]+oy
kx1[i]=kx1[i]+ox
ky1[i]=ky1[i]+oy
pygame.draw.rect(x,(250,250,250),(kx[i],ky[i],2,2))
pygame.display.update()
clock.tick(60)