• API
• FAQ
• Tools
• Archive
daily pastebin goal
69%
SHARE
TWEET

# Untitled

a guest May 16th, 2018 97 Never
ENDING IN00days00hours00mins00secs

1. import pygame
2.
3. from globals import *
4.
5. def collisionTester(mapNbr):
6.
7.     global upCol, downCol, leftCol, rightCol
8.
9.     upCollide = (670, 405)
10.     downCollide = (670, 426)
11.     leftCollide = (658, 416)
12.     rightCollide = (684, 416)
13.
14.     if mapNbr == 0:
15.
16.         chairRect = pygame.Rect(612 + Globals.camera_x, 398 + Globals.camera_y, 28, 34)
17.         deskRect = pygame.Rect(534 + Globals.camera_x, 370 + Globals.camera_y, 40, 114)
18.         stairWallRect = pygame.Rect(540 + Globals.camera_x, 354 + Globals.camera_y, 64, 18)
19.         bedRect = pygame.Rect(704 + Globals.camera_x, 394 + Globals.camera_y, 100, 60)
20.         upRect = pygame.Rect(542 + Globals.camera_x, 243 + Globals.camera_y, 300, 64)
21.         downRect = pygame.Rect(545 + Globals.camera_x, 480 + Globals.camera_y, 250, 16)
22.         rightRect = pygame.Rect(800 + Globals.camera_x, 244 + Globals.camera_y, 16, 250)
23.
24.         if chairRect.collidepoint(upCollide) or stairWallRect.collidepoint(upCollide)or bedRect.collidepoint(upCollide) or upRect.collidepoint(upCollide):
25.             upCol = True
26.         else:
27.             upCol = False
28.         if chairRect.collidepoint(downCollide) or deskRect.collidepoint(downCollide) or stairWallRect.collidepoint(downCollide) or bedRect.collidepoint(downCollide) or downRect.collidepoint(downCollide):
29.             downCol = True
30.         else:
31.             downCol = False
32.         if chairRect.collidepoint(leftCollide) or deskRect.collidepoint(leftCollide) or stairWallRect.collidepoint(leftCollide):
33.             leftCol = True
34.         else:
35.             leftCol = False
36.         if chairRect.collidepoint(rightCollide) or bedRect.collidepoint(rightCollide) or rightRect.collidepoint(rightCollide):
37.             rightCol = True
38.         else:
39.             rightCol = False
40.     elif mapNbr == 1:
41.         upRect = pygame.Rect(368 + Globals.camera_x, 316 + Globals.camera_y, 400, 66)
42.         downRect = pygame.Rect(340 + Globals.camera_x, 770 + Globals.camera_y, 450, 20)
43.         leftRect = pygame.Rect(340 + Globals.camera_x, 300 + Globals.camera_y, 38, 900)
44.         rightRect = pygame.Rect(750 + Globals.camera_x, 340 + Globals.camera_y, 20, 900)
45.         wallRect1 = pygame.Rect(467 + Globals.camera_x, 316 + Globals.camera_y, 14, 220)
46.         wallRect2 = pygame.Rect(416 + Globals.camera_x, 450 + Globals.camera_y, 66, 86)
47.         wallRect3 = pygame.Rect(584 + Globals.camera_x, 450 + Globals.camera_y, 172, 100)
48.         momRect = pygame.Rect(370 + Globals.camera_x, 520 + Globals.camera_y, 56, 74)
49.         tableRect = pygame.Rect(394 + Globals.camera_x, 606 + Globals.camera_y, 126, 54)
50.         tableRect1 = pygame.Rect(616 + Globals.camera_x, 570 + Globals.camera_y, 60, 96)
51.
52.         if upRect.collidepoint(upCollide) or wallRect1.collidepoint(upCollide) or wallRect2.collidepoint(upCollide) or wallRect3.collidepoint(upCollide) or momRect.collidepoint(upCollide) or tableRect.collidepoint(upCollide) or tableRect1.collidepoint(upCollide):
53.             upCol = True
54.         else:
55.             upCol = False
56.         if downRect.collidepoint(downCollide) or wallRect1.collidepoint(downCollide) or wallRect2.collidepoint(downCollide) or wallRect3.collidepoint(downCollide) or tableRect.collidepoint(downCollide) or tableRect1.collidepoint(downCollide):
57.             downCol = True
58.         else:
59.             downCol = False
60.         if leftRect.collidepoint(leftCollide) or wallRect1.collidepoint(leftCollide) or wallRect2.collidepoint(leftCollide) or wallRect3.collidepoint(leftCollide) or momRect.collidepoint(leftCollide) or tableRect.collidepoint(leftCollide) or tableRect1.collidepoint(leftCollide):
61.             leftCol = True
62.         else:
63.             leftCol = False
64.         if rightRect.collidepoint(rightCollide) or wallRect1.collidepoint(rightCollide) or wallRect2.collidepoint(rightCollide) or wallRect3.collidepoint(rightCollide) or tableRect.collidepoint(rightCollide) or tableRect1.collidepoint(rightCollide):
65.             rightCol = True
66.         else:
67.             rightCol = False
68.     elif mapNbr == 2:
69.         homeRect = pygame.Rect(645 + Globals.camera_x, 245 + Globals.camera_y, 125, 135)
70.
71.         if homeRect.collidepoint(upCollide):
72.             upCol = True
73.         else:
74.             upCol = False
75.         if homeRect.collidepoint(downCollide):
76.             downCol = True
77.         else:
78.             downCol = False
79.         if homeRect.collidepoint(leftCollide):
80.             leftCol = True
81.         else:
82.             leftCol = False
83.         if homeRect.collidepoint(rightCollide):
84.             rightCol = True
85.         else:
86.             rightCol = False
87.
88.     return
89.
90. def texts(txt): #en cours pour l'image de fond
91.     liste = ["yo", "tb", "sava", "cc"]
92.     pygame.font.init()
93.     myfont = pygame.font.SysFont("monospace", 50)
94.     label = myfont.render(liste[txt], 1, BLACK)
95.     """#tbt=pygame.rect(0,550,170,1280)
96.    tbt = pygame.Surface((1280, 170))
97.    gameDisplay.blit(tbt, (0, 550))
98.    tbt.fill(BLACK)"""
99.
100.     gameDisplay.blit(label, (100, 600))
101.
102.
103. pygame.init()
104. gameDisplay = pygame.display.set_mode((1280, 720))
105. pygame.display.set_caption('RPG ISN')
106. clock = pygame.time.Clock()
107.
108. crashed = False
109. play = False
110.
114. pygame.mixer.music.play(-1)"""
115.
116. for i in range(0, 185):
117.     for event in pygame.event.get():
118.         if event.type == pygame.QUIT:
119.             pygame.quit()
120.             quit()
121.     gameDisplay.blit(titleScreen, (0, i-185))
122.     pygame.display.update()
123.     clock.tick(60)
124.
125. for i in range(0, 650):
126.     gameDisplay.blit(titleScreen, (0, 0))
127.     gameDisplay.blit(titleMenu0, (0, -650 + i))
128.     pygame.display.update()
129.
130. while not crashed and not play:
131.
132.     for event in pygame.event.get():
133.         if event.type == pygame.QUIT:
134.             crashed = True
135.
136.         if event.type == pygame.MOUSEBUTTONUP:
137.             (mousePosX, mousePosY) = pygame.mouse.get_pos()
138.             print(mousePosX, mousePosY)
139.             if 472 <= mousePosX <= 806 and 481 <= mousePosY <= 608:
140.                 play = True
141.                 print("waaaa")
142.
143. if crashed:
144.     pygame.quit()
145.     quit()
146.
147. #playerBox = pygame.Surface((27, 15))
148. #playerBox.fill((255, 0, 0))
149.
150. #test = pygame.Surface((64, 64))
151. #test.fill((255, 0, 0))
152.
155. pygame.display.update()
156.
159.
162.
175.
178.
185.
187.
188. lastDir = playerDown0
189.
190. gameDisplay.blit(player, (640, 360))
191.
192. """pygame.display.flip()
194. pygame.mixer.music.play(-1)"""
195.
196. Globals.camera_x = 0
197. Globals.camera_y = 0
198.
199. Globals.mapNbr = 0
200.
201. BLACK = (0, 0, 0)
202. WHITE = (255, 255, 255)
203.
204. upCol = False
205. downCol = False
206. leftCol = False
207. rightCol = False
208. stepVar = 0
209. txt = 0
210. trainPos = 0
211. trainMove = False
212. inText = False
214. inPause = False
215. pauseDebugger = False
221. firstTime = True
222. emotionDelay = 0
223.
224. # noinspection PyInterpreter
225. while not crashed:
226.
227.     for event in pygame.event.get():
228.         if event.type == pygame.QUIT:
229.             crashed = True
230.
231.         key = pygame.key.get_pressed()
232.         if key[pygame.K_w]:
233.             if not inMenu and not inText:#la
234.                 Globals.camera_move = 1
235.             else:
240.                 else:
243.         elif key[pygame.K_s]:
244.             if not inMenu and not inText:
245.                 Globals.camera_move = 2
246.             else:
251.                 else:
254.         elif key[pygame.K_a]:
255.             if not inMenu and not inText:
256.                 Globals.camera_move = 3
257.             else:
259.         elif key[pygame.K_d]:
260.             if not inMenu and not inText:
261.                 Globals.camera_move = 4
262.             else:
264.         else:
265.             Globals.camera_move = 0
266.             stepVar = 0
267.             player = lastDir
268.         if key[pygame.K_LSHIFT]:
269.             sprint = 1
270.         else:
271.             sprint = 0
272.
273.         if key[pygame.K_RETURN] and inMenu is True or key[pygame.K_SPACE] and inMenu is True:
275.                 Globals.camera_x = 2310
276.                 while Globals.camera_y < 5588:
277.                     gameDisplay.blit(background, (-5000 + Globals.camera_x, -11620 + Globals.camera_y))
278.                     gameDisplay.blit(train, (640, 360))
279.                     Globals.camera_y += 10
280.                     pygame.display.update()
281.                     clock.tick(60)
282.                 Globals.camera_x = 2138
283.                 player = player.Right0
284.                 lastDir = player.Right0
286.                 trainPos = 1
288.                 Globals.camera_x = 2310
289.                 while Globals.camera_y < 10000:
290.                     gameDisplay.blit(background, (-5000 + Globals.camera_x, -11620 + Globals.camera_y))
291.                     gameDisplay.blit(train, (640, 360))
292.                     Globals.camera_y += 10
293.                     pygame.display.update()
294.                     clock.tick(60)
295.                 Globals.camera_x = 2138
296.                 player = playerRight0 #la
297.                 lastDir = playerRight0
299.                 trainPos = 2
300.
301.         if key[pygame.K_ESCAPE] and not inMenu:
303.             inPause = True
304.             pauseDebugger = True
305.
306.         if key[pygame.K_ESCAPE] and not inPause and leaveMenuAllowed is True:
309.
310.         if key[pygame.K_ESCAPE] and not pauseDebugger and inPause is True:
312.             inPause = False
314.
315.         if event.type == pygame.MOUSEBUTTONUP:
316.             (mousePosX, mousePosY) = pygame.mouse.get_pos()
317.             if 360 <= mousePosX <= 930 and 315 <= mousePosY <= 410 and inPause:
318.                 inPause = False
320.             elif 490 <= mousePosX <= 800 and 500 <= mousePosY <= 590 and inPause:
321.                 pygame.quit()
322.                 quit()
323.
324.             print(mousePosX - Globals.camera_x, mousePosY - Globals.camera_y)       #Outil screen pos
325.
326.         if key[pygame.K_SPACE] and inText:
327.             txt += 1
328.
329.         if event.type == pygame.MOUSEBUTTONUP:
330.             mousePos = pygame.mouse.get_pos()
332.                 inPause = False
335.                 pygame.quit()
336.                 quit()
337.
338.         print(event)
339.
340.     collisionTester(Globals.mapNbr)
341.
342.     if stepVar == 28:
343.         stepVar = 0
344.
345.     if Globals.camera_move == 1 and not upCol:
346.         stepVar += 1
347.         if Globals.camera_y <= 11220:
348.             if sprint == 0:
349.                 Globals.camera_y += 4
350.             else:
351.                 Globals.camera_y += 8
352.             if stepVar == 0:
353.                 player = playerUp0
354.             elif stepVar <= 1 and stepVar < 8:
355.                 player = playerUp1
356.             elif 8 <= stepVar < 15:
357.                 player = playerUp0
358.             elif 15 <= stepVar < 22:
359.                 player = playerUp2
360.             elif 22 <= stepVar < 28:
361.                 player = playerUp0
362.             lastDir = playerUp0
363.         else:
364.             print("mur")
365.     elif Globals.camera_move == 2 and not downCol:
366.         stepVar += 1
367.         if Globals.camera_y >= -372:
368.             if sprint == 0:
369.                 Globals.camera_y -= 4
370.             else:
371.                 Globals.camera_y -= 8
372.             if stepVar == 0:
373.                 player = playerDown0
374.             elif stepVar <= 1 and stepVar < 8:
375.                 player = playerDown1
376.             elif 8 <= stepVar < 15:
377.                 player = playerDown0
378.             elif 15 <= stepVar < 22:
379.                 player = playerDown2
380.             elif 22 <= stepVar < 28:
381.                 player = playerDown0
382.             lastDir = playerDown0
383.         else:
384.             print("mur")
385.     elif Globals.camera_move == 3 and not leftCol:
386.         stepVar += 1
387.         if Globals.camera_x <= 11272:
388.             if sprint == 0:
389.                 Globals.camera_x += 4
390.             else:
391.                 Globals.camera_x += 8
392.             if stepVar == 0:
393.                 player = playerLeft0
394.             elif stepVar <= 1 and stepVar < 8:
395.                 player = playerLeft1
396.             elif 8 <= stepVar < 15:
397.                 player = playerLeft0
398.             elif 15 <= stepVar < 22:
399.                 player = playerLeft2
400.             elif 22 <= stepVar < 28:
401.                 player = playerLeft0
402.             lastDir = playerLeft0
403.         else:
404.             print("mur")
405.     elif Globals.camera_move == 4 and not rightCol:
406.         stepVar += 1
407.         if Globals.camera_x >= -236:
408.             if sprint == 0:
409.                 Globals.camera_x -= 4
410.             else:
411.                 Globals.camera_x -= 8
412.             if stepVar == 0:
413.                 player = playerRight0
414.             elif stepVar <= 1 and stepVar < 8:
415.                 player = playerRight1
416.             elif 8 <= stepVar < 15:
417.                 player = playerRight0
418.             elif 15 <= stepVar < 22:
419.                 player = playerRight2
420.             elif 22 <= stepVar < 28:
421.                 player = playerRight0
422.             lastDir = playerRight0
423.         else:
424.             print("mur")
425.
426.     if Globals.mapNbr == 0:
427.         gameDisplay.blit(bedroom, (30 + Globals.camera_x, Globals.camera_y))
428.
429.         if 88 <= Globals.camera_x <= 112 and 68 <= Globals.camera_y <= 100:
430.             Globals.mapNbr = 1
431.             Globals.camera_x = 0
432.             Globals.camera_y = 0
433.     elif Globals.mapNbr == 1: #la dans ce if
434.         gameDisplay.blit(home, (-80 + Globals.camera_x, +180 + Globals.camera_y))
435.         gameDisplay.blit(mum, (380 + Globals.camera_x, 540 + Globals.camera_y))
436.
437.         if Globals.camera_x <= -8 and -4 <= Globals.camera_y <= 32:
438.             Globals.mapNbr = 0
439.             Globals.camera_x = 85
440.             Globals.camera_y = 76
441.         if 76 <= Globals.camera_x <= 140 and Globals.camera_y <= -318:
442.             Globals.mapNbr = 2
443.             Globals.camera_x = 0
444.             Globals.camera_y = 0
445.         mumRectXl = pygame.Rect(360 + Globals.camera_x, 550 + Globals.camera_y, 400, 400)
446.         mumRect = pygame.Rect(380 + Globals.camera_x, 540 + Globals.camera_y, 38, 48)
447.         if Player.rectXl.colliderect(mumRectXl) == 1 and firstTime:
448.             print("point d'exclamation")
449.             inText = True
450.             firstTime = False
451.             key = pygame.key.get_pressed()
452.         if inText:
453.             if emotionDelay < 100:
454.                 gameDisplay.blit(intero, (392 + Globals.camera_x, 525 + Globals.camera_y))
455.                 emotionDelay += 1
456.
457.     elif Globals.mapNbr == 2:
458.         gameDisplay.blit(background, (-5000 + Globals.camera_x, -11620 + Globals.camera_y))
459.
460.         if -24 <= Globals.camera_x <= 0 and 26 <= Globals.camera_y <= 44:
461.             Globals.mapNbr = 1
462.             Globals.camera_x = 112
463.             Globals.camera_y = -316
464.
465.         if not trainMove:
466.             if trainPos == 0:
467.                 gameDisplay.blit(train, (-1670 + Globals.camera_x, 75 + Globals.camera_y))
468.             elif trainPos == 1:
469.                 gameDisplay.blit(train, (-1670 + Globals.camera_x, -5350 + Globals.camera_y))
470.             else:
471.                 gameDisplay.blit(train, (-1670 + Globals.camera_x, -10000 + Globals.camera_y))
472.
473.         if 1920 <= Globals.camera_x <= 2160 and 56 <= Globals.camera_y <= 192 and menuLeaved is False:
480.         elif 1920 <= Globals.camera_x <= 2160 and 56 <= Globals.camera_y <= 192 and menuLeaved is True:
482.         elif inPause:
484.         else:
487.
488.     if not inText:
489.         txt = 0
490.
491.     if inText:
492.         if txt > 3:
493.
494.             inText = False
495.
496.         else:
497.             gameDisplay.blit(txtWindow, (0, 500))  # la don'tWork
498.             texts(txt)
499.             #definie l'image comme lastdir STP
500.
505.
506.     #gameDisplay.blit(playerBox, (658, 410))
507.     #gameDisplay.blit(test, (100 + Globals.camera_x, 100 + Globals.camera_y))
508.
509.     print(Globals.camera_x, Globals.camera_y)
510.     (mousePosX, mousePosY) = pygame.mouse.get_pos()
511.     print(mousePosX, mousePosY)
512.     gameDisplay.blit(player, (640, 360))
513.
514.     if Globals.mapNbr == 0:
515.         print("Chambre")
516.     elif Globals.mapNbr == 1:
517.         print("aaa")
518.     elif Globals.mapNbr == 2:
519.         print("world")
520.
521.     if inPause:
522.         pauseDebugger = False
523.         gameDisplay.blit(pause, (0, 0))
524.
525.     pygame.display.update()
526.     gameDisplay.fill(BLACK)  # la
527.     clock.tick(60)
528.
529. pygame.quit()
530. quit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top