0

What I am trying to do is make so that the bullets that spawn when I click move up towards the top of the screen. I am new to programming, so when I tried to look for help elsewhere I found nothing that I could understand. below is my code so far

#!/usr/bin/env python3
#from sys import exit
import sys, pygame, pygame.mixer
from pygame.locals import *
import pygame
from pygame.locals import *
from sys import exit
bkgrnd_img = "cory_in_the_house.png" #change name and picture
mouse_image_filename = "Good_Cory.png"
projectile_thing = "good_bullet"

pygame.init()

screen = pygame.display.set_mode((800,650), 0, 32)
background = pygame.ima`enter code 
here`ge.load(bkgrnd_img).convert()
pygame.display.set_caption("i dont think ur ready")
mouse_cursor = 
pygame.image.load(mouse_image_filename).convert_alpha()

clock = pygame.time.Clock()

speed = 250



screen.blit(background, (0,0))
while True:

    for event in pygame.event.get(): #goes through stored 
pygame events(?)
        if event.type == pygame.QUIT: #checks if user presses x button
            exit()


if (cory_health == 0):
    break


    x, y = pygame.mouse.get_pos()
    x -= mouse_cursor.get_width()/2
    y -= mouse_cursor.get_height()/2
    screen.blit(mouse_cursor, (x, y))

    if(event.type == pygame.MOUSEBUTTONDOWN):
        print("The mouse was clicked")
        x, y = pygame.mouse.get_pos()
        x -= mouse_cursor.get_width()/2
        y -= mouse_cursor.get_height()/2
        screen.blit(mouse_cursor, (x, y))
        screen.blit(pygame.image.load('good_bullet.jpg'), (x, y))



    pygame.display.update()

Thanks in advance

EGG
  • 1
  • What have you tried to implement this? There are already a lot of questions and answers about bullets on Stack Overflow (you can find some in the sidebar on the right) and there are also tutorials on other sites. Have you read any of them? – skrx Jul 18 '18 at 18:40
  • when i tried to implement the code from other i get this: File "C:\Users\Tip\Downloads\programing\practice wubs", line 48 screen.blit(ship,(mx-32,500)) ^ SyntaxError: invalid syntax [Finished in 0.272s] – EGG Jul 18 '18 at 18:57
  • There was a missing parenthesis in the linked example. I've fixed it. – skrx Jul 18 '18 at 19:12
  • where do the parenthesis go – EGG Jul 18 '18 at 19:33
  • The closing parenthesis on the line above was missing. – skrx Jul 18 '18 at 20:39

0 Answers0