bonjour a tous,

mon problème est dans le titre, TypeError: 'NoneType' object is not iterable à la ligne 37

je ne vois pas ou ça bug


voici mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
# -*-coding:Utf-8 -*
 
import os
 
from map import Map 
 
import pygame
pygame.init()
 
myMap = Map()
myMap.printMap()
 
def rulesGames():
 
	print("Rules of the game")
	# ecrire les regles du jeu
 
 
rulesGames()
 
 
 
def movement():
 
 
 
	wall = "O"
	mcGyver = "X"
	road = " "
 
 
	newPosition = myMap.position("X")
	exit = myMap.position("G")
	oldCase = " "
	print("\n".join(myMap.save))
 
	while list(newPosition) != list(exit):
 
		command = 0 
		command = input("What direction ?")
 
		if len(command) == 1:
 
			direction = 1
			miles = 1
 
		else: 
			direction = command[0]
			miles = int(command[1:])
 
 
		for i in range(miles):
			Oldposition = myMap.position("X")
			newPosition = list(Oldposition) 
 
 
 
		if event.type == KEYDOWN:
 
			if event.key == K_UP:
				newPosition[0] -= 1
 
			if event.key == K_RIGHT:
				newPosition[1] -= 1
 
			if event.key == K_DOWN:
				newPosition[0] += 1
 
			if event.key == K_LEFT:
				newPosition[1] += 1 
 
 
 
 
 
			if myMap.atPosition(newPosition) != wall:
				myMap.write(Oldposition, oldCase)
				oldCase = myMap.read(newPosition)
				myMap.write(newPosition, "X")
 
 
	print("\n".join(myMap.save))
 
	print("You did it !")
 
movement()

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
# -*-coding:Utf-8 -*
import os
 
class Map: 
 
 
	def __repr__(self):
		return "<Map {}>".format(self.name)
 
 
 
	def printMap(self):
 
		map = os.listdir("map")
		mapFile = open("./Map/"+map[0], "r")
		print(mapFile.read())
		self.save = mapFile.read().splitlines()
 
 
 
	def size(self):
		absc = len(save[0])
		ordi = len(save)
 
		return(absc, ordi)
 
 
 
	def position(self, wanted):
 
		for i, line in enumerate(self.save):
			for j, character in enumerate(line):
 
				if character == wanted:
 
					abscissa = i
					ordinate = j
 
					return(abscissa, ordinate)
 
 
	def readMap(self, position, character):
		x = position[0]
		y = position[1]
 
		line = list(self.save[x])
		line[y] = character
 
		self.save[x] = "".join(line)
 
 
	def atPosition(self, position):
		return(self.save[position[0]][position[1]])
Merci pour votre aide !