Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php: bereich "auffüllen"

Empfohlene Antworten

wie funktioniert eigendlich der füllpinselprinzip (z.b. bei malprogrammen),

habe folgendes zweidimensionales arrayfeld:

beispiel: Xangeklickt, alle umliegenden 0en sollen zu 2en werden

also:

1 1 1 0 0 0 0 0 0 0

1 1 1 1 0 X 0 0 0 0

1 1 1 1 0 0 0 1 1 1

1 1 1 1 0 0 1 1 1 1

0 0 0 0 0 0 1 1 1 1

0 0 0 1 1 1 1 1 1 1

0 0 0 1 1 1 1 0 1 1

1 1 1 1 1 0 0 0 1 1

1 1 1 1 0 0 0 0 1 1

1 1 1 1 0 0 1 1 1 1

soll so werden:

1 1 1 2 2 2 2 2 2 2

1 1 1 1 2 X 2 2 2 2

1 1 1 1 2 2 2 1 1 1

1 1 1 1 2 2 1 1 1 1

2 2 2 2 2 2 1 1 1 1

2 2 2 1 1 1 1 1 1 1

2 2 2 1 1 1 1 0 1 1

1 1 1 1 1 0 0 0 1 1

1 1 1 1 0 0 0 0 1 1

1 1 1 1 0 0 1 1 1 1

habe das ganze mit folgender funktion versucht, stürzt aber immer ab..

schauen(5,1); //startwert

function schauen ($x,$y){

if ($feld[$x-1][$y+1]==0){$feld[$x+1][$y+1]=2; schauen($x-1,$y+1);}

if ($feld[$x-1][$y-1]==0){$feld[$x-1][$y-1]=2; schauen($x-1,$y-1);}

if ($feld[$x+1][$y+1]==0){$feld[$x+1][$y+1]=2; schauen($x+1,$y+1);}

if ($feld[$x+1][$y-1]==0){$feld[$x+1][$y-1]=2; schauen($x+1,$y-1);}

if ($feld[$x+1][$y]==0){$feld[$x+1][$y]=2; schauen($x+1,$y);}

if ($feld[$x-1][$y]==0){$feld[$x-1][$y]=2; schauen($x-1,$y);}

if ($feld[$x][$y+1]==0){$feld[$x][$y+1]=2; schauen($x,$y+1);}

if ($feld[$x][$y-1]==0){$feld[$x][$y-1]=2; schauen($x,$y-1);}

}

-habe auch mal die anzahl der functionsaufrufe auf 50 begrenzt, weil sich die schleife ja sonst immer wieder mehrfach + unendlich aufufen würde, hat aber auch nix gebracht.

-verbesserung wäre alle zutreffenden werte in ein array zu speichern & dann vor jeden functionsaufuf zu prüfen, ob die function mit den werten schonmal aufgerufen wurde. wie mache ich das am besten??

:confused:

hab mittlerweile den fehler selber gefunden, thread kann also theoretisch geschlossen werden..

Das sieht ja ganz nach Minesweeper aus (automatisches Freilegen von nicht belegten Feldern).

ja z.b., ist aber auch bei anderen spielen ganz nützlich..

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.