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
| // Your code here
var x;
var y;
var a;
//création de la bordure
RectanglePlein(0, 0, 1280, 20, 'black');
RectanglePlein(1260, 20, 20, 110, 'black');
RectanglePlein(1260, 185, 20, 410, 'black');
RectanglePlein(0, 0, 20, 595, 'black');
RectanglePlein(0, 570, 1280, 25, 'black');
Deplacer(30, 50); //point de départ
Lever();
a = 0;
function Keypressed(k) {
if (k == Caractere_vers_Ascii('D')) {
Droite(90);
a = a + 90;
}
if (k == Caractere_vers_Ascii('Q')) {
Gauche(90);
a = a - 90;
}
if (k == Caractere_vers_Ascii('Z')) {
Avancer(2); //Avance le personnage
if (a < -360 || a > 360) {
a = 0;
}
if (a == 0 || a == 360 || a == -360) { //Actualise les coordonnées du personnage
y = y + 2;
}
if (a == 180 || a == -180) { //Actualise les coordonnées du personnage
y = y - 2;
}
if (a == 90 || a == -270) { //Actualise les coordonnées du personnage
x = x + 2;
}
if (a == 270 || a == -90) { //Actualise les coordonnées du personnage
y = y + 2;
}
}
}
Ecrire(x);
var T = Tableau(10, 18);
T = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0];
// T[numéro de ligne (0 à 9)*nombre de caractère par ligne + numéro du caractère(de 0 à 17)]
Ecrire(T[0 * 18 + 0]); //test du tableau
for (i = 0; i <= 9; i = i + 1) {
for (j = 0; j <= 17; j = j + 1) {
if (T[i * 18 + j] == 0) {
RectanglePlein(j * 1240 / 18 + 20, i * 55 + 20, 1240 / 18, 55, 'black');
if (x == j * 1240 / 18 + 20) { //Déplacer la tortue vers l'arrière lorqu'elle arrive sur la limite d'un mur
Deplacer(x - 2, y);
}
if (y == i * 55 + 20) {
Deplacer(x, y - 2);
}
if (x == (j+1) * 1240 / 18 + 20) {
Deplacer(x + 2, y);
}
if (y == (i+1) * 55 + 20) {
Deplacer(x, y + 2);
}
}
}
} |
Partager