testB
This commit is contained in:
commit
9594bd3981
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
venv/
|
||||
.vscode/
|
||||
.ideagit
|
||||
.idea/
|
||||
.idea
|
56
game.py
56
game.py
@ -1,11 +1,37 @@
|
||||
|
||||
import pygame
|
||||
|
||||
# test2
|
||||
# testujemy
|
||||
# test3
|
||||
# test AdamO
|
||||
# test AdamB
|
||||
|
||||
class Smieciarka(pygame.sprite.Sprite):
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.image = pygame.image.load('smieciarka.png')
|
||||
pygame.sprite.Sprite.__init__(self)
|
||||
self.rect = pygame.Rect(self.x * WIDTH + MARGIN * self.x +
|
||||
MARGIN, self.y * HEIGHT + MARGIN * self.y, WIDTH, HEIGHT)
|
||||
|
||||
def w_lewo(self):
|
||||
if self.x > 0:
|
||||
self.x -= 1
|
||||
self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN
|
||||
self.image = pygame.image.load('smieciarka.png')
|
||||
|
||||
def w_prawo(self):
|
||||
if self.x < 14:
|
||||
self.x += 1
|
||||
self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN
|
||||
self.image = pygame.image.load('smieciarka_odwrocona.png')
|
||||
|
||||
def w_gore(self):
|
||||
if self.y > 0:
|
||||
self.y -= 1
|
||||
self.rect.y = self.y * HEIGHT + self.y * MARGIN
|
||||
|
||||
def w_dol(self):
|
||||
if self.y < 14:
|
||||
self.y += 1
|
||||
self.rect.y = self.y * HEIGHT + self.y * MARGIN
|
||||
|
||||
|
||||
# Define some colors
|
||||
BLACK = (0, 0, 0)
|
||||
@ -51,6 +77,14 @@ done = False
|
||||
# Used to manage how fast the screen updates
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
smieciarka = Smieciarka(10, 10)
|
||||
|
||||
smieciarka_list = pygame.sprite.Group()
|
||||
all_sprites_list = pygame.sprite.Group()
|
||||
|
||||
smieciarka_list.add(smieciarka)
|
||||
all_sprites_list.add(smieciarka)
|
||||
|
||||
# -------- Main Program Loop -----------
|
||||
while not done:
|
||||
for event in pygame.event.get(): # User did something
|
||||
@ -65,6 +99,15 @@ while not done:
|
||||
# Set that location to one
|
||||
grid[row][column] = 1
|
||||
print("Click ", pos, "Grid coordinates: ", row, column)
|
||||
elif event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_LEFT:
|
||||
smieciarka.w_lewo()
|
||||
if event.key == pygame.K_RIGHT:
|
||||
smieciarka.w_prawo()
|
||||
if event.key == pygame.K_UP:
|
||||
smieciarka.w_gore()
|
||||
if event.key == pygame.K_DOWN:
|
||||
smieciarka.w_dol()
|
||||
|
||||
# Set the screen background
|
||||
screen.fill(BLACK)
|
||||
@ -81,6 +124,7 @@ while not done:
|
||||
(MARGIN + HEIGHT) * row + MARGIN,
|
||||
WIDTH,
|
||||
HEIGHT])
|
||||
all_sprites_list.draw(screen)
|
||||
|
||||
# Limit to 60 frames per second
|
||||
clock.tick(60)
|
||||
|
BIN
smieciarka_odwrocona.png
Normal file
BIN
smieciarka_odwrocona.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
Reference in New Issue
Block a user