fork download
  1. def menu(height):
  2.  
  3. import pygame
  4. import pygame.freetype
  5. # Initialize Pygame
  6. pygame.init()
  7. Chest =0
  8. Left_shoulder=0
  9. Right_shoulder=0
  10. leg=0
  11. Left_weapon=0
  12. Right_weapon=0
  13. # Screen dimensions
  14. width = int((4/3)*height)#800
  15. screen = pygame.display.set_mode((width, height))
  16. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 2/60*height)
  17. # Button properties
  18. button_color = (100, 100, 100) # Grey
  19. button_x = int(width/2)-int((5/60)*width)
  20. button_y = int((height/2)-int((1/8)*height))
  21. button_width = int((1/8) * width)
  22. button_height = int((1/6) * height)
  23. Chest_menu = pygame.Rect(0, 0, int(width/3),height)
  24. left_shoulder_menu = pygame.Rect(0, 0, int(width/3),height)
  25. right_shoulder_menu = pygame.Rect(0, 0, int(width/3),height)
  26. left_leg_menu = pygame.Rect(0, 0, int(width/3),height)
  27. right_leg_menu = pygame.Rect(0, 0, int(width/3),height)
  28. left_gun_menu = pygame.Rect(0, 0, int(width/3),height)
  29. right_gun_menu = pygame.Rect(0, 0, int(width/3),height)
  30.  
  31. battle_menu = pygame.Rect(width-(2*button_width), 0, 2*button_width, button_height)
  32. button_rect = pygame.Rect(button_x, button_y, button_width, button_height)
  33. button_rect1 = pygame.Rect(int(button_x-((7/80)*width)), int(button_y), int(button_width/1.5), int(button_height/1.5))
  34. button_rect2 = pygame.Rect(int(button_x+((105/800)*width)), int(button_y), int(button_width/1.5), int(button_height/1.5))
  35. button_rect3 = pygame.Rect(int(button_x), int(button_y+((105/600)*height)), int(button_width/2.2), int(button_height*1.5))
  36. button_rect4 = pygame.Rect(int(button_x+((55/800)*width)), int(button_y+((105/600)*height)), int(button_width/2.2), int(button_height*1.5))
  37. button_rect5 = pygame.Rect(int(button_x-((122.5/800)*width)), int(button_y), int(button_width/2), int(button_height/2))
  38. button_rect6 = pygame.Rect(int(button_x+((175/800)*width)), int(button_y), int(button_width/2), int(button_height/2))
  39. button1= pygame.Rect(int(35/800*width),int(50/600*height),int(2*button_width),int(button_height/1.5))
  40. button2= pygame.Rect(int(35/800*width),int(150/600*height),int(2*button_width),int(button_height/1.5))
  41. button3= pygame.Rect(int(35/800*width),int(250/600*height),int(2*button_width),int(button_height/1.5))
  42. button4= pygame.Rect(int(35/800*width),int(350/600*height),int(2*button_width),int(button_height/1.5))
  43. button5= pygame.Rect(int(35/800*width),int(450/600*height),int(2*button_width),int(button_height/1.5))
  44.  
  45. # Font for button text
  46. text_color = (255, 255, 255) # White
  47. clicked=0
  48. running = True
  49. while running:
  50. for event in pygame.event.get():
  51. if event.type == pygame.QUIT:
  52. running = False
  53. if event.type == pygame.MOUSEBUTTONDOWN:
  54.  
  55. #Chest
  56.  
  57. if Chest==1 and button1.collidepoint(event.pos):
  58. chest_choice = 1
  59. if Chest==1 and button2.collidepoint(event.pos):
  60. chest_choice = 2
  61. if Chest==1 and button3.collidepoint(event.pos):
  62. chest_choice = 3
  63. if Chest==1 and button4.collidepoint(event.pos):
  64. chest_choice = 4
  65. if Chest==1 and button5.collidepoint(event.pos):
  66. chest_choice = 5
  67.  
  68. #left shoulder
  69.  
  70. if Left_shoulder==1 and button1.collidepoint(event.pos):
  71. Left_shoulder_choice = 1
  72. if Left_shoulder==1 and button2.collidepoint(event.pos):
  73. Left_shoulder_choice = 2
  74. if Left_shoulder==1 and button3.collidepoint(event.pos):
  75. Left_shoulder_choice = 3
  76. if Left_shoulder==1 and button4.collidepoint(event.pos):
  77. Left_shoulder_choice = 4
  78. if Left_shoulder==1 and button5.collidepoint(event.pos):
  79. Left_shoulder_choice = 5
  80.  
  81. #right shoulder
  82.  
  83. if Right_shoulder==1 and button1.collidepoint(event.pos):
  84. Right_shoulder_choice = 1
  85. if Right_shoulder==1 and button2.collidepoint(event.pos):
  86. Right_shoulder_choice = 2
  87. if Right_shoulder==1 and button3.collidepoint(event.pos):
  88. Right_shoulder_choice = 3
  89. if Right_shoulder==1 and button4.collidepoint(event.pos):
  90. Right_shoulder_choice = 4
  91. if Right_shoulder==1 and button5.collidepoint(event.pos):
  92. Right_shoulder_choice = 5
  93.  
  94. #legs
  95.  
  96. if leg==1 and button1.collidepoint(event.pos):
  97. leg_choice = 1
  98. if leg==1 and button2.collidepoint(event.pos):
  99. leg_choice = 2
  100. if leg==1 and button3.collidepoint(event.pos):
  101. leg_choice = 3
  102. if leg==1 and button4.collidepoint(event.pos):
  103. leg_choice = 4
  104. if leg==1 and button5.collidepoint(event.pos):
  105. leg_choice = 5
  106.  
  107. #left weapon
  108.  
  109. if Left_weapon==1 and button1.collidepoint(event.pos):
  110. Left_weapon_choice = 1
  111. if Left_weapon==1 and button2.collidepoint(event.pos):
  112. Left_weapon_choice = 2
  113. if Left_weapon==1 and button3.collidepoint(event.pos):
  114. Left_weapon_choice = 3
  115. if Left_weapon==1 and button4.collidepoint(event.pos):
  116. Left_weapon_choice = 4
  117. if Left_weapon==1 and button5.collidepoint(event.pos):
  118. Left_weapon_choice = 5
  119.  
  120. #right weapon
  121.  
  122. if Right_weapon==1 and button1.collidepoint(event.pos):
  123. Right_weapon_choice = 1
  124. if Right_weapon==1 and button2.collidepoint(event.pos):
  125. Right_weapon_choice = 2
  126. if Right_weapon==1 and button3.collidepoint(event.pos):
  127. Right_weapon_choice = 3
  128. if Right_weapon==1 and button4.collidepoint(event.pos):
  129. Right_weapon_choice = 4
  130. if Right_weapon==1 and button5.collidepoint(event.pos):
  131. Right_weapon_choice = 5
  132.  
  133. if button_rect.collidepoint(event.pos):
  134. Chest = 1
  135. else:
  136. Chest=0
  137. if button_rect1.collidepoint(event.pos):
  138. Left_shoulder=1
  139. else:
  140. Left_shoulder=0
  141. if button_rect2.collidepoint(event.pos):
  142. Right_shoulder=1
  143. else:
  144. Right_shoulder=0
  145. if button_rect3.collidepoint(event.pos):
  146. leg=1
  147. elif button_rect4.collidepoint(event.pos):
  148. leg=1
  149. else:
  150. leg=0
  151. if button_rect5.collidepoint(event.pos):
  152. Left_weapon=1
  153. else:
  154. Left_weapon=0
  155. if button_rect6.collidepoint(event.pos):
  156. Right_weapon=1
  157. else:
  158. Right_weapon=0
  159. if battle_menu.collidepoint(event.pos):
  160. return ("1",chest_choice,Left_shoulder_choice,Right_shoulder_choice,leg_choice,Left_weapon_choice,Right_weapon_choice)
  161.  
  162. # Add your button's action here
  163.  
  164. # Drawing
  165.  
  166. font.fgcolor = (255, 0, 0)
  167.  
  168. screen.fill((0, 0, 0)) # Black background\
  169.  
  170. pygame.draw.rect(screen, button_color, battle_menu)
  171. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 40/600*height)
  172. font.fgcolor = (255,255,255)
  173. font.render_to(screen, (int(width-(2*button_width)+10/800*width),button_height/4), "To Battle")
  174.  
  175. pygame.draw.rect(screen, button_color, button_rect)
  176. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 15/60*height)
  177. font.fgcolor = (255,255,255)
  178. font.render_to(screen, (int(button_x+((8/800)*width)),int(button_y+((15/600)*height))), "+")
  179.  
  180.  
  181. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 10/60*height)
  182. font.fgcolor = (255,255,255)
  183. pygame.draw.rect(screen, button_color, button_rect1)
  184. font.render_to(screen, (int(button_x-((65/800)*width)),int(button_y+((10/600)*height))), "+")
  185.  
  186.  
  187. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 10/60*height)
  188. font.fgcolor = (255,255,255)
  189. pygame.draw.rect(screen, button_color, button_rect2)
  190. font.render_to(screen, (int(button_x+((110/800)*width)),int(button_y+((10/600)*height))), "+")
  191.  
  192.  
  193. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 80/600*height)
  194. font.fgcolor = (255,255,255)
  195. pygame.draw.rect(screen, button_color, button_rect3)
  196. font.render_to(screen, (int(button_x),int(button_y+((165/600)*height))), "+")
  197.  
  198.  
  199. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 80/600*height)
  200. font.fgcolor = (255,255,255)
  201. pygame.draw.rect(screen, button_color, button_rect4)
  202. font.render_to(screen, (int(button_x+((55/800)*width)),int(button_y+((165/600)*height))), "+")
  203.  
  204. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 90/600*height)
  205. font.fgcolor = (255,255,255)
  206. pygame.draw.rect(screen, button_color, button_rect5)
  207. font.render_to(screen, (int(button_x-((122.5/800)*width)),int(button_y+((3/600)*height))), "+")
  208.  
  209. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 90/600*height)
  210. font.fgcolor = (255,255,255)
  211. pygame.draw.rect(screen, button_color, button_rect6)
  212. font.render_to(screen, (int(button_x+((175/800)*width)),int(button_y+((3/600)*height))), "+")
  213. grey=(50,50,50)
  214.  
  215. if Chest==1:
  216. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 20/600*height)
  217. font.fgcolor = (100,0,0)
  218. pygame.draw.rect(screen, grey, Chest_menu)
  219. pygame.draw.rect(screen, button_color,button1)
  220. font.render_to(screen, (6/80*width, 75/600*height), "Garrison Chest")
  221. pygame.draw.rect(screen, button_color,button2)
  222. font.render_to(screen, (7/80*width, 175/600*height), "Turtle Chest")
  223. pygame.draw.rect(screen, button_color,button3)
  224. font.render_to(screen, (7.5/80*width, 275/600*height), "Viper Chest")
  225. pygame.draw.rect(screen, button_color,button4)
  226. font.render_to(screen, (7/80*width, 375/600*height), "Mantis Chest")
  227. pygame.draw.rect(screen, button_color,button5)
  228. font.render_to(screen, (7/80*width, 0), "Chest Menu")
  229. elif Left_shoulder==1:
  230. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 20/600*height)
  231. font.fgcolor = (100,0,0)
  232. pygame.draw.rect(screen, grey, left_shoulder_menu)
  233. pygame.draw.rect(screen, button_color,button1)
  234. font.render_to(screen, (4/80*width, 75/600*height), "Garrison Shoulder")
  235. pygame.draw.rect(screen, button_color,button2)
  236. font.render_to(screen, (5/80*width, 175/600*height), "Turtle Shoulder")
  237. pygame.draw.rect(screen, button_color,button3)
  238. font.render_to(screen, (5.5/80*width, 275/600*height), "Viper Shoulder")
  239. pygame.draw.rect(screen, button_color,button4)
  240. font.render_to(screen, (5/80*width, 375/600*height), "Mantis Shoulder")
  241. pygame.draw.rect(screen, button_color,button5)
  242. font.render_to(screen, (3/80*width, 0), "Left Shoulder Menu")
  243. elif Right_shoulder==1:
  244. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 20/600*height)
  245. font.fgcolor = (100,0,0)
  246. pygame.draw.rect(screen, grey, right_shoulder_menu)
  247. pygame.draw.rect(screen, button_color,button1)
  248. font.render_to(screen, (4/80*width, 75/600*height), "Garrison Shoulder")
  249. pygame.draw.rect(screen, button_color,button2)
  250. font.render_to(screen, (5/80*width, 175/600*height), "Turtle Shoulder")
  251. pygame.draw.rect(screen, button_color,button3)
  252. font.render_to(screen, (5.5/80*width, 275/600*height), "Viper Shoulder")
  253. pygame.draw.rect(screen, button_color,button4)
  254. font.render_to(screen, (5/80*width, 375/600*height), "Mantis Shoulder")
  255. pygame.draw.rect(screen, button_color,button5)
  256. font.render_to(screen, (25/800*width, 0), "Right Shoulder Menu")
  257. elif leg==1:
  258. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 20/600*height)
  259. font.fgcolor = (100,0,0)
  260. pygame.draw.rect(screen, grey, left_leg_menu)
  261. pygame.draw.rect(screen, button_color,button1)
  262. font.render_to(screen, (7/80*width, 75/600*height), "Garrison Legs")
  263. pygame.draw.rect(screen, button_color,button2)
  264. font.render_to(screen, (8/80*width, 175/600*height), "Turtle Legs")
  265. pygame.draw.rect(screen, button_color,button3)
  266. font.render_to(screen, (8.5/80*width, 275/600*height), "Viper Legs")
  267. pygame.draw.rect(screen, button_color,button4)
  268. font.render_to(screen, (8/80*width, 375/600*height), "Mantis Legs")
  269. pygame.draw.rect(screen, button_color,button5)
  270. font.render_to(screen, (8/80*width, 0), "Leg Menu")
  271. elif Left_weapon==1:
  272. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 20/600*height)
  273. font.fgcolor = (100,0,0)
  274. pygame.draw.rect(screen, grey, left_gun_menu)
  275. pygame.draw.rect(screen, button_color,button1)
  276. font.render_to(screen, (4.5/80*width, 75/600*height), "Garrison Weapon")
  277. pygame.draw.rect(screen, button_color,button2)
  278. font.render_to(screen, (5.5/80*width, 175/600*height), "Turtle Weapon")
  279. pygame.draw.rect(screen, button_color,button3)
  280. font.render_to(screen, (6/80*width, 275/600*height), "Viper Weapon")
  281. pygame.draw.rect(screen, button_color,button4)
  282. font.render_to(screen, (5.5/80*width, 375/600*height), "Mantis Weapon")
  283. pygame.draw.rect(screen, button_color,button5)
  284. font.render_to(screen, (3.5/80*width, 0), "Left Weapon Menu")
  285. elif Right_weapon==1:
  286. font = pygame.freetype.Font("OpenSans-ExtraBold.ttf", 20/600*height)
  287. font.fgcolor = (100,0,0)
  288. pygame.draw.rect(screen, grey, right_gun_menu)
  289. pygame.draw.rect(screen, button_color,button1)
  290. font.render_to(screen, (4.5/80*width, 75/600*height), "Garrison Weapon")
  291. pygame.draw.rect(screen, button_color,button2)
  292. font.render_to(screen, (5.5/80*width, 175/600*height), "Turtle Weapon")
  293. pygame.draw.rect(screen, button_color,button3)
  294. font.render_to(screen, (6/80*width, 275/600*height), "Viper Weapon")
  295. pygame.draw.rect(screen, button_color,button4)
  296. font.render_to(screen, (5.5/80*width, 375/600*height), "Mantis Weapon")
  297. pygame.draw.rect(screen, button_color,button5)
  298. font.render_to(screen, (3/80*width, 0), "Right Weapon Menu")
  299.  
  300. pygame.display.flip()
Success #stdin #stdout 0.08s 14064KB
stdin
Standard input is empty
stdout
Standard output is empty