私は pygame で単純なゲームアプリを作成していますが、マウスを押し続けるだけでなく、ユーザーが敵を繰り返しクリックしてインタラクション (射撃など) を行う方法がわかりません。助けてください!これが私のコードです。
import pygame, sys
from pygame.locals import *
from time import *
bif="map.jpg"
enemy="squarecharacter.png"
pygame.init()
screen=pygame.display.set_mode((1000,550), 0, 32)
background=pygame.image.load(bif).convert()
square1=pygame.image.load(enemy).convert_alpha()
square1_x,square1_y=(300,300)
clock=pygame.time.Clock()
speed=50
square_health1=100
while True:
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
screen.blit(background, (0,0))
screen.blit(square1, (square1_x,square1_y))
mousepos_x,mousepos_y=pygame.mouse.get_pos()
button1, button2, button3=pygame.mouse.get_pressed()
if mousepos_x in range((int(square1_x)),(int(square1_x+50))) and mousepos_y in range((int(square1_y)),(int(square1_y+50))):
if button1==1:
square_health1-=10
button1-=1
print str(square_health1)
continue