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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
std::ofstream Output("level1.txt", std::ios::binary); Output.write((char*) &numberOfStaticBoxes, sizeof(int)); Output.write((char*) &Static[0].textureNumber, sizeof(int)); Output.write((char*) &Static[0].xPos, sizeof(float)); Output.write((char*) &Static[0].yPos, sizeof(float)); Output.write((char*) &Static[0].width, sizeof(float)); Output.write((char*) &Static[0].heigth, sizeof(float)); Output.write((char*) &Static[0].rotation, sizeof(float)); Output.write((char*) &Static[1].textureNumber, sizeof(int)); Output.write((char*) &Static[1].xPos, sizeof(float)); Output.write((char*) &Static[1].yPos, sizeof(float)); Output.write((char*) &Static[1].width, sizeof(float)); Output.write((char*) &Static[1].heigth, sizeof(float)); Output.write((char*) &Static[1].rotation, sizeof(float)); Output.close(); |
C-/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 |
std::ifstream Input("level1.txt", std::ios::binary); int numberOfStaticBoxes = 1; s_Static Static[2]; if (Input != NULL) // hier ist Input 0, darum is was mit dem einlesen falsch.. { Input.read((char*) &numberOfStaticBoxes, sizeof(int)); Input.read((char*) &Static[0].textureNumber, sizeof(int)); Input.read((char*) &Static[0].xPos, sizeof(float)); Input.read((char*) &Static[0].yPos, sizeof(float)); Input.read((char*) &Static[0].width, sizeof(float)); Input.read((char*) &Static[0].heigth, sizeof(float)); Input.read((char*) &Static[0].rotation, sizeof(float)); Input.read((char*) &Static[1].textureNumber, sizeof(int)); Input.read((char*) &Static[1].xPos, sizeof(float)); Input.read((char*) &Static[1].yPos, sizeof(float)); Input.read((char*) &Static[1].width, sizeof(float)); Input.read((char*) &Static[1].heigth, sizeof(float)); Input.read((char*) &Static[1].rotation, sizeof(float)); Input.close(); for (int i = 0; i<=1; i ++) { m_game->CreateStatic(&Static[i]); } } |
Zitat von »"Nox"«
hmm, sicher? Weil "s_Static Static[2];". Nach meinem Kenntnisstand bekommt man für sizeof(s_Static)); damit was anderes als für sizeof(Static[0]));
Zitat von »"Unknown"«
Habe auch schon versucht jede variabel einzeln ein und auszulesen. Ging auch net ..
C-/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 |
void CGame::CreateStatic(s_Static *s_static) { b2BodyDef bodyDef; bodyDef.position.Set(s_static->xPos, s_static->yPos); bodyDef.angle = s_static->rotation*DEGTORAD; b2Body *m_body = m_world->CreateBody(&bodyDef); b2PolygonDef shapeDef; float width2 = (s_static->width/30.0f)/2.0f; float heigth2 = (s_static->heigth/30.0f)/2.0f; shapeDef.SetAsBox(width2, heigth2); m_body->CreateShape(&shapeDef); m_body->SetMassFromShapes(); CStatic *m_static = new CStatic; HTEXTURE *texture = GetGroundTexture(s_static->textureNumber); m_static->Create(texture, m_body, s_static); m_staticBodyList.push_back(m_body); m_staticSpriteList.push_back(m_static); } |
Zitat
if (Input != NULL) // hier ist Input 0, darum is was mit dem einlesen falsch..
Zitat von »"Unknown"«
@dot: das mit den einzelnen Variablen ein und auslesen mit den gleichen sizes geht auch net der Fehler leigt beim einlesen, bzw die schreibrechte, ausm welchen Grund auch immer.
C-/C++-Quelltext |
|
1 |
Output.write((char*) &Static[0], sizeof(Static[0])); |
C-/C++-Quelltext |
|
1 |
Input.read((char*) &Static[1], sizeof(s_Static)); |
Zitat von »"Unknown"«
Also mit den Leserechten komme ich net weiter, und ihr könnt mir ja auch nicht aufn PC gucken
Iwie is das Bullshit
Werbeanzeige