forked from helloworldC2/VirtualRobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlay.py
More file actions
106 lines (83 loc) · 3.08 KB
/
Play.py
File metadata and controls
106 lines (83 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import cursor
from cursor import *
import pygame
from pygame.locals import *
import sys
import Game
import gui
def playMenu(display) :
bg = pygame.image.load("wallpaper.jpg")
#bg = pygame.transform.scale(bg,(1107,700))
bgpart = pygame.image.load("bgpart.jpg")
robot = pygame.image.load("robot.png").convert_alpha()
robot = pygame.transform.scale(robot,(150,150))
ai = pygame.image.load("buttons/AI.png").convert_alpha()
single = pygame.image.load("buttons/Single.png").convert_alpha()
multi = pygame.image.load("buttons/Multiplayer.png").convert_alpha()
sound = pygame.image.load("buttons/soundoff.png").convert_alpha()
soundOn = pygame.image.load("buttons/soundon.png").convert_alpha()
sound = pygame.transform.scale(sound,(35,50))
soundOn = pygame.transform.scale(soundOn,(60,50))
sX = 720
sY = 540
rX = 50
rY = 50
aiWidth = ai.get_width()
singleWidth = single.get_width()
multiWidth = multi.get_width()
aiX = 400 - aiWidth/2
singleX = 400 - singleWidth/2
multiX = 400 - multiWidth/2
aiY = 250
singleY = 350
multiY = 450
left = 0
display.blit(bg,(0,0))
display.blit(robot,(rX,rY))
display.blit(ai,(aiX,aiY))
display.blit(single,(singleX,singleY))
display.blit(multi,(multiX,multiY))
display.blit(sound,(sX,sY))
s = 0
while True :
pos = pygame.mouse.get_pos()
if collide(aiX,aiY,ai,pos) or collide(singleX,singleY,single,pos) or collide(multiX,multiY,multi,pos) or collide(sX,sY,sound,pos) :
pygame.mouse.set_cursor(*cursor.HAND_CURSOR)
else :
pygame.mouse.set_cursor(*cursor.ARROW_CURSOR)
if left == 0 and rX <= 500 :
rX += 1
if rX == 500 :
left = 1
elif left == 1 and rX > 50 :
rX -= 1
if rX == 50 :
left = 0
for ev in pygame.event.get():
if ev.type == QUIT:
pygame.quit()
sys.exit()
if ev.type == MOUSEBUTTONDOWN and ev.button == 1 :
if s == 0 and collide(sX,sY,sound,pos) :
s = 1
display.blit(bg,(0,0))
display.blit(robot,(rX,rY))
display.blit(ai,(aiX,aiY))
display.blit(single,(singleX,singleY))
display.blit(multi,(multiX,multiY))
display.blit(sound,(sX,sY))
display.blit(soundOn,(sX,sY))
break
if s == 1 and collide(sX,sY,sound,pos) :
s = 0
display.blit(bg,(0,0))
display.blit(robot,(rX,rY))
display.blit(ai,(aiX,aiY))
display.blit(single,(singleX,singleY))
display.blit(multi,(multiX,multiY))
display.blit(sound,(sX,sY))
break
display.blit(bgpart,(0,0))
display.blit(robot,(rX,rY))
pygame.display.update()
return