Форум сайта python.su
import pygame
SCREEN_WIDTH = 1920
SCREEN_HEIGHT = 1080
class Fighter():
def __init__(self,x,y):
self.attack_type = 0
self.health = 100
def move(self, screen_width, screen_height, surface, event, round_over):
self.attack_type = 0
clock = pygame.time.Clock()
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT))
pygame.display.set_caption(“Hell Knight”)
icon = pygame.image.load('image/icon.png')
pygame.display.set_icon(icon)
forest2 = pygame.image.load('image/FOREST2.jpg')
player = pygame.image.load('image/PLAYER.png')
walk_left = [
pygame.image.load('image/Run_left/1.png'),
pygame.image.load('image/Run_left/2.png'),
pygame.image.load('image/Run_left/3.png'),
pygame.image.load('image/Run_left/4.png'),
]
walk_right = [
pygame.image.load('image/Run/1.png'),
pygame.image.load('image/Run/2.png'),
pygame.image.load('image/Run/3.png'),
pygame.image.load('image/Run/4.png')
]
stand = [
pygame.image.load('image/PLAYER.png')
]
player_anim_count = 0
player_speed = 30
player_x = 250
player_y = 730
is_Jump = False
Jump_count = 13
surface = pygame.Surface((170,128))
bg_sound = pygame.mixer.Sound('sounds/dima-koltsov-hidden.mp3')
bg_sound.play()
running = True
while running:
self = 2
pygame.display.update()
screen.blit(forest2, (0,0))
keys = pygame.key.get_pressed()
if keys:
screen.blit(walk_left, (player_x,player_y))
elif keys:
screen.blit(walk_right, (player_x, player_y))
else:
screen.blit(stand, (player_x, player_y))
if keys:
player_x -= player_speed
elif keys:
player_x += player_speed
if not is_Jump:
if keys:
is_Jump = True
else:
if Jump_count >= -13:
if Jump_count > 0:
player_y -= (Jump_count ** 2) / 2
else:
player_y += (Jump_count ** 2) / 2
Jump_count -= 2
else:
is_Jump = False
Jump_count = 13
if player_anim_count == 3:
player_anim_count = 0
else:
player_anim_count += 1
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
# Вот основное место ошибок:
elif event.type == pygame.MOUSEBUTTONDOWN:
self.attack(surface)
if event.type == 1:
self.attack_type = 1
if event.type == 3:
self.attack_type = 2
clock.tick(10)
def attack(self,surface):
attacking_rect = pygame.Rect(self.rect.centerx, self.rect.y, 2 * self.rect.width, self.rect.height)
pygame.draw.rect(surface, (0,255,0), attacking_rect)
def draw (self,surface):
pygame.draw.rect(surface)
Офлайн
Оберните код тег код - ничо ж не ясно
Офлайн