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
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 |
float worldTob2X (float x) { if (x<400.0f || x>400.0f) { float tempX = x - 400.0f; tempX = tempX/30; return tempX; } else {return 0.0f;}; } float worldTob2Y (float y) { if (y > 300.0f) { float tempY = 300.0f - y; tempY = tempY/30; return tempY; } if (y < 300.0f) { float tempY = 300.0f - y; tempY = tempY/30; return tempY; } if (y == 300.0f) { return 0.0f; } } float b2ToWorldX (float x) { float tempX; tempX = (800.0f/2.0f)+(30.0f*x); return tempX; } float b2ToWorldY (float y) { float tempY; tempY =(600.0f/2.0f)-(30.0f*y); return tempY; } |
Quellcode |
|
1 2 3 4 5 6 7 8 |
void CSprite::Render() { b2Vec2 position = m_body->GetPosition(); m_xPos=(b2ToWorldX(position.x*m_zoom)); m_yPos=(b2ToWorldY(position.y*m_zoom)); m_rotation = (m_body->GetAngle()); m_sprite->RenderEx(m_xPos, m_yPos, m_rotation,m_zoom); } |
Zitat von »"Deviloper"«
Ist nur viel schneller
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 |
float g_width, g_heigth; // des Fensters // foreward decleration namespace hge { class Point; } namespace b2 { class Point { float m_x; float m_y; public: Point(const float x = 0.0f, const float y = 0.0f) : m_x(x), m_y(y) {} public: operator hge::Point() const { return hge::Point(m_x * 30 + (g_width >> 1)), m_y * 30 + (g_height >> 1))); } public: const float get_x() const { return m_x; } const float get_y() const { return m_y; } void set_x(const float x) { m_x = x; } void set_y(const float y) { m_y = y; } }; }; // b2 namespace hge { class Point { float m_x; float m_y; public: Point(const float x = 0.0f, const float y = 0.0f) : m_x(x), m_y(y) {} public: operator b2::Point() const { return b2::Point((m_x - (g_width >> 1)) / 30, (m_y - (g_height >> 1)) / 30); } public: const float get_x() const { return m_x; } const float get_y() const { return m_y; } void set_x(const float x) { m_x = x; } void set_y(const float y) { m_y = y; } }; }; // hge void init(const float width, const float heigth) { g_width = width; g_heigth= heigth; } |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
if (y > 300.0f) { float tempY = 300.0f - y; tempY = tempY/30; return tempY; } if (y < 300.0f) { float tempY = 300.0f - y; tempY = tempY/30; return tempY; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 |
inline const float world_to_b2_X(const float x) { return (x - (g_width >> 1)) / 30.0f; } inline const float world_to_b2_Y(const float y) { return ((g_height >> 1) - y) / 30.0f); } inline const float b2_to_world_X(const float x) { return static_cast<float>(g_width >> 1) + x * 30.0f; } inline const float b2_to_world_Y(const float y) { return static_cast<float>(g_height >> 1) - y * 30.0f; } |
Quellcode |
|
1 2 3 4 5 6 7 8 9 |
------ Erstellen gestartet: Projekt: 2D Simulation, Konfiguration: Debug Win32 ------ Verknüpfen... LINK : warning LNK4098: Standardbibliothek "LIBCMTD" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden. csprite.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""float const __cdecl b2_to_world_Y(float)" (?b2_to_world_Y@@YA?BMM@Z)" in Funktion ""public: void __thiscall CSprite::Render(void)" (?Render@CSprite@@QAEXXZ)". csprite.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""float const __cdecl b2_to_world_X(float)" (?b2_to_world_X@@YA?BMM@Z)" in Funktion ""public: void __thiscall CSprite::Render(void)" (?Render@CSprite@@QAEXXZ)". C:\Dokumente und Einstellungen\Fabian\Desktop\C++\hge box2d\2D Simulation\Debug\2D Simulation.exe : fatal error LNK1120: 2 nicht aufgelöste externe Verweise. Das Buildprotokoll wurde unter "file://c:\Dokumente und Einstellungen\Fabian\Desktop\C++\hge box2d\2D Simulation\2D Simulation\Debug\BuildLog.htm" gespeichert. 2D Simulation - 3 Fehler, 1 Warnung(en) ========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ========== |
Quellcode |
|
1 2 |
const float b2_to_world_X(const float x) { return static_cast<float>(g_width >> 1) + x * 30.0f; } |
Quellcode |
|
1 2 |
const float b2_to_world_X(const float x) { return static_cast<float>(g_width >> 1) - x * 30.0f; } |
Werbeanzeige