aboutsummaryrefslogtreecommitdiff
path: root/Client/Source/Phy2DLite/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Source/Phy2DLite/Tests')
-rw-r--r--Client/Source/Phy2DLite/Tests/test.cpp (renamed from Client/Source/Phy2DLite/Tests/test_p2d.cpp)27
1 files changed, 23 insertions, 4 deletions
diff --git a/Client/Source/Phy2DLite/Tests/test_p2d.cpp b/Client/Source/Phy2DLite/Tests/test.cpp
index 69737f6..6456b75 100644
--- a/Client/Source/Phy2DLite/Tests/test_p2d.cpp
+++ b/Client/Source/Phy2DLite/Tests/test.cpp
@@ -454,15 +454,17 @@ static void Demo9(Body* b, Joint* j)
}
}
-static void InitDemo()
+void(*demos[])(Body* b, Joint* j) = { Demo1, Demo2, Demo3, Demo4, Demo5, Demo6, Demo7, Demo8, Demo9 };
+
+static void InitDemo(int index)
{
world.Clear();
numBodies = 0;
numJoints = 0;
bomb = NULL;
- demoIndex = 0;
- Demo5(bodies, joints);
+ demoIndex = index;
+ demos[index](bodies, joints);
}
int main(int argc, char **argv) {
@@ -545,7 +547,7 @@ int main(int argc, char **argv) {
glOrtho(-zoom, zoom, -zoom / aspect + pan_y, zoom / aspect + pan_y, -1.0, 1.0);
}
- InitDemo();
+ InitDemo(5);
// Main loop
bool done = false;
@@ -568,6 +570,23 @@ int main(int argc, char **argv) {
done = true;
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
done = true;
+ if (event.type == SDL_KEYDOWN)
+ {
+ switch (event.key.keysym.sym)
+ {
+ case SDLK_1:
+ case SDLK_2:
+ case SDLK_3:
+ case SDLK_4:
+ case SDLK_5:
+ case SDLK_6:
+ case SDLK_7:
+ case SDLK_8:
+ case SDLK_9:
+ InitDemo(event.key.keysym.sym - SDLK_1);
+ break;
+ }
+ }
}
// Start the Dear ImGui frame