CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

Help Java

cell-95
cell-95
Niveau 6
06 juin 2017 à 14:27:28

Salut,
J'ai besoin d'aide pour comprendre cette boucle issue de la vidéo suivante merci https://www.youtube.com/watch?v=xAvFYEXxWKg.
int[][] go(int dy, int dx, boolean updatescore) {
int[][] bak = new int[4][4];
for (int j = 0 ; j < 4; j++) for (int i = 0 ; i < 4; i++) bak[j][i] = b[j][i];
boolean moved = false;
if (dx != 0 || dy != 0) {
int d = dx != 0 ? dx : dy;
for (int perp = 0; perp < b.length; perp++)
for (int tang = (d > 0 ? b.length - 2 : 1); tang != (d > 0 ? -1 : b.length); tang-=d) {
int y = dx != 0 ? perp : tang, x = dx != 0 ? tang : perp, ty = y, tx = x;
if (bak[y][x]==0) continue;
for (int i=(dx != 0 ? x : y)+d; i!= (d > 0 ? b.length : -1); i+=d) {
int r = dx != 0 ? y : i, c = dx != 0 ? i : x;
if (bak[r][c] != 0 && bak[r][c] != bak[y][x]) break;
if (dx != 0) tx = i;
else ty = i;
}
if ( (dx != 0 && tx == x) || (dy != 0 && ty == y)) continue;
else if (bak[ty][tx]==bak[y][x]) {
bak[ty][tx] *= 2;
if(updatescore) score += bak[ty][tx];
moved = true;
}
else if ( (dx != 0 && tx != x) || (dy != 0 && ty != y)) {
bak[ty][tx] = bak[y][x];
moved = true;
}
if (moved) bak[y][x] = 0;
}
}
return moved ? bak : null;
}

BLOQUER

Sujet fermé pour la raison suivante : http://www.jeuxvideo.com/forums/0-47-0-1-0-1-0-programmation.htm
Sous forums
  • Aide à l'achat Mac
  • Création de sites web
  • Création de Jeux
  • Linux
  • Programmation
  • Internet
  • Steam Deck
  • Macintosh
  • Hardware