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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
while True:
# mouse coords
textsurface = myfont.render(str(pygame.mouse.get_pos()), False, RED, BLACK)
# Affichage des coordonnées de la souris
right_canvas.blit(textsurface, (10, 0))
# handle events
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit(0)
elif event.type == pygame.KEYDOWN:
# left_canvas.fill(WHITE)
# permet de redessiner le left_canvas avec le
# la map qui est chargée depuis le fichier
# json correspondant au niveau courant
# utilitaires.loadLevel("Save/saveGAME/",
# left_canvas,
#*WHITE,
# index_current_level)
# F12
if event.key == pygame.K_F12:
print("F12")
# F11
if event.key == pygame.K_F11:
print("F11")
# F9
if event.key == pygame.K_F9:
print("F9")
# F8
if event.key == pygame.K_F8:
print("F8")
# utilitaires.makeSVG03("Save/saveGAME/57.json")
# F7
if event.key == pygame.K_F7:
print("F7")
if event.key == pygame.K_a:
if (index_current_level <= 0):
index_current_level = 0
utilitaires.loadLevel("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
else:
index_current_level -= 1
utilitaires.loadLevel("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
print(index_current_level)
if event.key == pygame.K_z:
if (index_current_level >= len(files)):
index_current_level = len(files)
utilitaires.loadLevel01PrTest("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
else:
index_current_level += 1
utilitaires.loadLevel01PrTest("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
print(index_current_level)
if event.key == pygame.K_h:
if p01:
print("p01 existe")
utilitaires.loadLevel("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
p01.move_left()
p01.draw(left_canvas, left_canvas_rect)
pygame.display.update()
else:
print("p01 n'existe pas")
if event.key == pygame.K_j:
if p01:
print("p01 existe")
utilitaires.loadLevel("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
p01.move_right()
p01.draw(left_canvas, left_canvas_rect)
pygame.display.update()
else:
print("p01 n'existe pas")
if event.key == pygame.K_p:
if p01:
print("p01 existe")
utilitaires.loadLevel("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
p01.move_up()
p01.draw(left_canvas, left_canvas_rect)
pygame.display.update()
else:
print("p01 n'existe pas")
if event.key == pygame.K_m:
if p01:
print("p01 existe")
utilitaires.loadLevel("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
p01.move_down()
p01.draw(left_canvas, left_canvas_rect)
pygame.display.update()
else:
print("p01 n'existe pas")
# ESC quitte le programme
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit(0)
# qd les boutons souris st relachés
elif event.type == pygame.MOUSEBUTTONUP:
# qd le bouton gauche de la souris est relaché
# imprime les coordonnées de la souris
# et de chacun des rooms
if event.button == 1: # left mouse button
print("01: Mouse clicked")
pos = pygame.mouse.get_pos()
if button_area.collidepoint(pos[0] - right_canvas_rect.x,
pos[1] - right_canvas_rect.y):
print(pos)
print("sur le bouton")
# charge le 1° fichier json du repertoire
# en tant que 1° niveau
"""
print("")
print("CONTENU de lvl: " +
str(lvl))
print("")
"""
lvl = utilitaires.loadLevel01PrTest("Save/saveGAME/",
left_canvas,
WHITE,
index_current_level)
p01 = utilitaires.createPlayer("Audrey")
print("nom du joueur: " + str(p01.get_name()))
p01.draw(left_canvas, left_canvas_rect)
pygame.display.update()
"""
utilitaires.placePlayer(left_canvas,
lvl, p01)
"""
# print("nom du joueur: " + str(p01.get_name()))
# qd le bouton droit de la souris est relaché
# imprime 1 message
elif event.button == 3: # right mouse button
print("04: Right button clicked")
# draw left & right canvases
screen.blit(left_canvas, (0, 0))
screen.blit(right_canvas, (left_canvas_width, 0))
pygame.display.update() |
Partager