-
Notifications
You must be signed in to change notification settings - Fork 4
/
road_select.py
160 lines (149 loc) · 4.79 KB
/
road_select.py
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import pygame
from pygame.locals import *
import sys
import pyganim
from Button import Button
from constants import *
import inputbox
def road_select(DISPLAY_SURF):
background = pygame.image.load('Images/road_sel.jpg')
DISPLAY_SURF.blit(background,SCREEN_TOPLEFT)
pygame.display.update()
road1 = pygame.image.load('Images/game1/road/r11.gif')
road2 = pygame.image.load('Images/game1/road/r21.gif')
road3 = pygame.image.load('Images/game1/road/r31.gif')
road4 = pygame.image.load('Images/game1/road/r41.gif')
run = True
while run:
DISPLAY_SURF.blit(background,SCREEN_TOPLEFT)
mouse = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN:
if rect1.collidepoint(mouse):
return 1
elif rect2.collidepoint(mouse):
return 2
elif rect3.collidepoint(mouse):
return 3
elif rect4.collidepoint(mouse):
return 4
rect1 = DISPLAY_SURF.blit(road1,(30,180))
rect2 = DISPLAY_SURF.blit(road2,(180,180))
rect3 = DISPLAY_SURF.blit(road3,(330,180))
rect4 = DISPLAY_SURF.blit(road4,(470,180))
pygame.display.update()
def car_select(DISPLAY_SURF):
background = pygame.image.load('Images/xyz.jpg')
Imag = pygame.image.load('Images/selection.png')
DISPLAY_SURF.blit(background,SCREEN_TOPLEFT)
pygame.display.update()
car1 = pygame.image.load('Images/game1/vehicle/car3.png')
car2 = pygame.image.load('Images/game1/vehicle/truck3.png')
car3 = pygame.image.load('Images/game1/vehicle/matcycle3.png')
run = True
while run:
DISPLAY_SURF.blit(background,SCREEN_TOPLEFT)
DISPLAY_SURF.blit(Imag,(30,10))
mouse = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN:
if rect1.collidepoint(mouse):
return 1
elif rect2.collidepoint(mouse):
return 2
elif rect3.collidepoint(mouse):
return 3
rect1 = DISPLAY_SURF.blit(car1,(30,180))
rect2 = DISPLAY_SURF.blit(car2,(230,193))
rect3 = DISPLAY_SURF.blit(car3,(430,200))
pygame.display.update()
def select_items(DISPLAY_SURF):
car_val=car_select(DISPLAY_SURF)
if(car_val==1):
car1 = pygame.image.load('Images/game1/vehicle/car1.png')
car2 = pygame.image.load('Images/game1/vehicle/car2.png')
scalew = 0.995
scalez = 0.995
scalex = 0.999
scaley = 0.999
multiplier_scale_big = 1.004
multiplier_scale_small = 0.992
sound_path = 'Sound/car.ogg'
elif(car_val==2):
car1 = pygame.image.load('Images/game1/vehicle/truck1.png')
car2 = pygame.image.load('Images/game1/vehicle/truck2.png')
scalew = 0.800
scalez = 0.800
scalex = 0.999
scaley = 0.999
multiplier_scale_big = 1.004
multiplier_scale_small = 0.992
sound_path = 'Sound/truck.ogg'
elif(car_val==3):
car1 = pygame.image.load('Images/game1/vehicle/matcycle1.png')
car2 = pygame.image.load('Images/game1/vehicle/matcycle2.png')
scalew = 0.999
scalez = 0.999
scalex = 0.999
scaley = 0.999
multiplier_scale_big = 1.004
multiplier_scale_small = 0.995
sound_path = 'Sound/bike.ogg'
else:
car1 = pygame.image.load('Images/game1/vehicle/car1.png')
car2 = pygame.image.load('Images/game1/vehicle/car2.png')
scalew = 0.995
scalez = 0.995
scalex = 0.999
scaley = 0.999
multiplier_scale_big = 1.004
multiplier_scale_small = 0.992
sound_path = 'Sound/car.ogg'
road_val= road_select(DISPLAY_SURF)
background = pygame.image.load('Images/input.png')
DISPLAY_SURF.blit(background,SCREEN_TOPLEFT)
pygame.display.update()
if road_val == 1 :
path1 = 'Images/game1/road/r1/'
path2 = '.png'
usr, boltAnim1,boltAnim2 = inputbox.ask_parallel(DISPLAY_SURF,"Guess Answer ?? :",road_val,46,path1,path2)
carx = 280
mincary = 150
maxcary = 300
elif road_val == 2 :
path1 = 'Images/game1/road/r2/'
path2 = '.png'
usr, boltAnim1,boltAnim2 = inputbox.ask_parallel(DISPLAY_SURF,"Guess Answer ?? :",road_val,30,path1,path2)
carx = 280
mincary = 188
maxcary = 300
elif road_val == 3 :
path1 = 'Images/game1/road/r3/'
path2 = '.gif'
usr, boltAnim1,boltAnim2 = inputbox.ask_parallel(DISPLAY_SURF,"Guess Answer ?? :",road_val,13,path1,path2)
carx = 310
mincary = 180
maxcary = 300
elif road_val == 4:
path1 = 'Images/game1/road/r4/tmp-'
path2 = '.gif'
usr, boltAnim1,boltAnim2 = inputbox.ask_parallel(DISPLAY_SURF,"Guess Answer ??:",road_val,20,path1,path2)
carx = 280
mincary = 180
maxcary = 300
else :
path1 = 'Images/game1/road/r3/'
path2 = '.gif'
usr, boltAnim1,boltAnim2 = inputbox.ask_parallel(DISPLAY_SURF,"Guess Answer ?? :",road_val,13,path1,path2)
carx = 280
mincary = 170
maxcary = 350
return usr,car1,car2,boltAnim1,boltAnim2,carx,mincary,maxcary,scalex,scaley,scalew,scalez,multiplier_scale_big,multiplier_scale_small,sound_path