I am a programing beginner. Recently I've been trying to create a simple game by using pygame, I've managed to describe a bullet and move it. However, I can't move this bullet as I expected. Although I would like to move this bullet describing a parabola curve, I can't rotate a bullet and move like a parabola. So, the code is as below.
import pygame
import math
# each variables
pmsl_no = 0
pmsl_MAX = 10
pmsl_f = [False]*pmsl_MAX
pmsl_x = [0]*pmsl_MAX
pmsl_y = [0]*pmsl_MAX
pmsl_xx = [0]*pmsl_MAX
pmsl_yy = [0]*pmsl_MAX
pmsl_deg = [0]*pmsl_MAX
# set bullet
def set_fire(a):
global pmsl_no, pmsl_deg
while True:
if pmsl_f[pmsl_no] == False:
pmsl_f[pmsl_no] = True
if player_f[pmsl_no] == True:
pmsl_deg[pmsl_no] += math.pi / 50
if pmsl_deg[pmsl_no] >= 2*math.pi:
pmsl_deg[pmsl_no] -= math.pi / 50
pmsl_x[pmsl_no] = player_x[pmsl_no] + 100
pmsl_y[pmsl_no] = player_y[pmsl_no] + 115
d = abs(distance_e() - player_x[pmsl_no])
pmsl_xx[pmsl_no] = d * (pmsl_deg[pmsl_no] - math.sin(math.radians(pmsl_deg[pmsl_no]))) / (2 * math.pi) / 50
pmsl_yy[pmsl_no] = a * (1 - math.cos(math.radians(pmsl_deg[pmsl_no]))) / 50
break
pmsl_no = (pmsl_no+1) % pmsl_MAX
#bring bullet
def bring_pmsl():
if tmr % 1000 == 0:
set_fire(10)
# shoot bullet
def move_pmsl():
for i in range(pmsl_MAX):
if pmsl_f[i] == True:
d = abs(distance_e() - player_x[pmsl_no])
h = d*math.sin(pmsl_deg[i])/(2*10*math.pi)*(1-math.cos(pmsl_deg[i]))
pmsl_x[i] = pmsl_x[i] + pmsl_xx[i]
pmsl_y[i] = pmsl_y[i] - pmsl_yy[i]
image = pygame.transform.scale(img_weapon, (20, 10)).convert_alpha()
image2 = pygame.transform.rotate(image, h)
screen.blit(image2, [pmsl_x[i], pmsl_y[i]])
# main loop
running = True
while running:
tmr += 1
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
screen = pygame.display.set_mode((X, Y))
elif event.key == pygame.K_RETURN:
screen = pygame.display.set_mode((X, Y))
screen.fill((230, 230, 230))
pygame.display.update()
clock.tick(500)
※ I omit some codes which have nothing to do with this problem.
I have no error massage but I can't move bullet as I expected. So, what should I do to solve this problem? If you know about that, please let me know.
Tips: version: python ver.3.6