I'd like to create multiple objects from 1 variable. I'm doing a shooting game :p Here is my code (not all of it :D) :
The first things
dx = math.cos(math.radians(direction))
dy = math.sin(math.radians(direction))
if ball_independant == False:
ball_x = x
ball_y = y
This is for the ball (bullet) to go off in a single direction independant of my spaceship.
# BALL DEPLACEMENT
if space:
ball_independant = True
ball_exist = True
if ball_exist == True:
gameDisplay.blit(ball_draw, (ball_x, ball_y))
if d_ball_limit == False:
ball_direction = direction
d_ball_x = math.cos(math.radians(direction))
d_ball_y = math.sin(math.radians(direction))
d_ball_limit = True
ball_direction_set = True
ball_y -= int(ball_velocity * d_ball_x)
ball_x -= int(ball_velocity * d_ball_y)
Direction is the direction of my spaceship BEFORE I launch the ball. So after, the ball's direction dosent change, it goes strait on. For the ball, I use a pygame.image.load so I can after rotate it. Which I can't with a draw.rect I think
So I'd like to when Space is pushed, I create some balls that take the direction of the spaceship and NEVER CHANGE DIRECTION after.
I saw on google things like Sprites, but I don't understand it and I don't wanna redo my code again :D So if it's possible to do it without to much changing, it would be awesome !! Thanks !