|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
看鱼C的教程自学了一周的python,
勉强算是写出个有界面的东西,
现在的问题时鼠标检测机制不是很灵敏,
求大佬救救孩子吧!!!
话不多说直接上码
- import pygame
- import os, pygame
- from pygame.locals import *
- from sys import exit
- from random import *
- framemenu = pygame.image.load('images/framemenu.png')
- framemenu_back = pygame.image.load('images/framemenu_back.png')
- framemenu_back_big = pygame.image.load('images/framemenu_back_big.png')
- framemenu_high = pygame.image.load('images/framemenu_high.png')
- framemenu_high_2 = pygame.image.load('images/framemenu_high_2.png')
- framemenu_high_big = pygame.image.load('images/framemenu_high_big.png')
- framemenu_low = pygame.image.load('images/framemenu_low.png')
- framemenu_low_2 = pygame.image.load('images/framemenu_low_2.png')
- framemenu_low_big = pygame.image.load('images/framemenu_low_big.png')
- helpmenu = pygame.image.load('images/helpmenu.png')
- helpmenu_back = pygame.image.load('images/helpmenu_back.png')
- helpmenu_back_big = pygame.image.load('images/helpmenu_back_big.png')
- helpmenu_raiders = pygame.image.load('images/helpmenu_raiders.png')
- helpmenu_raiders_big = pygame.image.load('images/helpmenu_raiders_big.png')
- helpmenu_writer = pygame.image.load('images/helpmenu_writer.png')
- helpmenu_writer_big = pygame.image.load('images/helpmenu_writer_big.png')
- mainmenu = pygame.image.load('images/mainmenu.png')
- mainmenu_help = pygame.image.load('images/mainmenu_help.png')
- mainmenu_help_big = pygame.image.load('images/mainmenu_help_big.png')
- mainmenu_set = pygame.image.load('images/mainmenu_set.png')
- mainmenu_set_big = pygame.image.load('images/mainmenu_set_big.png')
- mainmenu_start = pygame.image.load('images/mainmenu_start.png')
- mainmenu_start_big = pygame.image.load('images/mainmenu_start_big.png')
- raidersmenu = pygame.image.load('images/raidersmenu.png')
- raidersmenu_back = pygame.image.load('images/raidersmenu_back.png')
- raidersmenu_back_big = pygame.image.load('images/raidersmenu_back_big.png')
- setmenu = pygame.image.load('images/setmenu.png')
- setmenu_back = pygame.image.load('images/setmenu_back.png')
- setmenu_back_big = pygame.image.load('images/setmenu_back_big.png')
- setmenu_frame = pygame.image.load('images/setmenu_frame.png')
- setmenu_frame_big = pygame.image.load('images/setmenu_frame_big.png')
- setmenu_sound = pygame.image.load('images/setmenu_sound.png')
- setmenu_sound_big = pygame.image.load('images/setmenu_sound_big.png')
- soundmenu = pygame.image.load('images/soundmenu.png')
- soundmenu_0 = pygame.image.load('images/soundmenu_0.png')
- soundmenu_1 = pygame.image.load('images/soundmenu_1.png')
- soundmenu_2 = pygame.image.load('images/soundmenu_2.png')
- soundmenu_3 = pygame.image.load('images/soundmenu_3.png')
- soundmenu_4 = pygame.image.load('images/soundmenu_4.png')
- soundmenu_5 = pygame.image.load('images/soundmenu_5.png')
- soundmenu_back = pygame.image.load('images/soundmenu_back.png')
- soundmenu_back_big = pygame.image.load('images/soundmenu_back_big.png')
- soundmenu_minus = pygame.image.load('images/soundmenu_minus.png')
- soundmenu_minus_big = pygame.image.load('images/soundmenu_minus_big.png')
- soundmenu_plus = pygame.image.load('images/soundmenu_plus.png')
- soundmenu_plus_big = pygame.image.load('images/soundmenu_plus_big.png')
- startmenu = pygame.image.load('images/startmenu.png')
- startmenu_back = pygame.image.load('images/startmenu_back.png')
- startmenu_back_big = pygame.image.load('images/startmenu_back_big.png')
- startmenu_new = pygame.image.load('images/startmenu_new.png')
- startmenu_new_big = pygame.image.load('images/startmenu_new_big.png')
- startmenu_read = pygame.image.load('images/startmenu_read.png')
- startmenu_read_big = pygame.image.load('images/startmenu_read_big.png')
- writermenu = pygame.image.load('images/writermenu.png')
- writermenu_back = pygame.image.load('images/writermenu_back.png')
- writermenu_back_big = pygame.image.load('images/writermenu_back_big.png')
- image_none = pygame.image.load('images/image_none.png')
- def main_pagecheck(mouse_x = 0,mouse_y = 0,main_page = 0,volume = 3,frame = 60):
- if main_page == 0:
- if mouse_x > 30 and mouse_x < 200 and mouse_y > 400 and mouse_y < 500:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [1,startmenu,startmenu_new,startmenu_read,startmenu_back,image_none,volume,frame,1]
- else:
- return [0,mainmenu,mainmenu_start_big,mainmenu_help,mainmenu_set,image_none,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 580 and mouse_y < 680:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [2,helpmenu,helpmenu_raiders,helpmenu_writer,helpmenu_back,image_none,volume,frame,1]
- else:
- return [0,mainmenu,mainmenu_start,mainmenu_help_big,mainmenu_set,image_none,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 760 and mouse_y < 860:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [3,setmenu,setmenu_sound,setmenu_frame,setmenu_back,image_none,volume,frame,1]
- else:
- return [0,mainmenu,mainmenu_start,mainmenu_help,mainmenu_set_big,image_none,volume,frame,0]
- else:
- return [0,mainmenu,mainmenu_start,mainmenu_help,mainmenu_set,image_none,volume,frame,0]
-
- elif main_page == 1:
- if mouse_x > 30 and mouse_x < 200 and mouse_y > 400 and mouse_y < 500:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [9,image_none,image_none,image_none,image_none,image_none,volume,frame,1]
- else:
- return [1,startmenu,startmenu_new_big,startmenu_read,startmenu_back,image_none,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 580 and mouse_y < 680:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [8,image_none,image_none,image_none,image_none,image_none,volume,frame,1]
- else:
- return [1,startmenu,startmenu_new,startmenu_read_big,startmenu_back,image_none,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 760 and mouse_y < 860:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [0,mainmenu,mainmenu_start,mainmenu_help,mainmenu_set,image_none,volume,frame,1]
- else:
- return [1,startmenu,startmenu_new,startmenu_read,startmenu_back_big,image_none,volume,frame,0]
- else:
- return [1,startmenu,startmenu_new,startmenu_read,startmenu_back,image_none,volume,frame,0]
-
- elif main_page == 2:
- if mouse_x > 30 and mouse_x < 200 and mouse_y > 400 and mouse_y < 500:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [4,raidersmenu,image_none,image_none,raidersmenu_back,image_none,volume,frame,1]
- else:
- return [2,helpmenu,helpmenu_raiders_big,helpmenu_writer,helpmenu_back,image_none,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 580 and mouse_y < 680:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [5,writermenu,image_none,image_none,writermenu_back,image_none,volume,frame,1]
- else:
- return [2,helpmenu,helpmenu_raiders,helpmenu_writer_big,helpmenu_back,image_none,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 760 and mouse_y < 860:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [0,mainmenu,mainmenu_start,mainmenu_help,mainmenu_set,image_none,volume,frame,1]
- else:
- return [2,helpmenu,helpmenu_raiders,helpmenu_writer,helpmenu_back_big,image_none,volume,frame,0]
- else:
- return [2,helpmenu,helpmenu_raiders,helpmenu_writer,helpmenu_back,image_none,volume,frame,0]
-
- elif main_page == 3:
- if mouse_x > 30 and mouse_x < 200 and mouse_y > 400 and mouse_y < 500:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- if volume == 0:
- han_4 = soundmenu_0
- elif volume == 1:
- han_4 = soundmenu_1
- elif volume == 2:
- han_4 = soundmenu_2
- elif volume == 3:
- han_4 = soundmenu_3
- elif volume == 4:
- han_4 = soundmenu_4
- else:
- han_4 = soundmenu_5
- return [6,soundmenu,soundmenu_plus,soundmenu_minus,soundmenu_back,han_4,volume,frame,1]
- else:
- return [3,setmenu,setmenu_sound_big,setmenu_frame,setmenu_back,image_none,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 580 and mouse_y < 680:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- if frame == 30:
- han_4 = framemenu_low_2
- else:
- han_4 = framemenu_high_2
- return [7,framemenu,image_none,image_none,framemenu_back,han_4,volume,frame,1]
- else:
- return [3,setmenu,setmenu_sound,setmenu_frame_big,setmenu_back,image_none,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 760 and mouse_y < 860:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [0,mainmenu,mainmenu_start,mainmenu_help,mainmenu_set,image_none,volume,frame,1]
- else:
- return [3,setmenu,setmenu_sound,setmenu_frame,setmenu_back_big,image_none,volume,frame,0]
- else:
- return [3,setmenu,setmenu_sound,setmenu_frame,setmenu_back,image_none,volume,frame,0]
-
- elif main_page == 4:
- if mouse_x > 30 and mouse_x < 200 and mouse_y > 760 and mouse_y < 860:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [2,helpmenu,helpmenu_raiders,helpmenu_writer,helpmenu_back,image_none,volume,frame,1]
- else:
- return [4,raidersmenu,image_none,image_none,raidersmenu_back_big,image_none,volume,frame,0]
- else:
- return [4,raidersmenu,image_none,image_none,raidersmenu_back,image_none,volume,frame,0]
-
- elif main_page == 5:
- if mouse_x > 30 and mouse_x < 200 and mouse_y > 760 and mouse_y < 860:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [2,helpmenu,helpmenu_raiders,helpmenu_writer,helpmenu_back,image_none,volume,frame,1]
- else:
- return [5,writermenu,image_none,image_none,raidersmenu_back_big,image_none,volume,frame,0]
- else:
- return [5,writermenu,image_none,image_none,writermenu_back,image_none,volume,frame,0]
-
- elif main_page == 6:
- if volume == 0:
- han_4 = soundmenu_0
- elif volume == 1:
- han_4 = soundmenu_1
- elif volume == 2:
- han_4 = soundmenu_2
- elif volume == 3:
- han_4 = soundmenu_3
- elif volume == 4:
- han_4 = soundmenu_4
- else:
- han_4 = soundmenu_5
- if mouse_x > 30 and mouse_x < 200 and mouse_y > 400 and mouse_y < 500:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1 and volume < 5:
- volume += 1
- if volume == 0:
- han_4 = soundmenu_0
- elif volume == 1:
- han_4 = soundmenu_1
- elif volume == 2:
- han_4 = soundmenu_2
- elif volume == 3:
- han_4 = soundmenu_3
- elif volume == 4:
- han_4 = soundmenu_4
- else:
- han_4 = soundmenu_5
- return [6,soundmenu,soundmenu_plus_big,soundmenu_minus,soundmenu_back,han_4,volume,frame,0]
- else:
- return [6,soundmenu,soundmenu_plus_big,soundmenu_minus,soundmenu_back,han_4,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 580 and mouse_y < 680:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1 and volume > 0:
- volume -= 1
- if volume == 0:
- han_4 = soundmenu_0
- elif volume == 1:
- han_4 = soundmenu_1
- elif volume == 2:
- han_4 = soundmenu_2
- elif volume == 3:
- han_4 = soundmenu_3
- elif volume == 4:
- han_4 = soundmenu_4
- else:
- han_4 = soundmenu_5
- return [6,soundmenu,soundmenu_plus,soundmenu_minus_big,soundmenu_back,han_4,volume,frame,0]
- else:
- return [6,soundmenu,soundmenu_plus,soundmenu_minus_big,soundmenu_back,han_4,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 760 and mouse_y < 860:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [3,setmenu,setmenu_sound,setmenu_frame,setmenu_back,image_none,volume,frame,1]
- else:
- return [6,soundmenu,soundmenu_plus,soundmenu_minus,soundmenu_back_big,han_4,volume,frame,0]
- else:
- return [6,soundmenu,soundmenu_plus,soundmenu_minus,soundmenu_back,han_4,volume,frame,0]
-
- elif main_page == 7:
- if frame == 60:
- han_4 = framemenu_low_2
- else:
- han_4 = framemenu_high_2
- if mouse_x > 30 and mouse_x < 200 and mouse_y > 400 and mouse_y < 500:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- frame = 144
- return [7,framemenu,framemenu_high_big,framemenu_low,framemenu_back,framemenu_high_2,volume,frame,0]
- else:
- return [7,framemenu,framemenu_high_big,framemenu_low,framemenu_back,han_4,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 580 and mouse_y < 680:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- frame = 60
- return [7,framemenu,framemenu_high,framemenu_low_big,framemenu_back,framemenu_low_2,volume,frame,0]
- else:
- return [7,framemenu,framemenu_high,framemenu_low_big,framemenu_back,han_4,volume,frame,0]
- elif mouse_x > 30 and mouse_x < 200 and mouse_y > 760 and mouse_y < 860:
- temp = 0
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- pressed_array = pygame.mouse.get_pressed()
- for index in range(len(pressed_array)):
- if pressed_array[index]:
- if index == 0:
- temp = 1
- if temp == 1:
- return [3,setmenu,setmenu_sound,setmenu_frame,setmenu_back,image_none,volume,frame,1]
- else:
- return [7,framemenu,framemenu_high,framemenu_low,framemenu_back_big,han_4,volume,frame,0]
- else:
- return [7,framemenu,framemenu_high,framemenu_low,framemenu_back,han_4,volume,frame,0]
-
- elif main_page == 9:
- return [9,image_none,image_none,image_none,image_none,image_none,volume,frame,1]
- elif main_page == 8:
- return [8,image_none,image_none,image_none,image_none,image_none,volume,frame,1]
复制代码 |
|