From 1e8cc3a193615960c3107efefb9671be821069ac Mon Sep 17 00:00:00 2001 From: pi3c Date: Sun, 10 Dec 2023 01:10:49 +0300 Subject: [PATCH] lesson6 refactoring in oop style, add food --- part2_OOP/lesson6/app.py | 4 + part2_OOP/lesson6/snake/__init__.py | 0 part2_OOP/lesson6/snake/config.py | 7 ++ part2_OOP/lesson6/snake/food.py | 25 +++++ part2_OOP/lesson6/snake/game.py | 89 +++++++++++++++++ part2_OOP/lesson6/{ => snake}/img/bg.png | Bin part2_OOP/lesson6/{ => snake}/img/body_h.png | Bin .../lesson6/{ => snake}/img/body_ld_ur.png | Bin .../lesson6/{ => snake}/img/body_lu_dr.png | Bin .../lesson6/{ => snake}/img/body_rd_ul.png | Bin .../lesson6/{ => snake}/img/body_ru_dl.png | Bin part2_OOP/lesson6/{ => snake}/img/body_v.png | Bin part2_OOP/lesson6/snake/img/mouse1.png | Bin 0 -> 15052 bytes part2_OOP/lesson6/snake/img/mouse2.png | Bin 0 -> 15699 bytes .../lesson6/{ => snake}/img/snake_down.png | Bin .../lesson6/{ => snake}/img/snake_left.png | Bin .../lesson6/{ => snake}/img/snake_right.png | Bin .../lesson6/{ => snake}/img/snake_up.png | Bin part2_OOP/lesson6/{game.py => snake/snake.py} | 93 ++++++------------ 19 files changed, 154 insertions(+), 64 deletions(-) create mode 100644 part2_OOP/lesson6/app.py create mode 100644 part2_OOP/lesson6/snake/__init__.py create mode 100644 part2_OOP/lesson6/snake/config.py create mode 100644 part2_OOP/lesson6/snake/food.py create mode 100644 part2_OOP/lesson6/snake/game.py rename part2_OOP/lesson6/{ => snake}/img/bg.png (100%) rename part2_OOP/lesson6/{ => snake}/img/body_h.png (100%) rename part2_OOP/lesson6/{ => snake}/img/body_ld_ur.png (100%) rename part2_OOP/lesson6/{ => snake}/img/body_lu_dr.png (100%) rename part2_OOP/lesson6/{ => snake}/img/body_rd_ul.png (100%) rename part2_OOP/lesson6/{ => snake}/img/body_ru_dl.png (100%) rename part2_OOP/lesson6/{ => snake}/img/body_v.png (100%) create mode 100644 part2_OOP/lesson6/snake/img/mouse1.png create mode 100644 part2_OOP/lesson6/snake/img/mouse2.png rename part2_OOP/lesson6/{ => snake}/img/snake_down.png (100%) rename part2_OOP/lesson6/{ => snake}/img/snake_left.png (100%) rename part2_OOP/lesson6/{ => snake}/img/snake_right.png (100%) rename part2_OOP/lesson6/{ => snake}/img/snake_up.png (100%) rename part2_OOP/lesson6/{game.py => snake/snake.py} (51%) diff --git a/part2_OOP/lesson6/app.py b/part2_OOP/lesson6/app.py new file mode 100644 index 0000000..ed8e376 --- /dev/null +++ b/part2_OOP/lesson6/app.py @@ -0,0 +1,4 @@ +from snake import game + +if __name__ == "__main__": + game.mainloop() diff --git a/part2_OOP/lesson6/snake/__init__.py b/part2_OOP/lesson6/snake/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/part2_OOP/lesson6/snake/config.py b/part2_OOP/lesson6/snake/config.py new file mode 100644 index 0000000..16a5d8e --- /dev/null +++ b/part2_OOP/lesson6/snake/config.py @@ -0,0 +1,7 @@ +class GameConfig: + pass + + +class SnakeConfig: + pass + diff --git a/part2_OOP/lesson6/snake/food.py b/part2_OOP/lesson6/snake/food.py new file mode 100644 index 0000000..1ae21f3 --- /dev/null +++ b/part2_OOP/lesson6/snake/food.py @@ -0,0 +1,25 @@ +import os +import random + +import pygame as pg + + +class Food: + FOOD = ( + pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'mouse1.png')), + pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'mouse2.png')) + ) + + def __init__(self) -> None: + self.x = random.randint(0, 26) * 30 + self.y = random.randint(0, 20) * 30 + self.type = random.choice(self.FOOD) + + + def draw(self, screen): + screen.blit(self.type, (self.x, self.y)) + + def get_coords(self): + return self.x, self.y + + diff --git a/part2_OOP/lesson6/snake/game.py b/part2_OOP/lesson6/snake/game.py new file mode 100644 index 0000000..9bdcc45 --- /dev/null +++ b/part2_OOP/lesson6/snake/game.py @@ -0,0 +1,89 @@ +import os +import time +from random import choice + +import pygame as pg + +from .snake import Snake +from .food import Food + +class Game: + def __init__(self) -> None: + self.screen_widht = 780 + self.screen_hight = 600 + self.clock = pg.time.Clock() + pg.font.init() + self.font = pg.font.SysFont(choice(pg.font.get_fonts()), 72) + self.score = 0 + + self.title = 'Snakessss' + self.done = False + self.bg = pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'bg.png')) + self.screen = pg.display.set_mode((self.screen_widht, self.screen_hight)) + self.fps = 60 + + def game_init(self): + pg.init() + + def set_title(self): + pg.display.set_caption(self.title) + + def set_bg(self): + self.screen.blit(self.bg, (0, 0)) + + def gameover(self): + self.done = True + surf = self.font.render('Game over', True, (20, 20, 20)) + rect = surf.get_rect() + rect.midtop = (390, 250) + self.screen.blit(surf, rect) + pg.display.flip() + time.sleep(5) + pg.quit() + + +def mainloop(): + game = Game() + snake =Snake(90, 300) + foods_array = [] + def update_game_window(): + while len(foods_array) < 2: + food = Food() + if food.get_coords() not in snake.get_coords(): + foods_array.append(food) + + for f in foods_array: + if snake.get_head_coords() == f.get_coords(): + foods_array.remove(f) + snake.length += 1 + + game.set_bg() + snake.draw(game.screen) + for f in foods_array: + f.draw(game.screen) + + pg.display.update() + + if snake.impacted: + game.gameover() + + while not game.done: + for event in pg.event.get(): + if event.type == pg.QUIT: + game.done = True + pressed = pg.key.get_pressed() + if pressed[pg.K_UP]: + if snake.direction != 'down': + snake.direction = 'up' + if pressed[pg.K_DOWN]: + if snake.direction != 'up': + snake.direction = 'down' + if pressed[pg.K_LEFT]: + if snake.direction != 'right': + snake.direction = 'left' + if pressed[pg.K_RIGHT]: + if snake.direction != 'left': + snake.direction = 'right' + + update_game_window() + game.clock.tick(game.fps) diff --git a/part2_OOP/lesson6/img/bg.png b/part2_OOP/lesson6/snake/img/bg.png similarity index 100% rename from part2_OOP/lesson6/img/bg.png rename to part2_OOP/lesson6/snake/img/bg.png diff --git a/part2_OOP/lesson6/img/body_h.png b/part2_OOP/lesson6/snake/img/body_h.png similarity index 100% rename from part2_OOP/lesson6/img/body_h.png rename to part2_OOP/lesson6/snake/img/body_h.png diff --git a/part2_OOP/lesson6/img/body_ld_ur.png b/part2_OOP/lesson6/snake/img/body_ld_ur.png similarity index 100% rename from part2_OOP/lesson6/img/body_ld_ur.png rename to part2_OOP/lesson6/snake/img/body_ld_ur.png diff --git a/part2_OOP/lesson6/img/body_lu_dr.png b/part2_OOP/lesson6/snake/img/body_lu_dr.png similarity index 100% rename from part2_OOP/lesson6/img/body_lu_dr.png rename to part2_OOP/lesson6/snake/img/body_lu_dr.png diff --git a/part2_OOP/lesson6/img/body_rd_ul.png b/part2_OOP/lesson6/snake/img/body_rd_ul.png similarity index 100% rename from part2_OOP/lesson6/img/body_rd_ul.png rename to part2_OOP/lesson6/snake/img/body_rd_ul.png diff --git a/part2_OOP/lesson6/img/body_ru_dl.png b/part2_OOP/lesson6/snake/img/body_ru_dl.png similarity index 100% rename from part2_OOP/lesson6/img/body_ru_dl.png rename to part2_OOP/lesson6/snake/img/body_ru_dl.png diff --git a/part2_OOP/lesson6/img/body_v.png b/part2_OOP/lesson6/snake/img/body_v.png similarity index 100% rename from part2_OOP/lesson6/img/body_v.png rename to part2_OOP/lesson6/snake/img/body_v.png diff --git a/part2_OOP/lesson6/snake/img/mouse1.png b/part2_OOP/lesson6/snake/img/mouse1.png new file mode 100644 index 0000000000000000000000000000000000000000..73e776a8f5ef75527a1560850d5f7a6279c0fbbb GIT binary patch literal 15052 zcmeIYWmKC@7d4DaaHqJtyGw9)ij`skf@^ViC~hrM+}+*1cyS68cX#hg@5k5o{(08= z-hWTBuH?$hIs2TmXU`UURaHH@ zKELh-Z0^bZh`fIG_SrZRqxUsLdpNSXTR_CDdbO2uy}msvcrjRdX;;6OJo4rp7-hGM z{Mh*XxaIV_CjRC5=oboJM(&JEC&@7xy-x+tfr>mQ>`>y@&iRouMSkwrSMS+l_I7)L z&4q%)GPO|rjfI6w-R@5A-_O9QoSl%5wij2$d=F($GiUa}ew#at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ake/img/mouse2.png b/part2_OOP/lesson6/snake/img/mouse2.png new file mode 100644 index 0000000000000000000000000000000000000000..7b57c26a1f51c04d171d4f86cb82ebf467ecccfb GIT binary patch literal 15699 zcmeHtWmKG7(r)A0I0Schmj;4+a1ty8X&QHThaiFA8r&Tc++Bh@1b2c%aJ?kw%zQKJ zet%}Id;d-MdTsBjXIDMDcD=GHOhrish)jqK004k;vXW{qN7COLBK*rb&(+8*P`|2(JD`%y5p>!{ zrEnIE+fDDHr>&H}qA@o#W%v2}2@I4cvN z)wGRuLb~3})`#1l4$rMJC+*KSo>Z{Sdz)0Nq$^TtciPsIWAP@)Q6j?^-;{iY6*T?3T7yYmGeyy%ztZavNWqO|7yKWEq0)6l9QPwlPZso{N zPR@K=cdt(#1|Khj^?mO&l^&m_+8y`j4&+|lIWAmYpRBjHl74UhpxiD(`&65w?d$9C z@XNU?DEOcOz0mSLtMtQG`&0LCt6GbLZz#;Z!Ox zUvJ}$p(Hm}36aCRVF=Oa{c=Ec53#b<18FX%ck8Tr1l5lSTbC_GG`>3SN!mc8uSs?S zy{nc;CyxF1{3z+@EB>y19lc#cj6MzezBj&)XZmbTm5f}ltG*|=2jL~GiP-}`HCLoW zyB-r{wyjSq$)2B1hVIK!A(n!C{Ev66)$%uV^|7A*N-fo=_nM^HN2|ecw})Lu;*`*B zAsXWOeMVLkRiD#u-n=7?8?wg?P?29M(#6$nRgSW z4D_!dK)o~>czE!mQiag%@d6!NS;OS_(z2!>`<7+qd7mLn@5;674X2J8rr;Z0maVUa zuY}g4<>@jV_RR}3?RRKqY?^Kpb#0p;qXd0rj-+NDalbu(T6z|+Sf{gq9d1pAtXwcz zv@HFoRDkW2QymV~8ukz6lky9S3Qswq*ex0m=p9CfvJETyO3yDyZzRc{i7^Ch2VX01 zJyF?2H9faS>OOEeC}rP2V+s_GKPC-4nl3#lOka83iQbSG0QE8NByX2zX+6i?WhTg^ z;b5QL@-1ax^8*tSdsv8(n==m6Kh(FOrEn^|Ha}LI4dcQ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)0mz1?EBEm16YxeM4s~c^O5~= zhe9x{Gz{2bvx`$2bXEmx`6?=HP3&Yju!ep10^kj}@3PPdrPTru&_3c-B$6XyMhEMU znyY@GJyq)?-x<5^I!KsU5b!g@j`^Y%n!4|y1Ok^HF?a1WV%CWU(kLK-*`bi|9|93k zh=OKHdN&#{={fBlo6r{P(5Wb)qanB`0BNZANJzNJ{1dj%PYrSq%+_Q6NAP_v3#%3r$G_`J*TTcaE8Nw%t?iei?E zTSo>tQU(ZDqPf-E0{NZB`{B4k@K2Y(50!WRB|HW1UuTB9AhCBa(k_*6#NX(`f za?c*-M_c(u7hvK@d4CVnX>2M}U0iIrV*t20J~W@z5>*=-bNRV2QCzT!e&=P-3nBUT z?UMQ}GXvDG^U-0nnu^h`$w{W+?>hYo+ZM4Q6IS`EFmf6aJG9AM?5q%mO95ngG@8Ne1t)`pO}aV9Ugv^Rf>}K zeI^eGjC@;NUHw@J1r=aZFF0mX-%f}P4j9=HeQG3TR%Q}conZIypefUT1uNqS|6$>j z7Yl2|%+gxMNNq!J+?-d_Ac%#Y9-nPBY}2#R_L=c`xjwxA^AYJP8#A-9fwbfBs344J mdH$7uk~VYV0?gCNT&B1w7xRn(+1N|c1jtD#Nmhs(1pFV0H|zWW literal 0 HcmV?d00001 diff --git a/part2_OOP/lesson6/img/snake_down.png b/part2_OOP/lesson6/snake/img/snake_down.png similarity index 100% rename from part2_OOP/lesson6/img/snake_down.png rename to part2_OOP/lesson6/snake/img/snake_down.png diff --git a/part2_OOP/lesson6/img/snake_left.png b/part2_OOP/lesson6/snake/img/snake_left.png similarity index 100% rename from part2_OOP/lesson6/img/snake_left.png rename to part2_OOP/lesson6/snake/img/snake_left.png diff --git a/part2_OOP/lesson6/img/snake_right.png b/part2_OOP/lesson6/snake/img/snake_right.png similarity index 100% rename from part2_OOP/lesson6/img/snake_right.png rename to part2_OOP/lesson6/snake/img/snake_right.png diff --git a/part2_OOP/lesson6/img/snake_up.png b/part2_OOP/lesson6/snake/img/snake_up.png similarity index 100% rename from part2_OOP/lesson6/img/snake_up.png rename to part2_OOP/lesson6/snake/img/snake_up.png diff --git a/part2_OOP/lesson6/game.py b/part2_OOP/lesson6/snake/snake.py similarity index 51% rename from part2_OOP/lesson6/game.py rename to part2_OOP/lesson6/snake/snake.py index 81e4777..8e20498 100644 --- a/part2_OOP/lesson6/game.py +++ b/part2_OOP/lesson6/snake/snake.py @@ -1,40 +1,40 @@ import os -import time + import pygame as pg -pg.init() -pg.display.set_caption("First Game") -screen = pg.display.set_mode((780, 600)) -done = False - -FPS = 60 # Создаем переменную FPS -clock = pg.time.Clock() # Создаем счетчик для FPS -bg = pg.image.load(os.path.join(os.curdir, 'img', 'bg.png')) -snake_head = { - 'left': pg.image.load(os.path.join(os.curdir, 'img', 'snake_left.png')), - 'right': pg.image.load(os.path.join(os.curdir, 'img', 'snake_right.png')), - 'up': pg.image.load(os.path.join(os.curdir, 'img', 'snake_up.png')), - 'down': pg.image.load(os.path.join(os.curdir, 'img', 'snake_down.png')), -} -snake_body = { - 'h': pg.image.load(os.path.join(os.curdir, 'img', 'body_h.png')), - 'v': pg.image.load(os.path.join(os.curdir, 'img', 'body_v.png')), - 'ru_dl': pg.image.load(os.path.join(os.curdir, 'img', 'body_ru_dl.png')), - 'rd_ul': pg.image.load(os.path.join(os.curdir, 'img', 'body_rd_ul.png')), - 'lu_dr': pg.image.load(os.path.join(os.curdir, 'img', 'body_lu_dr.png')), - 'ld_ur': pg.image.load(os.path.join(os.curdir, 'img', 'body_ld_ur.png')), -} class Snake: def __init__(self, x, y) -> None: self.x = x self.y = y + self.snake_head = { + 'left': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'snake_left.png')), + 'right': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'snake_right.png')), + 'up': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'snake_up.png')), + 'down': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'snake_down.png')), + } + self.snake_body = { + 'h': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'body_h.png')), + 'v': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'body_v.png')), + 'ru_dl': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'body_ru_dl.png')), + 'rd_ul': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'body_rd_ul.png')), + 'lu_dr': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'body_lu_dr.png')), + 'ld_ur': pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'body_ld_ur.png')), + } + self.direction = 'right' self.direction_prev = 'right' - self.length = 2 - self.speed = 30 # скорость движения змейки чем меньше, тем быстрее + self.length = 2 + self.speed = 10 # скорость движения змейки чем меньше, тем быстрее self.counter = 0 # Просто счетчик, для регулировки скорости нужен self.body = [('h', 60, 300), ('h', 30, 300)] + self.impacted = False + + def get_head_coords(self): + return self.x, self.y + + def get_coords(self): + return [(self.x, self.y)] + [(el[1], el[2]) for el in self.body] def draw(self, screen): if len(self.body) > self.length: @@ -80,49 +80,14 @@ class Snake: self.direction_prev = 'down' if (self.x, self.y) in [(x[1], x[2]) for x in self.body]: - gameover() + self.impacted = True + self.counter = 0 self.counter += 1 - screen.blit(snake_head[self.direction], (self.x, self.y)) + screen.blit(self.snake_head[self.direction], (self.x, self.y)) for el in self.body: - screen.blit(snake_body[el[0]], (el[1], el[2])) + screen.blit(self.snake_body[el[0]], (el[1], el[2])) -snake =Snake(90, 300) -def update_game_window(): - screen.blit(bg, (0,0)) - snake.draw(screen) - pg.display.update() - -def gameover(): - go_font = pg.font.SysFont('monaco', 72) - go_surf = go_font.render('Game over', True, (20, 20, 20)) - go_rect = go_surf.get_rect() - go_rect.midtop = (360, 15) - screen.blit(go_surf, go_rect) - pg.display.flip() - time.sleep(5) - pg.quit() - -while not done: - for event in pg.event.get(): - if event.type == pg.QUIT: - done = True - pressed = pg.key.get_pressed() - if pressed[pg.K_UP]: - if snake.direction != 'down': - snake.direction = 'up' - if pressed[pg.K_DOWN]: - if snake.direction != 'up': - snake.direction = 'down' - if pressed[pg.K_LEFT]: - if snake.direction != 'right': - snake.direction = 'left' - if pressed[pg.K_RIGHT]: - if snake.direction != 'left': - snake.direction = 'right' - - update_game_window() - clock.tick(FPS)