From f99fe6e27c07cb90803c267170de5b5e13b9534c Mon Sep 17 00:00:00 2001 From: PABLO Date: Thu, 8 May 2025 01:29:18 +0300 Subject: [PATCH] fix: movement --- DATA/Sprites/Snake/body.png | Bin 342 -> 308 bytes main.py | 92 ++++++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 36 deletions(-) diff --git a/DATA/Sprites/Snake/body.png b/DATA/Sprites/Snake/body.png index 9d8d66773aabbaa69869d56a6bc37b28aee2a3a3..f3a53f97bed8bf468b6cdd9e9110b926e8682325 100644 GIT binary patch delta 269 zcmV+o0rLLV0<;2DbI2BEigSU}a$9O$@B?2p$4b zhtBQTPL;xx;F=@~kPY8r$w_tR>%{;J27~eM5V6DEd1YwtvVTOs`B?xaHS_XVlrKHG zga|q%CRJL((2Y 0: self.body[i].x = self.body[i-1].x self.body[i].y = self.body[i-1].y - self.body[i].rotate = self.body[i-1].rotate if self.body[i-1] != "body-rotate" else self.convert_rot_to_tail(self.body[i-1].rotate, self.body[i].rotate) + self.body[i].rotate = self.body[i-1].rotate + self.body[i].type = self.body[i-1].type + i -= 1 - self.body[i].type = self.body[i-1].type - - # elif (self.body[i].type == "tail") and self.body[i-1].type == "body-rotate": - # self.body[l].rotate = self.convert_rot_to_tail(self.body[l-1].rotate, self.body[l].rotate) - - i = i - 1 - - self.body[0].rotate = vector * 90 self.body[0].x = int(math.cos(math.radians(self.body[0].rotate))) + self.body[0].x self.body[0].y = int(math.sin(math.radians(self.body[0].rotate))) + self.body[0].y @@ -102,14 +122,14 @@ class SNAKE(): self.body[1].type = "body-rotate" self.body[1].rotate = self.calculate_rot(self.body[0].rotate, self.body[1].rotate) else: - self.body[1].type = "body" - - - self.body[l].type = "tail" - # self.body[l].rotate = lf.body[l-1].type == "body-rotate" else self.body[l-1].rotate - # print(f"Move {vector}") + self.body[1].type = "body" + + self.body[len(self.body)-1 ].type = "tail" + self.body[len(self.body)-1 ].rotate = self.calc_tail_rotate() + + class Level_data(): def __init__(self, level_data_json = []): if level_data_json: @@ -176,8 +196,8 @@ class MYGAME(arcade.Window): # Загрузка пола for floor in self.Lvl_data.floor: floor_sprite = arcade.Sprite(floor["sprite"], self.scale_) - floor_sprite.center_x = self.level_start[0] - 16 + ( floor["x"] + 1 ) * 32 * self.scale_ - floor_sprite.center_y = self.level_start[1] - 16 + ( floor["y"] + 1 ) * 32 * self.scale_ + floor_sprite.center_x = self.level_start[0] - 16 + ( floor["x"] + 1 ) * 32 * self.scale_ + floor_sprite.center_y = self.level_start[1] - 16 + ( floor["y"] + 1 ) * 32 * self.scale_ self.floor_list.append(floor_sprite) # Загрузка врагов @@ -221,7 +241,7 @@ class MYGAME(arcade.Window): self.food_list[i].kill() self.food.pop(i) self.score += 1 - self.snake.add_dody() + self.snake.add_body() self.player_list.append(arcade.Sprite()) i += 1 # Enemy_spawn