diff --git a/src/images/animals/left/8FoxLeft.png b/src/images/animals/left/8FoxLeft.png index fef8721..6b7d468 100644 Binary files a/src/images/animals/left/8FoxLeft.png and b/src/images/animals/left/8FoxLeft.png differ diff --git a/src/images/animals/right/4LeopardRight.png b/src/images/animals/right/4LeopardRight.png index db15b39..d90f5fa 100644 Binary files a/src/images/animals/right/4LeopardRight.png and b/src/images/animals/right/4LeopardRight.png differ diff --git a/src/images/animals/right/6LionRight.png b/src/images/animals/right/6LionRight.png index 301c6d1..9bd2eee 100644 Binary files a/src/images/animals/right/6LionRight.png and b/src/images/animals/right/6LionRight.png differ diff --git a/src/init.py b/src/init.py index 37b3bb9..4029131 100644 --- a/src/init.py +++ b/src/init.py @@ -172,19 +172,19 @@ def clac_MAP1(): return MAP def refresh(): - l_elephant = pygame.Rect(281, 10, CHESSSIZE_Y, CHESSSIZE_Y) - l_eagle = pygame.Rect(157, 120, CHESSSIZE_Y, CHESSSIZE_Y) - l_wolf = pygame.Rect(284, 229, CHESSSIZE_Y, CHESSSIZE_Y) - l_lion = pygame.Rect(292, 343, CHESSSIZE_Y, CHESSSIZE_Y) - l_leopard = pygame.Rect(285, 450, CHESSSIZE_Y, CHESSSIZE_Y) - l_mouse = pygame.Rect(285, 665, CHESSSIZE_Y, CHESSSIZE_Y) - l_fox = pygame.Rect(157, 557, CHESSSIZE_Y, CHESSSIZE_Y) + l_elephant = pygame.Rect(int(2 / 9 * WIDTH), int(0 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + l_eagle = pygame.Rect(int(1 / 9 * WIDTH), int(1 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + l_wolf = pygame.Rect(int(2 / 9 * WIDTH), int(2 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + l_lion = pygame.Rect(int(2 / 9 * WIDTH), int(3 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + l_leopard = pygame.Rect(int(2 / 9 * WIDTH), int(4 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + l_mouse = pygame.Rect(int(2 / 9 * WIDTH), int(6 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + l_fox = pygame.Rect(int(1 / 9 * WIDTH), int(5 / 7 * HEIGHT), CHESSSIZE_Y,CHESSSIZE_Y) - r_elephant = pygame.Rect(795, 673, CHESSSIZE_Y, CHESSSIZE_Y) - r_eagle = pygame.Rect(925, 570, CHESSSIZE_Y, CHESSSIZE_Y) - r_wolf = pygame.Rect(803, 458, CHESSSIZE_Y, CHESSSIZE_Y) - r_lion = pygame.Rect(802, 347, CHESSSIZE_Y, CHESSSIZE_Y) - r_leopard = pygame.Rect(796, 232, CHESSSIZE_Y, CHESSSIZE_Y) - r_fox = pygame.Rect(920, 123, CHESSSIZE_Y, CHESSSIZE_Y) - r_mouse = pygame.Rect(793, 16, CHESSSIZE_Y, CHESSSIZE_Y) + r_elephant = pygame.Rect(int(6 / 9 * WIDTH), int(6 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + r_eagle = pygame.Rect(int(7 / 9 * WIDTH), int(5 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + r_wolf = pygame.Rect(int(6 / 9 * WIDTH), int(4 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + r_lion = pygame.Rect(int(6 / 9 * WIDTH), int(3 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + r_leopard = pygame.Rect(int(6 / 9 * WIDTH), int(2 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) + r_fox = pygame.Rect(int(7 / 9 * WIDTH), int(1 / 7 * HEIGHT), CHESSSIZE_Y,CHESSSIZE_Y) + r_mouse = pygame.Rect(int(6 / 9 * WIDTH), int(0 / 7 * HEIGHT), CHESSSIZE_Y, CHESSSIZE_Y) return l_elephant,l_eagle,l_wolf, l_lion,l_leopard, l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_fox,r_mouse \ No newline at end of file diff --git a/src/main.py b/src/main.py index 01ebf17..d05f341 100644 --- a/src/main.py +++ b/src/main.py @@ -31,6 +31,8 @@ Eagle = pygame.mixer.Sound('audio/Eagle.mp3') pygame.mixer.music.set_volume(0.5) #################################################### #animals img +hint = pygame.transform.scale(pygame.image.load("images/hint.png"),(CHESSSIZE_X,CHESSSIZE_Y)) +capture_hint = pygame.transform.scale(pygame.image.load("images/capture-hint.png"),(CHESSSIZE_X,CHESSSIZE_Y)) #Left L_mouse = pygame.transform.scale(pygame.image.load('images/animals/left/1MouseLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) L_eagle = pygame.transform.scale(pygame.image.load('images/animals/left/2EagleLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) @@ -110,8 +112,9 @@ def draw_right_animals(r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox) WIN.blit(R_fox, (r_fox.x, r_fox.y)) -def draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox): +def draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox,id, x, y, status, MAP, MAP1,turn): WIN.blit(SPACE,(0,0)) + path(id, x, y, status, MAP, MAP1, turn) draw_left_animals(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox) draw_right_animals(r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox) #WIN.blit(L_fox,(fox.x,fox.y)) @@ -919,6 +922,20 @@ def ismove(old_x,old_y,x,y,id,MAP,MAP1): else : return 0 +def path(id, x, y, status, MAP, MAP1, turn): + if status: + movement = [] + for i in range(9): + for j in range(7): + if turn == 0: + if right_move(x, y, i, j, id, MAP,MAP1): + movement.append([i, j]) + else: + if left_move(x, y, i, j, id, MAP,MAP1): + movement.append([i, j]) + for i, j in movement: + WIN.blit(hint, init.tran(i,j)) + WIN.blit(capture_hint,init.tran(x,y)) #TODO:Judge who win def left_win(x,y,MAP,MAP1): global r_animals @@ -1787,7 +1804,8 @@ def main(): run = False if right_win(x,y,MAP,MAP1): run = False - draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox) + draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox,id, x, y, status, MAP, MAP1,turn) + if left_win(x, y, MAP, MAP1): print_text(WIN, font, 500, 400, "Left Win!", RED) pygame.display.update() @@ -1803,6 +1821,6 @@ if __name__ == "__main__": while again == 1: l_elephant, l_eagle, l_wolf, l_lion, l_leopard, l_mouse, l_fox, r_elephant, r_eagle, r_wolf, r_lion, r_leopard, r_fox, r_mouse=init.refresh() draw_window(l_elephant, l_eagle, l_wolf, l_lion, l_leopard, l_mouse, l_fox, r_elephant, r_eagle, r_wolf, r_lion, - r_leopard, r_mouse, r_fox) + r_leopard, r_mouse, r_fox,0,0,0,0,0,0,0) main() pygame.quit() diff --git a/src/main1.py b/src/main1.py deleted file mode 100644 index aa536b6..0000000 --- a/src/main1.py +++ /dev/null @@ -1,1216 +0,0 @@ -import pygame -import init -import start_game -import time -import os -WIDTH , HEIGHT = 1200 , 800 - - -#模块############################### -ID = [1 for i in range(20)] -FPS = 60 -WIN = pygame.display.set_mode((WIDTH,HEIGHT)) -pygame.display.set_caption("Jungle") -SPACE = pygame.transform.scale(pygame.image.load('images/map.png'),(WIDTH,HEIGHT)) -CHESSSIZE_X=120 -CHESSSIZE_Y=100 #棋子大小 -################################################################## - -###########背景音乐########### -BGM = pygame.mixer.Sound('audio/BackgroudMusic.mp3') -Elephant = pygame.mixer.Sound('audio/Elephant.mp3') -Leopard = pygame.mixer.Sound('audio/Leopard.mp3') -Lion = pygame.mixer.Sound('audio/Lion.mp3') -Mouse = pygame.mixer.Sound('audio/Mouse.mp3') -#Start = pygame.mixer.Sound('audio/start.mp3') -Tiger = pygame.mixer.Sound('audio/Tiger.mp3') -Wolf = pygame.mixer.Sound('audio/Wolf.mp3') -Fox = pygame.mixer.Sound('audio/Fox..mp3') -Eagle = pygame.mixer.Sound('audio/Eagle.mp3') -pygame.mixer.music.set_volume(0.5) -#################################################### -hint = pygame.transform.scale(pygame.image.load("images/hint.png"),(CHESSSIZE_X,CHESSSIZE_Y)) -capture_hint = pygame.transform.scale(pygame.image.load("images/capture-hint.png"),(CHESSSIZE_X,CHESSSIZE_Y)) -#animals img -#Left -L_mouse = pygame.transform.scale(pygame.image.load('images/animals/left/1MouseLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_eagle = pygame.transform.scale(pygame.image.load('images/animals/left/2EagleLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_wolf = pygame.transform.scale(pygame.image.load('images/animals/left/3WolfLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_leopard = pygame.transform.scale(pygame.image.load('images/animals/left/4LeopardLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_tiger = pygame.transform.scale(pygame.image.load('images/animals/left/5TigerLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_lion = pygame.transform.scale(pygame.image.load('images/animals/left/6LionLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_elephant = pygame.transform.scale(pygame.image.load('images/animals/left/7ElephantLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_fox = pygame.transform.scale(pygame.image.load('images/animals/left/8FoxLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) - -#Right -R_mouse = pygame.transform.scale(pygame.image.load('images/animals/right/1MouseRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_eagle = pygame.transform.scale(pygame.image.load('images/animals/right/2EagleRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_wolf = pygame.transform.scale(pygame.image.load('images/animals/right/3WolfRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_leopard = pygame.transform.scale(pygame.image.load('images/animals/right/4LeopardRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_tiger = pygame.transform.scale(pygame.image.load('images/animals/right/5TigerRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_lion = pygame.transform.scale(pygame.image.load('images/animals/right/6LionRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_elephant = pygame.transform.scale(pygame.image.load('images/animals/right/7ElephantRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_fox = pygame.transform.scale(pygame.image.load('images/animals/right/8FoxRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -############################################################################### - - -#colour########################################################### -BLACK = (0,0,0) -LIGHTBLUE = (40,191,255) -LIGHTBLUE2 = (0,0,255) -BGCOLOR = (230,230,250) -MAGENTA = (255,0,255) -LIGHTYELLOW= (255,225,0) -MYCOLOR = (255,165,0) -WHITE = (255,255,255) -GREEN = (0,255,0) -RED = (255,0,0) -BLUE = (0,0,255) -Crimson=(220,20,60) -LightPink=(255,182,193) -DeepSkyBlue=(0,191,255) -############################################################# - - -#TEXT -def print_text(WIN,font,x,y,text,fcolor=WHITE): - imgText = font .render(text,True,fcolor) - WIN.blit(imgText,(x,y)) - -###################################### -def draw_left_animals(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox): - if ID[7]: - WIN.blit(L_elephant,(l_elephant.x,l_elephant.y)) - if ID[2]: - WIN.blit(L_eagle, (l_eagle.x, l_eagle.y)) - if ID[4]: - WIN.blit(L_wolf, (l_wolf.x, l_wolf.y)) - if ID[6]: - WIN.blit(L_lion, (l_lion.x, l_lion.y)) - if ID[5]: - WIN.blit(L_leopard, (l_leopard.x, l_leopard.y)) - if ID[1]: - WIN.blit(L_mouse, (l_mouse.x, l_mouse.y)) - if ID[3]: - WIN.blit(L_fox, (l_fox.x, l_fox.y)) - -def draw_right_animals(r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox): - if ID[14]: - WIN.blit(R_elephant, (r_elephant.x, r_elephant.y)) - if ID[9]: - WIN.blit(R_eagle, (r_eagle.x, r_eagle.y)) - if ID[11]: - WIN.blit(R_wolf, (r_wolf.x,r_wolf.y)) - if ID[13]: - WIN.blit(R_lion, (r_lion.x, r_lion.y)) - if ID[12]: - WIN.blit(R_leopard, (r_leopard.x, r_leopard.y)) - if ID[8]: - WIN.blit(R_mouse, (r_mouse.x, r_mouse.y)) - if ID[10]: - WIN.blit(R_fox, (r_fox.x, r_fox.y)) - - -def draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox): - WIN.blit(SPACE,(0,0)) - draw_left_animals(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox) - draw_right_animals(r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox) - #WIN.blit(L_fox,(fox.x,fox.y)) - pygame.display.update() -#TODO:传入动物编号id,动物现在的位置(x,y),将点击的动物圈起来,并显示可以移动的地方 -def path(): - pass - -#animals rect -l_elephant = pygame.Rect(int(2/9 * WIDTH),int(0 / 7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_eagle = pygame.Rect(int(1 / 9 *WIDTH),int(1 / 7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_wolf = pygame.Rect(int(2/9 * WIDTH),int(2/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_lion = pygame.Rect(int(2/9 * WIDTH),int(3/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_leopard = pygame.Rect(int(2/9 * WIDTH),int(4/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_mouse = pygame.Rect(int(2/9 * WIDTH),int(6/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_fox = pygame.Rect(int(1/9 * WIDTH),int(5/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) - -r_elephant = pygame.Rect(int(6/9*WIDTH),int(6/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_eagle = pygame.Rect(int(7/9*WIDTH),int(5/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_wolf = pygame.Rect(int(6/9*WIDTH),int(4/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_lion = pygame.Rect(int(6/9*WIDTH),int(3/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_leopard = pygame.Rect(int(6/9*WIDTH),int(2/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_fox = pygame.Rect(int(7/9*WIDTH),int(1/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_mouse = pygame.Rect(int(6/9*WIDTH),int(0/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -############################################# -l_animals =r_animals = 7 -def ismove(old_x,old_y,x,y,id,MAP,MAP1): - global l_animals - global r_animals - if id == 1: - if MAP[x][y] == 16: - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP[x][y] == 14 or MAP1[x][y] == 15): - if MAP[x][y] == 14 and MAP1[old_x][old_y] == 20: - return 0 - if MAP[x][y] == 14 and MAP1[old_x][old_y] != 20: - ID[14] = 0 - r_animals -= 1 - return 1 - if MAP[x][y] == 8: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y] <= 14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP[x][y] == 14 or MAP1[x][y] == 15): - if MAP[x][y] == 14 and MAP1[old_x][old_y] == 20: - return 0 - if MAP[x][y] == 14 and MAP1[old_x][old_y] != 20: - ID[14] = 0 - r_animals -= 1 - return 1 - if MAP[x][y] == 8: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 2: - if MAP[x][y] == 16 and MAP[x][y] != 0 and MAP[x][y] != 15 and MAP[x][y] != 17 and MAP[x][y] != 18 and MAP1[x][y] != 15 and (9 < MAP[x][y] <= 14): - return 0 - if x == old_x and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=9): - if y > old_y: - for i in range(old_y+1,y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 15 and MAP[x][i] != 17 and MAP[x][i] != 16 and MAP[x][i] != 18): - return 0 - if 8<=MAP[x][y]<=9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]]=0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else: - for i in range(y+1,old_y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 15 and MAP[x][i] != 17 and MAP[x][i] != 16 and MAP[x][i] != 18 ): - return 0 - if 8<=MAP[x][y]<=9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]]=0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif y == old_y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=9): - if x > old_x: - for i in range(old_x+1,x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 15 and MAP[i][y] != 17 and MAP[i][y] != 16 and MAP[i][y] != 18): - return 0 - if 8<=MAP[x][y]<=9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]]=0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - for i in range(x+1,old_x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 15 and MAP[i][y] != 17 and MAP[i][y] != 16 and MAP[i][y] != 18): - return 0 - if 8<=MAP[x][y]<=9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]]=0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 3: - if abs(x - old_x) <= 1 and abs(y - old_y) <= 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=10): - if 8 <= MAP[x][y] <= 10: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - return 0 - elif id == 4: - if MAP[x][y] == 16: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=11): - if 8 <= MAP[x][y] <= 11: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=11): - if 8 <= MAP[x][y] <= 11: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 5: - if MAP[x][y] == 16: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) ==1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=12): - if 8 <= MAP[x][y] <= 12: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=12): - if 8 <= MAP[x][y] <= 12 : - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 6: - if MAP[x][y] == 16: - return 0 - if MAP[x][y] == 20: - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=13): - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=13): - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=13): - if y > old_y: - for i in range(old_y+1,y): - if MAP[x][i] != 20 and MAP[x][i] != 1 : - return 0 - if 8 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else: - for i in range(y+1,old_y): - if MAP[x][i] != 20 and MAP[x][i] != 1 : - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=13): - if x > old_x: - for i in range(old_x+1,x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else: - for i in range(x+1,old_x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else: - return 0 - elif id == 7: - if MAP[x][y] == 16: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 9<=MAP[x][y]<=14): - if 9 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 and MAP[x][y] == 18 or MAP1[x][y] == 15 or 9<=MAP[x][y]<=14): - if 9 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 8: - if MAP[x][y] == 18: - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP[x][y] == 7 or MAP1[x][y] == 17): - if MAP[x][y] == 7: - if MAP1[old_x][old_y] != 20: - ID[7] = 0 - l_animals -= 1 - return 1 - else: - return 0 - if MAP[x][y] == 1: - ID[1] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP[x][y] == 7 or MAP1[x][y] == 17): - if MAP[x][y] == 7: - if MAP1[old_x][old_y] != 20: - ID[7] = 0 - l_animals -= 1 - return 1 - else: - return 0 - if MAP[x][y] == 1: - ID[1] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1 <= MAP[x][y] <= 7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 9: - if MAP[x][y] == 18 and MAP[x][y] != 0 and MAP[x][y] != 15 and MAP[x][y] != 17 and MAP[x][y] != 16 and MAP1[x][y] != 17 and (2 old_y: - for i in range(old_y + 1, y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 17 and MAP[i][y] != 15 and MAP[x][i] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - for i in range(y + 1, old_y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 17 and MAP[i][y] != 15 and MAP[x][i] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif y == old_y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=2): - if x > old_x: - for i in range(old_x + 1, x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 17 and MAP[i][y] != 15 and MAP[i][y] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - for i in range(x + 1, old_x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 17 and MAP[i][y] != 15 and MAP[i][y] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - return 0 - elif id == 10: - if abs(x - old_x) <= 1 and abs(y - old_y) <= 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=3): - if 1 <= MAP[x][y] <= 3: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - return 0 - elif id == 11: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=4): - if 1 <= MAP[x][y] <= 4: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=4): - if 1 <= MAP[x][y] <= 4: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 12: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=5): - if 1 <= MAP[x][y] <= 5: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=5): - if 1 <= MAP[x][y] <= 5: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - return 1 - return 1 - else : - return 0 - elif id == 13: - if MAP[x][y] == 18: - return 0 - if MAP[x][y] == 20: - return 0 - if abs(x - old_x) ==1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if y > old_y: - for i in range(old_y+1,y): - if MAP[x][i] != 20 and MAP[x][i] != 8 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - for i in range(y+1,old_y): - if MAP[x][i] != 20 and MAP[x][i] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if x > old_x: - for i in range(old_x+1,x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - for i in range(x+1,old_x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - return 0 - elif id == 14: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7): - if 2 <= MAP[x][y] <= 7: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7): - if 2 <= MAP[x][y] <= 7: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else : - return 0 - -def path(id, x, y, status, MAP, MAP1): - if status: - movement = [] - for i in range(9): - for j in range(7): - if ismove(x, y, i, j, id, MAP,MAP1): - movement.append([i, j]) - for i, j in movement: - WIN.blit(hint, init.tran(i,j)) - WIN.blit(capture_hint,init.tran(x,y)) - pygame.display.update() -#TODO:Judge who win -def left_win(old_x,old_y,x,y,MAP,MAP1): - global r_animals - if r_animals == 0: - return 1 - if MAP1[x][y] == 18 and 1<=MAP[x][y]<=7: - return 1 - for i in range(8,15): - pass - return 0 - -def right_win(old_x,old_y,x,y,MAP,MAP1): - global l_animals - if l_animals == 0: - return 1 - if MAP1[x][y] == 16 and 8 <= MAP[x][y] <= 14: - return 1 - for i in range(1, 8): - pass - return 0 - -def main(): - global l_animals,r_animals - game_status = 1 - BGM.play(-1) - MAP = init.calc_map() - MAP1 = init.clac_MAP1() - game_status = start_game.starting_screen() - if not game_status: - return False - #TODO:updata MAP1 - run = True - clock = pygame.time.Clock() - font = pygame.font.SysFont('kaiti',40) - status = id = old_x = old_y = x = y = turn = 0 - while run: - clock.tick(FPS) - for event in pygame.event.get(): - if event.type == pygame.QUIT: - run = False - elif event.type == pygame.MOUSEBUTTONDOWN: - b1, b2, b3 = pygame.mouse.get_pressed() - if b1 and not b3: - print(r_animals) - mouse_x , mouse_y = event.pos - old_x = x - old_y = y - x = int(mouse_x / WIDTH * 9) - y = int(mouse_y / HEIGHT * 7) - if status == 0: - id = MAP[x][y] - if 0 < id < 8 and turn == 0: - if id == 1: - Mouse.play() - elif id == 2: - Eagle.play() - elif id == 3: - Fox.play() - elif id == 4: - Wolf.play() - elif id == 5: - Leopard.play() - elif id == 6: - Lion.play() - elif id == 7: - Elephant.play() - status = 1 - path(id, x, y, status, MAP, MAP1) - elif 7 < id <15 and turn == 1: - if id == 8: - Mouse.play() - if id == 9: - Eagle.play() - if id == 10: - Fox.play() - if id == 11: - Wolf.play() - if id == 12: - Leopard.play() - if id == 13: - Lion.play() - if id == 14: - Elephant.play() - status = 2 - path(id, x, y, status, MAP, MAP1) - #TODO: Cirlce the elective animal - else: - if id == 1 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if(ismove(old_x,old_y,x,y,id,MAP,MAP1)): - print(MAP1[old_x][old_y]) - l_mouse.x,l_mouse.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else: - status = 0 - elif id == 2 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - path(id, x, y, status, MAP, MAP1) - else: - #print(ismove(old_x,old_y,x,y,id,MAP)) - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_eagle.x , l_eagle.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 3 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_fox.x , l_fox.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 4 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_wolf.x , l_wolf.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 5 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_leopard.x , l_leopard.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 6 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_lion.x , l_lion.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 7 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_elephant.x , l_elephant.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 8 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_mouse.x , r_mouse.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 9 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_eagle.x , r_eagle.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 10 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_fox.x , r_fox.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 11 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_wolf.x , r_wolf.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 12 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_leopard.x , r_leopard.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 13 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_lion.x , r_lion.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 14 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_elephant.x , r_elephant.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - #print(turn, status) - if left_win(old_x,old_y,x,y,MAP,MAP1): - run = False - if right_win(old_x,old_y,x,y,MAP,MAP1): - run = False - #print(old_x,old_y) - #print(x,y) - draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox) - if left_win(old_x, old_y, x, y, MAP, MAP1): - print_text(WIN, font, 500, 400, "Left Win!", RED) - pygame.display.update() - if right_win(old_x, old_y, x, y, MAP, MAP1): - print_text(WIN, font, 500, 400, "Right Win!", BLUE) - pygame.display.update() - os.system("pause") - pygame.quit() - - - -if __name__ == "__main__": - while main(): - main() - pygame.quit() \ No newline at end of file diff --git a/src/main_an.py b/src/main_an.py deleted file mode 100644 index d05f341..0000000 --- a/src/main_an.py +++ /dev/null @@ -1,1826 +0,0 @@ -import pygame -import init -import start_game -import time -import os -#import path.path -WIDTH , HEIGHT = 1200 , 800 - - -#模块############################### -ID = [1 for i in range(20)] -FPS = 60 -WIN = pygame.display.set_mode((WIDTH,HEIGHT)) -pygame.display.set_caption("Jungle") -SPACE = pygame.transform.scale(pygame.image.load('images/map.png'),(WIDTH,HEIGHT)) -CHESSSIZE_X=120 -CHESSSIZE_Y=100 #棋子大小 -################################################################## - -###########背景音乐########### -BGM = pygame.mixer.Sound('audio/BackgroudMusic.mp3') -Elephant = pygame.mixer.Sound('audio/Elephant.mp3') -Leopard = pygame.mixer.Sound('audio/Leopard.mp3') -Lion = pygame.mixer.Sound('audio/Lion.mp3') -Mouse = pygame.mixer.Sound('audio/Mouse.mp3') -#Start = pygame.mixer.Sound('audio/start.mp3') -Tiger = pygame.mixer.Sound('audio/Tiger.mp3') -Wolf = pygame.mixer.Sound('audio/Wolf.mp3') -Fox = pygame.mixer.Sound('audio/Fox..mp3') -Eagle = pygame.mixer.Sound('audio/Eagle.mp3') -pygame.mixer.music.set_volume(0.5) -#################################################### -#animals img -hint = pygame.transform.scale(pygame.image.load("images/hint.png"),(CHESSSIZE_X,CHESSSIZE_Y)) -capture_hint = pygame.transform.scale(pygame.image.load("images/capture-hint.png"),(CHESSSIZE_X,CHESSSIZE_Y)) -#Left -L_mouse = pygame.transform.scale(pygame.image.load('images/animals/left/1MouseLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_eagle = pygame.transform.scale(pygame.image.load('images/animals/left/2EagleLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_wolf = pygame.transform.scale(pygame.image.load('images/animals/left/3WolfLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_leopard = pygame.transform.scale(pygame.image.load('images/animals/left/4LeopardLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_tiger = pygame.transform.scale(pygame.image.load('images/animals/left/5TigerLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_lion = pygame.transform.scale(pygame.image.load('images/animals/left/6LionLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_elephant = pygame.transform.scale(pygame.image.load('images/animals/left/7ElephantLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -L_fox = pygame.transform.scale(pygame.image.load('images/animals/left/8FoxLeft.png'),(CHESSSIZE_X,CHESSSIZE_Y)) - -#Right -R_mouse = pygame.transform.scale(pygame.image.load('images/animals/right/1MouseRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_eagle = pygame.transform.scale(pygame.image.load('images/animals/right/2EagleRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_wolf = pygame.transform.scale(pygame.image.load('images/animals/right/3WolfRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_leopard = pygame.transform.scale(pygame.image.load('images/animals/right/4LeopardRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_tiger = pygame.transform.scale(pygame.image.load('images/animals/right/5TigerRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_lion = pygame.transform.scale(pygame.image.load('images/animals/right/6LionRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_elephant = pygame.transform.scale(pygame.image.load('images/animals/right/7ElephantRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -R_fox = pygame.transform.scale(pygame.image.load('images/animals/right/8FoxRight.png'),(CHESSSIZE_X,CHESSSIZE_Y)) -############################################################################### - - -#colour########################################################### -BLACK = (0,0,0) -LIGHTBLUE = (40,191,255) -LIGHTBLUE2 = (0,0,255) -BGCOLOR = (230,230,250) -MAGENTA = (255,0,255) -LIGHTYELLOW= (255,225,0) -MYCOLOR = (255,165,0) -WHITE = (255,255,255) -GREEN = (0,255,0) -RED = (255,0,0) -BLUE = (0,0,255) -Crimson=(220,20,60) -LightPink=(255,182,193) -DeepSkyBlue=(0,191,255) -############################################################# - - -#TEXT -def print_text(WIN,font,x,y,text,fcolor=WHITE): - imgText = font .render(text,True,fcolor) - WIN.blit(imgText,(x,y)) - -###################################### -def draw_left_animals(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox): - if ID[7]: - WIN.blit(L_elephant,(l_elephant.x,l_elephant.y)) - if ID[2]: - WIN.blit(L_eagle, (l_eagle.x, l_eagle.y)) - if ID[4]: - WIN.blit(L_wolf, (l_wolf.x, l_wolf.y)) - if ID[6]: - WIN.blit(L_lion, (l_lion.x, l_lion.y)) - if ID[5]: - WIN.blit(L_leopard, (l_leopard.x, l_leopard.y)) - if ID[1]: - WIN.blit(L_mouse, (l_mouse.x, l_mouse.y)) - if ID[3]: - WIN.blit(L_fox, (l_fox.x, l_fox.y)) - -def draw_right_animals(r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox): - if ID[14]: - WIN.blit(R_elephant, (r_elephant.x, r_elephant.y)) - if ID[9]: - WIN.blit(R_eagle, (r_eagle.x, r_eagle.y)) - if ID[11]: - WIN.blit(R_wolf, (r_wolf.x,r_wolf.y)) - if ID[13]: - WIN.blit(R_lion, (r_lion.x, r_lion.y)) - if ID[12]: - WIN.blit(R_leopard, (r_leopard.x, r_leopard.y)) - if ID[8]: - WIN.blit(R_mouse, (r_mouse.x, r_mouse.y)) - if ID[10]: - WIN.blit(R_fox, (r_fox.x, r_fox.y)) - - -def draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox,id, x, y, status, MAP, MAP1,turn): - WIN.blit(SPACE,(0,0)) - path(id, x, y, status, MAP, MAP1, turn) - draw_left_animals(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox) - draw_right_animals(r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox) - #WIN.blit(L_fox,(fox.x,fox.y)) - pygame.display.update() - -#animals rect -l_elephant = pygame.Rect(int(2/9 * WIDTH),int(0 / 7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_eagle = pygame.Rect(int(1 / 9 *WIDTH),int(1 / 7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_wolf = pygame.Rect(int(2/9 * WIDTH),int(2/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_lion = pygame.Rect(int(2/9 * WIDTH),int(3/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_leopard = pygame.Rect(int(2/9 * WIDTH),int(4/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_mouse = pygame.Rect(int(2/9 * WIDTH),int(6/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -l_fox = pygame.Rect(int(1/9 * WIDTH),int(5/7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) - -r_elephant = pygame.Rect(int(6/9*WIDTH),int(6/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_eagle = pygame.Rect(int(7/9*WIDTH),int(5/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_wolf = pygame.Rect(int(6/9*WIDTH),int(4/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_lion = pygame.Rect(int(6/9*WIDTH),int(3/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_leopard = pygame.Rect(int(6/9*WIDTH),int(2/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_fox = pygame.Rect(int(7/9*WIDTH),int(1/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -r_mouse = pygame.Rect(int(6/9*WIDTH),int(0/7*HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y) -############################################# -l_animals =r_animals = 7 -def ismove(old_x,old_y,x,y,id,MAP,MAP1): - global l_animals - global r_animals - if id == 1: - if MAP[x][y] == 16: - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP[x][y] == 14 or MAP1[x][y] == 15): - if MAP[x][y] == 14 and MAP1[old_x][old_y] == 20: - return 0 - if MAP[x][y] == 14 and MAP1[old_x][old_y] != 20: - ID[14] = 0 - r_animals -= 1 - return 1 - if MAP[x][y] == 8: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y] <= 14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP[x][y] == 14 or MAP1[x][y] == 15): - if MAP[x][y] == 14 and MAP1[old_x][old_y] == 20: - return 0 - if MAP[x][y] == 14 and MAP1[old_x][old_y] != 20: - ID[14] = 0 - r_animals -= 1 - return 1 - if MAP[x][y] == 8: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 2: - if MAP[x][y] == 16 and MAP[x][y] != 0 and MAP[x][y] != 15 and MAP[x][y] != 17 and MAP[x][y] != 18 and MAP1[x][y] != 15 and (9 < MAP[x][y] <= 14): - return 0 - if x == old_x and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=9): - if y > old_y: - for i in range(old_y+1,y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 15 and MAP[x][i] != 17 and MAP[x][i] != 16 and MAP[x][i] != 18): - return 0 - if 8<=MAP[x][y]<=9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]]=0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else: - for i in range(y+1,old_y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 15 and MAP[x][i] != 17 and MAP[x][i] != 16 and MAP[x][i] != 18 ): - return 0 - if 8<=MAP[x][y]<=9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]]=0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif y == old_y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=9): - if x > old_x: - for i in range(old_x+1,x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 15 and MAP[i][y] != 17 and MAP[i][y] != 16 and MAP[i][y] != 18): - return 0 - if 8<=MAP[x][y]<=9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]]=0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - for i in range(x+1,old_x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 15 and MAP[i][y] != 17 and MAP[i][y] != 16 and MAP[i][y] != 18): - return 0 - if 8<=MAP[x][y]<=9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]]=0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 3: - if abs(x - old_x) <= 1 and abs(y - old_y) <= 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=10): - if 8 <= MAP[x][y] <= 10: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - return 0 - elif id == 4: - if MAP[x][y] == 16: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=11): - if 8 <= MAP[x][y] <= 11: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=11): - if 8 <= MAP[x][y] <= 11: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 5: - if MAP[x][y] == 16: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) ==1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=12): - if 8 <= MAP[x][y] <= 12: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=12): - if 8 <= MAP[x][y] <= 12 : - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 6: - if MAP[x][y] == 16: - return 0 - if MAP[x][y] == 20: - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=13): - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=13): - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=13): - if y > old_y: - for i in range(old_y+1,y): - if MAP[x][i] != 20 and MAP[x][i] != 1 : - return 0 - if 8 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else: - for i in range(y+1,old_y): - if MAP[x][i] != 20 and MAP[x][i] != 1 : - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8<=MAP[x][y]<=13): - if x > old_x: - for i in range(old_x+1,x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else: - for i in range(x+1,old_x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else: - return 0 - elif id == 7: - if MAP[x][y] == 16: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 9<=MAP[x][y]<=14): - if 9 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 and MAP[x][y] == 18 or MAP1[x][y] == 15 or 9<=MAP[x][y]<=14): - if 9 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - if MAP1[x][y] == 15 and 8<=MAP[x][y]<=14: - ID[MAP[x][y]] = 0 - r_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 8: - if MAP[x][y] == 18: - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP[x][y] == 7 or MAP1[x][y] == 17): - if MAP[x][y] == 7: - if MAP1[old_x][old_y] != 20: - ID[7] = 0 - l_animals -= 1 - return 1 - else: - return 0 - if MAP[x][y] == 1: - ID[1] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP[x][y] == 7 or MAP1[x][y] == 17): - if MAP[x][y] == 7: - if MAP1[old_x][old_y] != 20: - ID[7] = 0 - l_animals -= 1 - return 1 - else: - return 0 - if MAP[x][y] == 1: - ID[1] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1 <= MAP[x][y] <= 7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 9: - if MAP[x][y] == 18 and MAP[x][y] != 0 and MAP[x][y] != 15 and MAP[x][y] != 17 and MAP[x][y] != 16 and MAP1[x][y] != 17 and (2 old_y: - for i in range(old_y + 1, y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 17 and MAP[i][y] != 15 and MAP[x][i] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - for i in range(y + 1, old_y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 17 and MAP[i][y] != 15 and MAP[x][i] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif y == old_y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=2): - if x > old_x: - for i in range(old_x + 1, x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 17 and MAP[i][y] != 15 and MAP[i][y] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - for i in range(x + 1, old_x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 17 and MAP[i][y] != 15 and MAP[i][y] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - return 0 - elif id == 10: - if abs(x - old_x) <= 1 and abs(y - old_y) <= 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=3): - if 1 <= MAP[x][y] <= 3: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - return 0 - elif id == 11: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=4): - if 1 <= MAP[x][y] <= 4: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=4): - if 1 <= MAP[x][y] <= 4: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 12: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=5): - if 1 <= MAP[x][y] <= 5: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=5): - if 1 <= MAP[x][y] <= 5: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else : - return 0 - elif id == 13: - if MAP[x][y] == 18: - return 0 - if MAP[x][y] == 20: - return 0 - if abs(x - old_x) ==1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if y > old_y: - for i in range(old_y+1,y): - if MAP[x][i] != 20 and MAP[x][i] != 8 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - for i in range(y+1,old_y): - if MAP[x][i] != 20 and MAP[x][i] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if x > old_x: - for i in range(old_x+1,x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - for i in range(x+1,old_x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else: - return 0 - elif id == 14: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7): - if 2 <= MAP[x][y] <= 7: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7): - if 2 <= MAP[x][y] <= 7: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - else: - return 0 - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - ID[MAP[x][y]] = 0 - l_animals -= 1 - return 1 - return 1 - else : - return 0 - -def path(id, x, y, status, MAP, MAP1, turn): - if status: - movement = [] - for i in range(9): - for j in range(7): - if turn == 0: - if right_move(x, y, i, j, id, MAP,MAP1): - movement.append([i, j]) - else: - if left_move(x, y, i, j, id, MAP,MAP1): - movement.append([i, j]) - for i, j in movement: - WIN.blit(hint, init.tran(i,j)) - WIN.blit(capture_hint,init.tran(x,y)) -#TODO:Judge who win -def left_win(x,y,MAP,MAP1): - global r_animals - if r_animals == 0: - return 1 - if MAP1[x][y] == 18 and 1<=MAP[x][y]<=7: - return 1 - isWin = 0 - for i in range(8,15): - if ID[i] == 1: - isWin = left_Wall(i,MAP,MAP1) - if isWin == 0: - return 0 - if isWin == 1: - return 1 - return 0 - -def left_move(old_x,old_y,x,y,id,MAP,MAP1): - if id == 8: - if MAP[x][y] == 18: - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP[x][y] == 7 or MAP1[x][y] == 17): - if MAP[x][y] == 7: - if MAP1[old_x][old_y] != 20: - return 1 - else: - return 0 - if MAP[x][y] == 1: - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP[x][y] == 7 or MAP1[x][y] == 17): - if MAP[x][y] == 7: - if MAP1[old_x][old_y] != 20: - return 1 - else: - return 0 - if MAP[x][y] == 1: - return 1 - if MAP1[x][y] == 17 and 1 <= MAP[x][y] <= 7: - return 1 - return 1 - else : - return 0 - elif id == 9: - if MAP[x][y] == 18 and MAP[x][y] != 0 and MAP[x][y] != 15 and MAP[x][y] != 17 and MAP[x][y] != 16 and MAP1[x][y] != 17 and (2 old_y: - for i in range(old_y + 1, y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 17 and MAP[i][y] != 15 and MAP[x][i] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else: - for i in range(y + 1, old_y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 17 and MAP[i][y] != 15 and MAP[x][i] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - elif y == old_y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=2): - if x > old_x: - for i in range(old_x + 1, x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 17 and MAP[i][y] != 15 and MAP[i][y] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else: - for i in range(x + 1, old_x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 17 and MAP[i][y] != 15 and MAP[i][y] != 18): - return 0 - if 1 <= MAP[x][y] <= 2: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else: - return 0 - elif id == 10: - if abs(x - old_x) <= 1 and abs(y - old_y) <= 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=3): - if 1 <= MAP[x][y] <= 3: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - return 0 - elif id == 11: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=4): - if 1 <= MAP[x][y] <= 4: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=4): - if 1 <= MAP[x][y] <= 4: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else : - return 0 - elif id == 12: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=5): - if 1 <= MAP[x][y] <= 5: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=5): - if 1 <= MAP[x][y] <= 5: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else : - return 0 - elif id == 13: - if MAP[x][y] == 18: - return 0 - if MAP[x][y] == 20: - return 0 - if abs(x - old_x) ==1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if y > old_y: - for i in range(old_y+1,y): - if MAP[x][i] != 20 and MAP[x][i] != 8 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else: - for i in range(y+1,old_y): - if MAP[x][i] != 20 and MAP[x][i] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6): - if x > old_x: - for i in range(old_x+1,x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else: - for i in range(x+1,old_x): - if MAP[i][y] != 20 and MAP[i][y] != 1 : - return 0 - if 1 <= MAP[x][y] <= 6: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else: - return 0 - elif id == 14: - if MAP[x][y] == 18: - return 0 - if(MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7): - if 2 <= MAP[x][y] <= 7: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7): - if 2 <= MAP[x][y] <= 7: - if MAP[x][y] == 1: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7: - return 1 - return 1 - else : - return 0 - -def left_Wall(id,MAP,MAP1): - if 8<=id<=14: - if id == 8: - old_x,old_y = init.calc(r_mouse.x,r_mouse.y) - elif id == 9: - old_x, old_y = init.calc(r_eagle.x, r_eagle.y) - elif id == 10: - old_x, old_y = init.calc(r_fox.x, r_fox.y) - elif id == 11: - old_x, old_y = init.calc(r_wolf.x, r_wolf.y) - elif id == 12: - old_x, old_y = init.calc(r_leopard.x, r_leopard.y) - elif id == 13: - old_x, old_y = init.calc(r_lion.x, r_lion.y) - elif id == 14: - old_x, old_y = init.calc(r_elephant.x, r_elephant.y) - for x in range(0,9): - for y in range(0,6): - if left_move(old_x,old_y,x,y,id,MAP,MAP1): - return 0 - return 1 -def right_win(x,y,MAP,MAP1): - isWin = 0 - global l_animals - if l_animals == 0: - return 1 - if MAP1[x][y] == 16 and 8 <= MAP[x][y] <= 14: - return 1 - for i in range(1, 8): - if ID[i] == 1: - isWin = right_Wall(i,MAP,MAP1) - if isWin == 0: - return 0 - if isWin == 1: - return 1 - return 0 - -def right_move(old_x,old_y,x,y,id,MAP,MAP1): - if id == 1: - if MAP[x][y] == 16: - return 0 - if abs(x - old_x) == 1 and old_y == y and ( - MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP[x][y] == 14 or MAP1[x][y] == 15): - if MAP[x][y] == 14 and MAP1[old_x][old_y] == 20: - return 0 - if MAP[x][y] == 14 and MAP1[old_x][old_y] != 20: - return 1 - if MAP[x][y] == 8: - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and ( - MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP[x][y] == 14 or MAP1[x][y] == 15): - if MAP[x][y] == 14 and MAP1[old_x][old_y] == 20: - return 0 - if MAP[x][y] == 14 and MAP1[old_x][old_y] != 20: - return 1 - if MAP[x][y] == 8: - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - return 0 - elif id == 2: - if MAP[x][y] == 16 and MAP[x][y] != 0 and MAP[x][y] != 15 and MAP[x][y] != 17 and MAP[x][y] != 18 and MAP1[x][y] != 15 and (9 < MAP[x][y] <= 14): - return 0 - if x == old_x and ( - MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 9): - if y > old_y: - for i in range(old_y + 1, y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 15 and MAP[x][i] != 17 and MAP[x][i] != 16 and MAP[x][i] != 18): - return 0 - if 8 <= MAP[x][y] <= 9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - for i in range(y + 1, old_y): - if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 15 and MAP[x][i] != 17 and MAP[x][i] != 16 and MAP[x][i] != 18): - return 0 - if 8 <= MAP[x][y] <= 9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - elif y == old_y and ( - MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 9): - if x > old_x: - for i in range(old_x + 1, x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 15 and MAP[i][y] != 17 and MAP[i][y] != 16 and MAP[i][y] != 18): - return 0 - if 8 <= MAP[x][y] <= 9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - for i in range(x + 1, old_x): - if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 15 and MAP[i][y] != 17 and MAP[i][y] != 16 and MAP[i][y] != 18): - return 0 - if 8 <= MAP[x][y] <= 9: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - return 0 - elif id == 3: - if abs(x - old_x) <= 1 and abs(y - old_y) <= 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 10): - if 8 <= MAP[x][y] <= 10: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - return 0 - elif id == 4: - if MAP[x][y] == 16: - return 0 - if (MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 11): - if 8 <= MAP[x][y] <= 11: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 11): - if 8 <= MAP[x][y] <= 11: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - return 0 - elif id == 5: - if MAP[x][y] == 16: - return 0 - if (MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 12): - if 8 <= MAP[x][y] <= 12: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 12): - if 8 <= MAP[x][y] <= 12: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - return 0 - elif id == 6: - if MAP[x][y] == 16: - return 0 - if MAP[x][y] == 20: - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 13): - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 13): - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 13): - if y > old_y: - for i in range(old_y + 1, y): - if MAP[x][i] != 20 and MAP[x][i] != 1: - return 0 - if 8 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - for i in range(y + 1, old_y): - if MAP[x][i] != 20 and MAP[x][i] != 1: - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 13): - if x > old_x: - for i in range(old_x + 1, x): - if MAP[i][y] != 20 and MAP[i][y] != 1: - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - for i in range(x + 1, old_x): - if MAP[i][y] != 20 and MAP[i][y] != 1: - return 0 - if 8 <= MAP[x][y] <= 13: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - return 0 - elif id == 7: - if MAP[x][y] == 16: - return 0 - if (MAP[x][y] == 20): - return 0 - if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 9 <=MAP[x][y] <= 14): - if 9 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 and MAP[x][y] == 18 or MAP1[x][y] == 15 or 9 <=MAP[x][y] <= 14): - if 9 <= MAP[x][y] <= 14: - if MAP[x][y] == 8: - if MAP1[x][y] != 20: - return 1 - else: - return 0 - return 1 - if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14: - return 1 - return 1 - else: - return 0 -def right_Wall(id,MAP,MAP1): - if 1<=id<=7: - if id == 1: - old_x,old_y = init.calc(l_mouse.x,l_mouse.y) - elif id == 2: - old_x, old_y = init.calc(l_eagle.x, l_eagle.y) - elif id == 3: - old_x, old_y = init.calc(l_fox.x, l_fox.y) - elif id == 4: - old_x, old_y = init.calc(l_wolf.x, l_wolf.y) - elif id == 5: - old_x, old_y = init.calc(l_leopard.x, l_leopard.y) - elif id == 6: - old_x, old_y = init.calc(l_lion.x, l_lion.y) - elif id == 7: - old_x, old_y = init.calc(l_elephant.x, l_elephant.y) - for x in range(0,9): - for y in range(0,6): - if right_move(old_x,old_y,x,y,id,MAP,MAP1): - return 0 - return 1 -def main(): - global l_animals,r_animals - BGM.play(-1) - MAP = init.calc_map() - MAP1 = init.clac_MAP1() - game_status = start_game.starting_screen() - if not game_status: - return True - run = True - clock = pygame.time.Clock() - font = pygame.font.SysFont('kaiti',40) - status = id = old_x = old_y = x = y = turn = 0 - while run: - clock.tick(FPS) - for event in pygame.event.get(): - if event.type == pygame.QUIT: - run = False - elif event.type == pygame.MOUSEBUTTONDOWN: - b1, b2, b3 = pygame.mouse.get_pressed() - if b1 and not b3: - mouse_x , mouse_y = event.pos - old_x = x - old_y = y - x = int(mouse_x / WIDTH * 9) - y = int(mouse_y / HEIGHT * 7) - if status == 0: - id = MAP[x][y] - if 0 < id < 8 and turn == 0: - if id == 1: - Mouse.play() - elif id == 2: - Eagle.play() - elif id == 3: - Fox.play() - elif id == 4: - Wolf.play() - elif id == 5: - Leopard.play() - elif id == 6: - Lion.play() - elif id == 7: - Elephant.play() - status = 1 - elif 7 < id <15 and turn == 1: - if id == 8: - Mouse.play() - if id == 9: - Eagle.play() - if id == 10: - Fox.play() - if id == 11: - Wolf.play() - if id == 12: - Leopard.play() - if id == 13: - Lion.play() - if id == 14: - Elephant.play() - status = 2 - #TODO: Cirlce the elective animal - else: - if id == 1 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if(ismove(old_x,old_y,x,y,id,MAP,MAP1)): - print(MAP1[old_x][old_y]) - l_mouse.x,l_mouse.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else: - status = 0 - elif id == 2 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_eagle.x , l_eagle.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 3 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_fox.x , l_fox.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 4 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_wolf.x , l_wolf.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 5 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_leopard.x , l_leopard.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 6 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_lion.x , l_lion.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 7 and turn == 0 and status == 1: - if MAP[x][y] == id: - status = 1 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - l_elephant.x , l_elephant.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 1 - else : - status = 0 - elif id == 8 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_mouse.x , r_mouse.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 9 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_eagle.x , r_eagle.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 10 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_fox.x , r_fox.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 11 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_wolf.x , r_wolf.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 12 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_leopard.x , r_leopard.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 13 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_lion.x , r_lion.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - elif id == 14 and turn == 1 and status == 2: - if MAP[x][y] == id: - status = 2 - else: - if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) : - r_elephant.x , r_elephant.y = init.tran(x,y) - MAP[old_x][old_y] = MAP1[old_x][old_y] - MAP[x][y] = id - status = 0 - turn = 0 - else : - status = 0 - if left_win(x,y,MAP,MAP1): - run = False - if right_win(x,y,MAP,MAP1): - run = False - draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox,id, x, y, status, MAP, MAP1,turn) - - if left_win(x, y, MAP, MAP1): - print_text(WIN, font, 500, 400, "Left Win!", RED) - pygame.display.update() - if right_win(x, y, MAP, MAP1): - print_text(WIN, font, 500, 400, "Right Win!", BLUE) - pygame.display.update() - time.sleep(2) - #os.system("pause") - - -if __name__ == "__main__": - again = 1 - while again == 1: - l_elephant, l_eagle, l_wolf, l_lion, l_leopard, l_mouse, l_fox, r_elephant, r_eagle, r_wolf, r_lion, r_leopard, r_fox, r_mouse=init.refresh() - draw_window(l_elephant, l_eagle, l_wolf, l_lion, l_leopard, l_mouse, l_fox, r_elephant, r_eagle, r_wolf, r_lion, - r_leopard, r_mouse, r_fox,0,0,0,0,0,0,0) - main() - pygame.quit()