Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
switch (Fields[x, y]) { case FieldTypes.Bla: objWriter.WriteLine('.'); break; case FieldTypes.Bla: objWriter.WriteLine('0'); break; } |
C#-Quelltext |
|
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 |
0000000000000000 0.....0........0 0.....0........0 0...3..........0 0..............0 0.....0..0.....0 0.....0.0.0....0 00000000...0...0 0..........0...0 0..........0...0 0..........0...0 0..........0...0 0.......0..0...0 0.......0......0 0.......0......0 0...0...0......0 0...0..........0 0..000.........0 0....0.........0 0....0.........0 0....0.........0 0....0.2.......0 0..1.0.........0 0....0.........0 0000000000000000 |
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
0000000000000000000000000 0......0................0 0......0............1...0 0......0.........0......0 0..3...0.......000......0 0......0.........00000000 000..000................0 0......0............2...0 0.....0.....0000........0 0....0..................0 0.....0.................0 0......000000...........0 0.......................0 0.......................0 0.......................0 0000000000000000000000000 |
C#-Quelltext |
|
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 |
public FieldTypes[,] Fields { get; set; } const int MapHeight = 16; const int MapWidth = 25; public void SaveMap(String fileName) { try { StreamWriter sw; sw = new StreamWriter(@fileName + ".txt"); int i = 0; for (int x = 0; x < MapWidth; x++) { for (int y = 0; y < MapHeight; y++) { if (i >= MapHeight) { sw.WriteLine(); i = 0; } switch (Fields[x,y]) { case FieldTypes.Nothing: sw.Write('.'); break; case FieldTypes.Block: sw.Write('0'); break; case FieldTypes.Goal: sw.Write('1'); break; case FieldTypes.Spawn1: sw.Write('2'); break; case FieldTypes.Spawn2: sw.Write('3'); break; } i++; } } System.Windows.Forms.MessageBox.Show("Die Map wurde erfolgreich gespeichert"); sw.Close(); sw.Dispose(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("" + ex); } } |
Alter Hase
Beruf: Softwareentwickler (aktuell Web/Node); Freiberuflicher Google Proxy
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
0...............0........ .......0...............0. ..............0.......... .....0.........1.....0... ............0............ .0.00000.........0.0...0. ........0.0...0.........0 .0...0.......000.0...0000 0000....0...0...........0 .3.0...........0...0..... ......0...0...........0.. .0...........0...0....... ....0...0.......2...0...0 ...........0...0......... ..0...0...........0...0.. .........00000........... |
C#-Quelltext |
|
1 2 3 4 5 |
if (i >= MapWidth) //Vorher: i>=MapHeight { sw.WriteLine(); i = 0; } |
C#-Quelltext |
|
1 2 3 4 |
01010101 10101010 02020202 20202020 |
C#-Quelltext |
|
1 2 |
0102/*nächsteSpalte*/1020/*nächsteSpalte*/0102/*nächsteSpalte*/1020/*Umbruch da Integer == 16*/ 0102/*nächsteSpalte*/1020/*nächsteSpalte*/0102/*nächsteSpalte*/1020/*kein Umbruch, da Schleife(n) Bedingungen erfüllt, Map gespeichert*/ |
C#-Quelltext |
|
1 2 |
0102102001021020 0102102001021020 |
C#-Quelltext |
|
1 2 3 |
for (int y = 0; y < MapHeight; ++y) { for (int x = 0; x < MapWidth; ++x) |
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »Checkmateing« (30.09.2012, 13:26)
Werbeanzeige