我如何使我的子弹在pygame中移动

时间:2018-07-18 18:03:00

标签: pygame python-3.7

我要尝试做的是使单击时生成的项目符号向上移动到屏幕顶部。我是编程的新手,所以当我尝试在其他地方寻求帮助时,我什么都没理解。下面是到目前为止的代码

#!/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()

预先感谢

0 个答案:

没有答案