Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions design.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pygame, random
import os, time, math

ww = False
w = 1200
h = 600
fps = 60
Expand Down Expand Up @@ -189,6 +189,11 @@ def jump(self):
self.change_y = -16
rect = self.rect

def down(self):
global rect
self.change_y = 16
rect = self.rect

# Передвижение игрока
def go_left(self):
global zzz
Expand Down Expand Up @@ -288,6 +293,9 @@ def __init__(self, player):

class Bullet(pygame.sprite.Sprite):
def __init__(self, x, y, speedx):

global ww
ww = True
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load('Стрела.png')
if speedx < 0:
Expand All @@ -298,31 +306,18 @@ def __init__(self, x, y, speedx):
self.speedx = speedx

def update(self):
global ww
global mx, my
self.rect.x += self.speedx
if self.speedx < 0:
mx, my = self.rect.x - 4, self.rect.y + 2
else:
mx, my = self.rect.x + 67, self.rect.y + 2
if self.rect.x > SCREEN_WIDTH + 200:
self.kill()
elif self.rect.x < -200:
self.kill()


class Particles:
def __init__(self, x, y):
mx, my = x, y
particles.append([[mx, my], [random.randint(0, 20) / 10 - 1, -2], random.randint(4, 6)])

def update(self):
particle = particles[0]
particle[0][0] += particle[1][0]
particle[2] -= 0.1
particle[1][1] += 0.1
self.rect = pygame.draw.circle(screen, (226, 88, 34), [int(particle[0][0]), int(particle[0][1])], int(particle[2]))
bullets.add(
self.rect)
pygame.draw.circle(screen, (226, 88, 34), [int(particle[0][0]), int(particle[0][1])], int(particle[2]))
if particle[2] <= 0:
particles.remove(particle)


k = 0
bullets = pygame.sprite.Group()

Expand Down Expand Up @@ -381,6 +376,8 @@ def main():
player.go_right()
if event.key == pygame.K_UP or event.key == pygame.K_w:
player.jump()
if event.key == pygame.K_DOWN or event.key == pygame.K_s:
player.down()

elif event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT and player.change_x < 0 or event.key == pygame.K_a and \
Expand Down Expand Up @@ -421,6 +418,17 @@ def main():
current_level.draw(screen)
active_sprite_list.draw(screen)

if ww:
particles.append([[mx, my], [random.randint(0, 20) / 10 - 1, -2], random.randint(4, 6)])
for particle in particles:
particle[0][1] -= particle[1][0]

particle[2] -= 0.1
particle[1][1] += 0.1
pygame.draw.circle(screen, (226, 88, 34), [int(particle[0][0]), int(particle[0][1])], int(particle[2]))
if particle[2] <= 0:
particles.remove(particle)

# Устанавливаем количество фреймов
clock.tick(30)
# Обновляем экран после рисования объектов
Expand Down