From 8ecd8d3af66d104369aceb1f9340bbce840a1e28 Mon Sep 17 00:00:00 2001 From: s444349 Date: Sat, 28 Mar 2020 15:34:30 +0100 Subject: [PATCH] dodano obsluge smieciarki --- game.py | 50 ++++++++++++++++++++++++++++++++++++++- smieciarka_odwrocona.png | Bin 0 -> 22115 bytes 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 smieciarka_odwrocona.png diff --git a/game.py b/game.py index 0e88169..fe59d13 100644 --- a/game.py +++ b/game.py @@ -1,7 +1,37 @@ - import pygame +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) WHITE = (255, 255, 255) @@ -46,6 +76,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 @@ -60,6 +98,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) @@ -76,6 +123,7 @@ while not done: (MARGIN + HEIGHT) * row + MARGIN, WIDTH, HEIGHT]) + all_sprites_list.draw(screen) # Limit to 60 frames per second clock.tick(60) diff --git a/smieciarka_odwrocona.png b/smieciarka_odwrocona.png new file mode 100644 index 0000000000000000000000000000000000000000..ac4a734f8789a10d9117247833d6bec9661c7f5c GIT binary patch literal 22115 zcmeI42T)U6*RVs8-ULOup(-VW-lT_K1nB|-2?<3yL}}7{ks{IsL_t8BfPhFZf)uHO zR6#&GA_4-^zM%K2H}_uVo%!B>{`qFeOp>$q+H0+|pS|`v`()-MO!KNDF#!z$001CX zR+7^~eTyHz@o-R|V*4Y`s4sj+rRy#L03pTk8v~H?fC>O0(6EL;G&QXpkPa?Z4vs)& z2n6Wp>|kMSivR%JM$@z{b+i{LCAQyh%BqI?-dAx%9uHF z{#xT%d3kKw*AGLnqN02w&tKyr3MUxGon?F!74SGTykqZ!=VP0pn(etahvn}i=LT_9N0jUnfV2XJZ(0(YHsB#Pz^v08 zHUrQE0n9G>%nbm1({_?QF#tyQ8P8)pj0FHG5TSAat1Ezl9=&jRfB_HSoP}zOC}0=_ z;8E7MPy#%w1T=J$5tah*hyXm-LW9@=*q#8h*UZdrfWTzHIfXC!;_IA6Wb+&-Qpu&_ zRVT!;kV6d6Pk3IR0(g45*q<7yT7r2bZ_X>`$-QgqFPuNx_gb#0RM_81S zN|ys3E{^JNI3BZ+&y1-W8TmLnJFLTN732j3;bm-2fukn&tV3BD@`xZaLp<>&XI(>N%sYbgd^!UC|-Kw-?NXB2p-GzBk{BbTnEL z(#F%UK!wZSV#~wb+ALcl!i67a-dVy_K$PD~^GvS*t2%7Uyr;w!o7_*n0bdB)RTcrA`U(u&=zWW znL3pUm&%gbm8v*N?Fscj1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