updatable.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. import pygame
  2. from client_local.const import game as G
  3. from client_local.level import level
  4. import json
  5. from json import JSONDecodeError
  6. import logging
  7. from datetime import datetime
  8. # 配置logging基础配置并设置日志级别为INFO
  9. # logging.basicConfig(filename='move.log', level=logging.INFO)
  10. # 游戏初始化 读取配置文件
  11. try:
  12. with open("config.json", encoding="utf-8") as f:
  13. cfg_json = json.load(f)
  14. except JSONDecodeError:
  15. with open("config.json", encoding="utf-8_sig") as f:
  16. cfg_json = json.load(f)
  17. def move_correction_param(x):
  18. if x <= 0:
  19. return 0
  20. if x >= 19:
  21. return 19
  22. else:
  23. return round(x, 3)
  24. # 半身滑墙校正
  25. G.MOVE_CORRECTION = cfg_json.get("move_correction", 8)
  26. move_correction = move_correction_param(G.MOVE_CORRECTION)
  27. def current_grid(x_pos, y_pos):
  28. x = x_pos // G.GAME_SQUARE
  29. y = y_pos // G.GAME_SQUARE
  30. return int(x), int(y)
  31. class Updatable(pygame.sprite.Sprite):
  32. move_correction = move_correction_param(G.MOVE_CORRECTION)
  33. def __init__(self, x, y):
  34. super(Updatable, self).__init__()
  35. self.x = x
  36. self.y = y
  37. self.x_pos = x * G.GAME_SQUARE + G.HALF_GAME_SQUARE # 中心点x坐标
  38. self.y_pos = y * G.GAME_SQUARE + G.HALF_GAME_SQUARE # 中心点y坐标
  39. self.z_pos = 0 # z轴坐标
  40. if hasattr(self, 'is_ghost'):
  41. if not self.is_ghost:
  42. self.wall_walking = True # 允许穿墙
  43. else:
  44. self.wall_walking = False # 允许穿墙
  45. def if_hide(self):
  46. ret = False
  47. ois = level.current_level.obstacle_instances
  48. if (self.x, self.y) in ois.keys():
  49. an_obstacle = ois[(self.x, self.y)]
  50. if an_obstacle.obstacle_can_hide:
  51. self.blank_img()
  52. ret = True
  53. return ret
  54. def is_hide_sight(self):
  55. ret = False
  56. ois = level.current_level.obstacle_instances
  57. # if (self.x, self.y) in ois.keys():
  58. # an_obstacle = ois[(self.x, self.y)]
  59. # if an_obstacle.block_sight:
  60. # self.blank_img()
  61. # ret = True
  62. if (self.x, self.y) in ois.keys():
  63. if ois[(self.x, self.y)].block_sight:
  64. ret = True
  65. return ret
  66. def blank_img(self):
  67. # 清空image
  68. self.image = pygame.Surface((1, 1), pygame.SRCALPHA, 32)
  69. def get_ruld_block(self):
  70. right = self.x_pos + G.HALF_GAME_SQUARE - 1
  71. right_grid = int(right // G.GAME_SQUARE)
  72. top = self.y_pos - G.HALF_GAME_SQUARE
  73. top_grid = int(top // G.GAME_SQUARE)
  74. left = self.x_pos - G.HALF_GAME_SQUARE
  75. left_grid = int(left // G.GAME_SQUARE)
  76. bottom = self.y_pos + G.HALF_GAME_SQUARE - 1
  77. bottom_grid = int(bottom // G.GAME_SQUARE)
  78. return right, right_grid, top, top_grid, left, left_grid, bottom, bottom_grid
  79. def slide(self, update_time_old, district_locked, orientation, slide_speed, top, bottom, left, right, block,
  80. top_grid, bottom_grid, left_grid, right_grid, cl):
  81. slide_speed = min(20, slide_speed * G.GAME_SQUARE / 1000 * (pygame.time.get_ticks() - update_time_old))
  82. if orientation == 1:
  83. self.movement_right(district_locked, slide_speed, top, bottom, right, block, top_grid, bottom_grid, cl)
  84. elif orientation == 2:
  85. self.movement_up(district_locked, slide_speed, top, left, right, block, left_grid, right_grid, cl)
  86. elif orientation == 3:
  87. self.movement_left(district_locked, slide_speed, top, bottom, left, block, top_grid, bottom_grid, cl)
  88. elif orientation == 4:
  89. self.movement_down(district_locked, slide_speed, bottom, left, right, block, left_grid, right_grid, cl)
  90. def movement_right(self, district_locked, speed, top, bottom, right, block, top_grid, bottom_grid, cl):
  91. if right // G.GAME_SQUARE != (right + speed) // G.GAME_SQUARE: # 右侧身位跨格子时
  92. right_screen = right + speed >= cl.map_x_pos # 右侧碰撞屏幕
  93. right_district = self.x_pos + speed >= cl.district_square["x2"]
  94. right_block = block[1][self.x + 1][self.y] # 右侧numpy障碍
  95. right_block_top_0 = self.y != top // G.GAME_SQUARE and block[0][self.x + 1][top_grid + 1] # 右上侧横向障碍
  96. if self.y != top // G.GAME_SQUARE and block[1][self.x + 1][top_grid] == 1 and block[1][self.x + 1][
  97. top_grid + 1] == 0:
  98. right_block_top_1 = True
  99. # logging.info(f'右上正常滑')
  100. else:
  101. if move_correction >= (self.y + 1) * G.GAME_SQUARE - self.y_pos >= 0 and block[1][self.x + 1][self.y] == 1 and block[1][self.x + 1][self.y+1] == 0:
  102. right_block_top_1 = True
  103. # logging.info(f'右上额外滑, (self.y+1)*G.GAME_SQUARE - self.y_pos={(self.y+1)*G.GAME_SQUARE - self.y_pos}')
  104. else:
  105. right_block_top_1 = False
  106. # logging.info(f'右上不滑')
  107. right_block_bottom_0 = self.y != bottom // G.GAME_SQUARE and block[0][self.x + 1][bottom_grid] # 右下侧横向障碍
  108. if self.y != bottom // G.GAME_SQUARE and block[1][self.x + 1][bottom_grid] == 1 and block[1][self.x + 1][
  109. bottom_grid - 1] == 0:
  110. right_block_bottom_1 = True
  111. # logging.info(f'右下正常滑')
  112. else:
  113. if move_correction >= self.y_pos - self.y * G.GAME_SQUARE >= 0 and block[1][self.x + 1][self.y] == 1 and block[1][self.x + 1][self.y-1] == 0:
  114. right_block_bottom_1 = True
  115. # logging.info(f'右下额外滑, (self.y+1)*G.GAME_SQUARE - self.y_pos={(self.y+1)*G.GAME_SQUARE - self.y_pos}')
  116. else:
  117. right_block_bottom_1 = False
  118. # logging.info(f'右下不滑')
  119. right_edge = (right + speed) // G.GAME_SQUARE
  120. right_bomb = len(cl.get_bomb_instance(right_edge, self.y)) # 右侧糖泡
  121. right_bomb_top = len(cl.get_bomb_instance(right_edge, top_grid)) # 右上侧糖泡
  122. right_bomb_bottom = len(cl.get_bomb_instance(right_edge, bottom_grid)) # 右下侧糖泡
  123. if self.wall_walking and not right_screen:
  124. self.x_pos += speed
  125. cl.scroll_map()
  126. if self.wall_walking:
  127. self.x_pos += speed
  128. cl.scroll_map()
  129. if district_locked and right_district and not self.wall_walking:
  130. self.x_pos += min(speed, max(0, right_edge * G.GAME_SQUARE - G.HALF_GAME_SQUARE - self.x_pos))
  131. self.collide_wall()
  132. self.collide_district()
  133. elif right_block > 0 or right_screen or right_bomb > 0 and not self.wall_walking:
  134. self.collide_wall()
  135. if right_block_top_1 > 0:
  136. self.y_pos = min(self.y_pos + speed, (self.y + 1) * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  137. self.try_push("R", (0, -1))
  138. cl.scroll_map()
  139. # logging.info(f'右上拓展执行')
  140. elif right_block_bottom_1 > 0:
  141. self.y_pos = max(self.y_pos - speed, (self.y - 1) * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  142. self.try_push("R", (0, 1))
  143. cl.scroll_map()
  144. # logging.info(f'右下拓展执行')
  145. else:
  146. self.x_pos += min(speed, max(0, right_edge * G.GAME_SQUARE - G.HALF_GAME_SQUARE - self.x_pos))
  147. self.try_push("R")
  148. # logging.info(f'直走执行')
  149. elif right_block_top_0 > 0 or right_block_top_1 > 0 or right_bomb_top > 0 and not self.wall_walking:
  150. self.y_pos = min(self.y_pos + speed, self.y * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  151. self.try_push("R", (0, -1))
  152. # logging.info(f'右上执行')
  153. elif right_block_bottom_0 > 0 or right_block_bottom_1 > 0 or right_bomb_bottom > 0 and not self.wall_walking:
  154. self.y_pos = max(self.y_pos - speed, self.y * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  155. self.try_push("R", (0, 1))
  156. # logging.info(f'右下执行')
  157. else:
  158. self.x_pos += speed
  159. cl.scroll_map()
  160. elif self.x_pos // G.GAME_SQUARE != (self.x_pos + speed) // G.GAME_SQUARE:
  161. if len(level.current_level.get_bomb_instance(self.x + 1, self.y)) == 0 or self.wall_walking:
  162. self.x_pos += speed
  163. cl.scroll_map()
  164. else:
  165. self.x_pos += speed
  166. cl.scroll_map()
  167. def movement_up(self, district_locked, speed, top, left, right, block, left_grid, right_grid, cl):
  168. if top // G.GAME_SQUARE != (top - speed) // G.GAME_SQUARE:
  169. top_screen = top - speed < 0
  170. top_district = self.y_pos - speed < cl.district_square["y1"]
  171. top_block = block[0][self.x][self.y]
  172. top_block_left_1 = self.x != left // G.GAME_SQUARE and block[1][left_grid + 1][self.y - 1]
  173. if self.x != left // G.GAME_SQUARE and block[0][left_grid][self.y] == 1 and block[0][left_grid + 1][
  174. self.y] == 0:
  175. top_block_left_0 = True
  176. # logging.info(f'左上正常滑')
  177. else:
  178. if move_correction >= (self.x + 1) * G.GAME_SQUARE - self.x_pos >= 0 and block[0][self.x][self.y] == 1 and block[0][self.x+1][self.y] == 0:
  179. top_block_left_0 = True
  180. # logging.info(f'左上额外滑')
  181. else:
  182. top_block_left_0 = False
  183. # logging.info(f'左上不滑')
  184. top_block_right_1 = self.x != right // G.GAME_SQUARE and block[1][right_grid][self.y - 1]
  185. if self.x != right // G.GAME_SQUARE and block[0][right_grid][self.y] == 1 and block[0][right_grid - 1][
  186. self.y] == 0:
  187. top_block_right_0 = True
  188. # logging.info(f'右上正常滑')
  189. else:
  190. if move_correction >= self.x_pos - self.x * G.GAME_SQUARE >= 0 and block[0][self.x][self.y] == 1 and block[0][self.x-1][self.y] == 0:
  191. top_block_right_0 = True
  192. # logging.info(f'右上额外滑')
  193. else:
  194. top_block_right_0 = False
  195. # logging.info(f'右上不滑')
  196. # if self.defense == 35000:
  197. # logging.info(f'left={left},right={right},centre(x,y)={(self.x, self.y)},右上0={top_block_right_0},右上1={top_block_right_1},左上0={top_block_left_0}, 左上1={top_block_left_1}, Current time={datetime.now().strftime("%Y-%m-%d %H:%M:%S")}')
  198. top_edge = (top - speed) // G.GAME_SQUARE
  199. top_bomb = len(cl.get_bomb_instance(self.x, top_edge))
  200. top_bomb_left = len(cl.get_bomb_instance(left_grid, top_edge))
  201. top_bomb_right = len(cl.get_bomb_instance(right_grid, top_edge))
  202. if self.wall_walking and not top_screen:
  203. self.y_pos -= speed
  204. cl.scroll_map()
  205. elif district_locked and top_district:
  206. self.y_pos -= min(speed, max(0, top_edge * G.GAME_SQUARE + G.HALF_GAME_SQUARE - self.y_pos))
  207. self.collide_wall()
  208. self.collide_district()
  209. elif top_block > 0 or top_screen or top_bomb > 0:
  210. self.collide_wall()
  211. if top_block_left_0 > 0:
  212. self.x_pos = min(self.x_pos + speed, (self.x + 1) * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  213. self.try_push("U", (-1, 0))
  214. cl.scroll_map()
  215. elif top_block_right_0 > 0:
  216. self.x_pos = max(self.x_pos - speed, (self.x - 1) * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  217. self.try_push("U", (1, 0))
  218. cl.scroll_map()
  219. else:
  220. self.y_pos -= min(speed, max(0, top_edge * G.GAME_SQUARE + G.HALF_GAME_SQUARE - self.y_pos))
  221. self.try_push("U")
  222. elif top_block_left_0 > 0 or top_block_left_1 > 0 or top_bomb_left > 0:
  223. self.x_pos = min(self.x_pos + speed, self.x * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  224. self.try_push("U", (-1, 0))
  225. elif top_block_right_0 > 0 or top_block_right_1 > 0 or top_bomb_right > 0:
  226. self.x_pos = max(self.x_pos - speed, self.x * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  227. self.try_push("U", (1, 0))
  228. else:
  229. self.y_pos -= speed
  230. cl.scroll_map()
  231. elif self.y_pos // G.GAME_SQUARE != (self.y_pos - speed) // G.GAME_SQUARE:
  232. if len(level.current_level.get_bomb_instance(self.x, self.y - 1)) == 0 or self.wall_walking:
  233. self.y_pos -= speed
  234. cl.scroll_map()
  235. else:
  236. self.y_pos -= speed
  237. cl.scroll_map()
  238. def movement_left(self, district_locked, speed, top, bottom, left, block, top_grid, bottom_grid, cl):
  239. if left // G.GAME_SQUARE != (left - speed) // G.GAME_SQUARE:
  240. left_screen = left - speed < 0
  241. left_district = self.x_pos - speed < cl.district_square["x1"]
  242. left_block = block[1][self.x][self.y]
  243. left_block_top_0 = self.y != top // G.GAME_SQUARE and block[0][self.x - 1][top_grid + 1]
  244. if self.y != top // G.GAME_SQUARE and block[1][self.x][top_grid] == 1 and block[1][self.x][
  245. top_grid + 1] == 0:
  246. left_block_top_1 = True
  247. # logging.info(f'左上正常滑')
  248. else:
  249. if move_correction >= (self.y + 1) * G.GAME_SQUARE - self.y_pos >= 0 and block[1][self.x][self.y] == 1 and block[1][self.x][self.y+1] == 0:
  250. left_block_top_1 = True
  251. # logging.info(f'左上额外滑')
  252. else:
  253. left_block_top_1 = False
  254. # logging.info(f'左上不滑')
  255. left_block_bottom_0 = self.y != bottom // G.GAME_SQUARE and block[0][self.x - 1][bottom_grid]
  256. if self.y != bottom // G.GAME_SQUARE and block[1][self.x][bottom_grid] == 1 and block[1][self.x][
  257. bottom_grid - 1] == 0:
  258. left_block_bottom_1 = True
  259. # logging.info(f'左下正常滑')
  260. else:
  261. if move_correction >= self.y_pos - self.y * G.GAME_SQUARE >= 0 and block[1][self.x][self.y] == 1 and block[1][self.x][self.y-1] == 0:
  262. left_block_bottom_1 = True
  263. # logging.info(f'左下额外滑')
  264. else:
  265. left_block_bottom_1 = False
  266. # logging.info(f'左下不滑')
  267. left_edge = (left - speed) // G.GAME_SQUARE
  268. left_bomb = len(cl.get_bomb_instance(left_edge, self.y))
  269. left_bomb_top = len(cl.get_bomb_instance(left_edge, top_grid))
  270. left_bomb_bottom = len(cl.get_bomb_instance(left_edge, bottom_grid))
  271. if self.wall_walking and not left_screen:
  272. self.x_pos -= speed
  273. cl.scroll_map()
  274. if district_locked and left_district:
  275. self.x_pos -= min(speed, max(0, self.x_pos - (left * G.GAME_SQUARE + G.HALF_GAME_SQUARE)))
  276. self.collide_wall()
  277. self.collide_district()
  278. elif left_block > 0 or left_screen or left_bomb > 0:
  279. self.collide_wall()
  280. if left_block_top_1 > 0:
  281. self.y_pos = min(self.y_pos + speed, (self.y + 1) * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  282. self.try_push("L", (0, -1))
  283. cl.scroll_map()
  284. # logging.info(f'左上拓展')
  285. elif left_block_bottom_1 > 0:
  286. self.y_pos = max(self.y_pos - speed, (self.y - 1) * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  287. self.try_push("L", (0, 1))
  288. cl.scroll_map()
  289. # logging.info(f'左下拓展')
  290. else:
  291. self.x_pos -= min(speed, max(0, self.x_pos - (left * G.GAME_SQUARE + G.HALF_GAME_SQUARE)))
  292. self.try_push("L")
  293. # logging.info(f'直走')
  294. elif left_block_top_1 > 0 or left_block_top_0 > 0 or left_bomb_top > 0:
  295. self.y_pos = min(self.y_pos + speed, self.y * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  296. self.try_push("L", (0, -1))
  297. elif left_block_bottom_1 > 0 or left_block_bottom_0 > 0 or left_bomb_bottom > 0:
  298. self.y_pos = max(self.y_pos - speed, self.y * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  299. self.try_push("L", (0, 1))
  300. else:
  301. self.x_pos -= speed
  302. cl.scroll_map()
  303. elif self.x_pos // G.GAME_SQUARE != (self.x_pos - speed) // G.GAME_SQUARE:
  304. if len(level.current_level.get_bomb_instance(self.x - 1, self.y)) == 0 or self.wall_walking:
  305. self.x_pos -= speed
  306. cl.scroll_map()
  307. else:
  308. self.x_pos -= speed
  309. cl.scroll_map()
  310. def movement_down(self, district_locked, speed, bottom, left, right, block, left_grid, right_grid, cl):
  311. if bottom // G.GAME_SQUARE != (bottom + speed) // G.GAME_SQUARE:
  312. bottom_block = block[0][self.x][self.y + 1]
  313. bottom_district = self.y_pos + speed >= cl.district_square["y2"]
  314. bottom_block_right_1 = self.x != right // G.GAME_SQUARE and block[1][int(right // G.GAME_SQUARE)][
  315. self.y + 1]
  316. if self.x != right // G.GAME_SQUARE and block[0][right_grid][self.y + 1] == 1 and block[0][right_grid - 1][
  317. self.y + 1] == 0:
  318. bottom_block_right_0 = True
  319. # logging.info(f'右下正常滑')
  320. else:
  321. if move_correction >= self.x_pos - self.x * G.GAME_SQUARE >= 0 and block[0][self.x][self.y + 1] == 1 and block[0][self.x-1][self.y+1] == 0:
  322. bottom_block_right_0 = True
  323. # logging.info(f'右下额外滑')
  324. else:
  325. bottom_block_right_0 = False
  326. # logging.info(f'右下不滑')
  327. bottom_block_left_1 = self.x != left // G.GAME_SQUARE and block[1][int(left // G.GAME_SQUARE) + 1][
  328. self.y + 1]
  329. if self.x != left // G.GAME_SQUARE and block[0][left_grid][self.y + 1] == 1 and block[0][left_grid + 1][
  330. self.y + 1] == 0:
  331. bottom_block_left_0 = True
  332. # logging.info(f'左下正常滑')
  333. else:
  334. if move_correction >= (self.x + 1) * G.GAME_SQUARE - self.x_pos >= 0 and block[0][self.x][self.y + 1] == 1 and block[0][self.x+1][self.y + 1] == 0:
  335. bottom_block_left_0 = True
  336. # logging.info(f'左下额外滑')
  337. else:
  338. bottom_block_left_0 = False
  339. # logging.info(f'左下不滑')
  340. bottom_screen = bottom + speed >= cl.map_y_pos
  341. bottom_edge = (bottom + speed) // G.GAME_SQUARE
  342. bottom_bomb = len(cl.get_bomb_instance(self.x, bottom_edge))
  343. bottom_bomb_left = len(cl.get_bomb_instance(left_grid, bottom_edge))
  344. bottom_bomb_right = len(cl.get_bomb_instance(right_grid, bottom_edge))
  345. if self.wall_walking and not bottom_screen:
  346. self.y_pos += speed
  347. cl.scroll_map()
  348. elif district_locked and bottom_district:
  349. self.y_pos += min(speed, max(0, self.y_pos - (bottom_edge * G.GAME_SQUARE + G.HALF_GAME_SQUARE)))
  350. self.collide_wall()
  351. self.collide_district()
  352. elif bottom_block > 0 or bottom_screen or bottom_bomb > 0:
  353. self.collide_wall()
  354. if bottom_block_left_0 > 0:
  355. self.x_pos = min(self.x_pos + speed, (self.x + 1) * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  356. self.try_push("D", (-1, 0))
  357. cl.scroll_map()
  358. elif bottom_block_right_0 > 0:
  359. self.x_pos = max(self.x_pos - speed, (self.x - 1) * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  360. self.try_push("D", (1, 0))
  361. cl.scroll_map()
  362. else:
  363. self.y_pos += min(speed, max(0, self.y_pos - (bottom_edge * G.GAME_SQUARE + G.HALF_GAME_SQUARE)))
  364. self.try_push("D")
  365. elif bottom_block_right_0 > 0 or bottom_block_right_1 > 0 or bottom_bomb_right > 0:
  366. self.x_pos = max(self.x_pos - speed, self.x * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  367. self.try_push("D", (1, 0))
  368. elif bottom_block_left_0 > 0 or bottom_block_left_1 > 0 or bottom_bomb_left > 0:
  369. self.x_pos = min(self.x_pos + speed, self.x * G.GAME_SQUARE + G.HALF_GAME_SQUARE)
  370. self.try_push("D", (-1, 0))
  371. else:
  372. self.y_pos += speed
  373. cl.scroll_map()
  374. elif self.y_pos // G.GAME_SQUARE != (self.y_pos + speed) // G.GAME_SQUARE:
  375. if len(level.current_level.get_bomb_instance(self.x, self.y + 1)) == 0 or self.wall_walking:
  376. self.y_pos += speed
  377. cl.scroll_map()
  378. else:
  379. self.y_pos += speed
  380. cl.scroll_map()
  381. def collide_wall(self):
  382. pass
  383. def collide_district(self):
  384. pass
  385. def try_push(self, direction, offset=(0, 0)):
  386. pass
  387. def draw(self, screen: pygame.Surface):
  388. screen.blit(self.image, self.rect)
  389. def get_y(self):
  390. return self.y