<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
comment selectionne des objet dans un Array2D?<br>
>>movePirate<br>
| move tempX tempY |<br>
<u>(self grid<br>
</u> <u>select: [:each | each notNil </u> <=ca ca ne
marche pas, il me dit 'Use >>self width: x height: y<<
instead'<br>
<u>and: [each isPirate]])</u><br>
do: [:each | <br>
tempX _ each place x.<br>
tempY _ each place y.<br>
[self size < tempX | self size < tempY | tempY < 0
| tempX < 0 | self grid at: tempX at: tempY notNil]<br>
whileTrue: [move _ 4 atRandom.<br>
move = 1<br>
ifTrue: [tempY _ tempY + 1].<br>
move = 2<br>
ifTrue: [tempY _ tempY - 1].<br>
move = 1<br>
ifTrue: [tempX _ tempX + 1].<br>
move = 1<br>
ifTrue: [tempX _ tempX - 1]].<br>
self grid<br>
at: tempX<br>
at: tempY<br>
put: each.<br>
self grid at: each place x at: each place y put:nil.<br>
each place: tempX @ tempY]<br>
</body>
</html>