diff --git a/src/main1.py b/src/main1.py new file mode 100644 index 0000000..3e3dfac --- /dev/null +++ b/src/main1.py @@ -0,0 +1,132 @@ +import pygame +import os +pygame.init() +pygame.font.init() +#pygame.mixer.init() + +#模块############################### +FPS = 60 +WIDTH , HEIGHT = 1200 , 800 +WIN = pygame.display.set_mode((WIDTH,HEIGHT)) +pygame.display.set_caption("Jungle") +SPACE = pygame.transform.scale(pygame.image.load('images/map.png'),(WIDTH,HEIGHT)) +chosenChess=None #选择的棋子(将要移动) +coverdChess=None #点击的目标位置(将被覆盖) +currentChess=None #当前点击的棋子 +index=0 #记录棋盘上的棋子数量 +CHESSSIZE_X=120 +CHESSSIZE_Y=100 #棋子大小 +R=25 +GAP=3 #棋子间距 +face_size = int(CHESSSIZE_X * 1.25) +face_pos_x = (WIDTH - face_size) // 2 +face_pos_y = (CHESSSIZE_X * 2 - face_size) // 2 +################################################################## + +###########背景音乐########### +#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') +#################################################### +#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_window(fox): + WIN.blit(SPACE,(0,0)) + WIN.blit(L_fox,(fox.x,fox.y)) + pygame.display.update() + +def main(): + fox = pygame.Rect(155,130,CHESSSIZE_Y,CHESSSIZE_Y) + run = True + clock = pygame.time.Clock() + font1 = pygame.font.SysFont('kaiti',40) + status = 0; + while run: + clock.tick(FPS) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + run = False + elif event.type == pygame.MOUSEBUTTONDOWN: + mouse_x , mouse_y= event.pos + x = int(mouse_x / WIDTH * 9) + 1 + y = int(mouse_y / HEIGHT * 7) + 1 + b1,b2,b3 = pygame.mouse.get_pressed() + print(mouse_x,mouse_y) + if status == 1: + if mouse_x >=800: + fox.x = int((x-1) / 9 * WIDTH) - 10 + fox.y = int((y-1) / 7 * HEIGHT) + elif mouse_x >=600: + fox.x = int((x - 1) / 9 * WIDTH) + fox.y = int((y - 1) / 7 * HEIGHT) + else: + fox.x = int((x - 1) / 9 * WIDTH) + 15 + fox.y = int((y - 1) / 7 * HEIGHT) + if mouse_y >= 500: + fox.y -= 15 + status = 0 + else : + status = 1 + + + + #fox.x+=1 + draw_window(fox) + pygame.quit() + + + +if __name__ == "__main__": + main() \ No newline at end of file