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-/C++-Quelltext |
|
1 |
OSave.write ((char*) &pFleet[p+1].activated, sizeof (pFleet[p+1].activated)); |
C-/C++-Quelltext |
|
1 |
ILoad.read ((char*) &pFleet[p+1].activated, sizeof (pFleet[p+1].activated)); |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Ist es Dir denn klar?Und warum machst du &pFleet? Damit bekommst du doch eine Adresse. Was Char-Pointer sollen ist dir schon klar oder?
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Quellcode |
|
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 94 95 96 97 98 99 100 101 102 103 104 105 |
// ShowHighscore // // Aufgabe: Die Highscore im Menü ausgeben // void CHighscore::ShowHighscore () { // Variable zum Speichern der Erreichten Punkte int Points = 0; int FirstPlace = 0; int SecondPlace = 0; int ThirdPlace = 0; ////////////////////////////////// // Datei öffnen zum Auslesen der Erreichten Punkte ifstream RankingInput ("Ranking.fuck", ios::binary); if(RankingInput == NULL) { cout << "Datei konnte nicht zum Lesen geöffnet werden. \n"; } else { // Erreichte Punkte in Variabalen Points speichern RankingInput.read (reinterpret_cast(&Points), sizeof(Points)); RankingInput.read (reinterpret_cast(&FirstPlace), sizeof(FirstPlace)); RankingInput.read (reinterpret_cast(&SecondPlace), sizeof(SecondPlace)); RankingInput.read (reinterpret_cast(&ThirdPlace), sizeof(ThirdPlace)); } // Datei schließen RankingInput.close (); /////////////////////// // Neuer dritter Platz? if (Points > ThirdPlace && Points <= SecondPlace) { ThirdPlace = Points; } /////////////////////// // Neuer zweiter Platz? if (Points > SecondPlace && Points <= FirstPlace) { ThirdPlace = SecondPlace; SecondPlace = Points; } ////////////////////// // Neuer erster Platz? if (Points > FirstPlace) { ThirdPlace = SecondPlace; SecondPlace = FirstPlace; FirstPlace = Points; } cout << "Points: " << Points << "\n"; cout << "1.Platz: " << FirstPlace << " Punkte \n"; cout << "2.Platz: " << SecondPlace << " Punkte \n"; cout << "3.Platz: " << ThirdPlace << " Punkte \n\n"; // Points zurücksetzen Points = 0; //////////////////////////////////// // Ranglisten-Datei zum Schreiben öffnen ofstream RankingOutput ("Ranking.fuck", ios::binary); if(RankingOutput == NULL) { cout << "Datei konnte nicht zum Schreiben geöffnet werden.\n"; } else { // Variablen der Highscore-Instanz in Datei schreiben RankingOutput.write (reinterpret_cast(&FirstPlace), sizeof(FirstPlace)); RankingOutput.write (reinterpret_cast(&SecondPlace), sizeof(SecondPlace)); RankingOutput.write (reinterpret_cast(&ThirdPlace), sizeof(ThirdPlace)); // Erreichte Punkte in Variabalen Points speichern RankingOutput.write (reinterpret_cast(&Points), sizeof (Points)); } // Datei schließen RankingOutput.close (); } // ShowHighscore |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Werbeanzeige