diff --git a/include/cpp3ds/Input.h b/include/cpp3ds/Input.h index dffc992..ec51311 100644 --- a/include/cpp3ds/Input.h +++ b/include/cpp3ds/Input.h @@ -3,6 +3,8 @@ #define HID 0x10146000 +#define SLIDERSTATE 0x10144000 + namespace cpp3ds { enum Button { @@ -34,7 +36,10 @@ namespace cpp3ds { int getHID(); int last_hid; public: + static float slider; static bool isDown(Button button); + static void update3DSlider(); + static float get3DSlider(){ return Input::slider; } // int bind(Button button, Event event); // void unbind(int binding); // void unbindAll(); diff --git a/src/Input.cpp b/src/Input.cpp index de05685..f08d5bc 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -3,6 +3,8 @@ namespace cpp3ds { + float Input::slider = 0; + int Input::getHID(){ last_hid = read_word(HID); return last_hid; @@ -12,4 +14,8 @@ namespace cpp3ds { return (~read_word(HID) & button); } + void Input::update3DSlider(){ + Input::slider = (float)(read_word(SLIDERSTATE) & 0xFF) / 255; + } + } diff --git a/src/Stage.cpp b/src/Stage.cpp index 53ea750..bcec4f2 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -37,13 +38,16 @@ namespace cpp3ds { void Stage::draw(Screen& screen, float x, float y, bool use3D, bool isLeftside) { // Loop through and draw all actors on the stage ActorNode* cur = actorTail; + x += this->x; + y += this->y; while (cur != NULL) { Actors::Actor& actor = *cur->actor; if (use3D) { - float slider = 1.0f * actor.depth3d; - x = (isLeftside) ? x - slider : x + slider; + float slider = Input::get3DSlider() * actor.depth3d; + actor.draw(screen, (isLeftside) ? x-slider : x+slider, y, use3D, isLeftside); + } else { + actor.draw(screen, x, y, use3D, isLeftside); } - actor.draw(screen, this->x + x, this->y + y, use3D, isLeftside); cur = cur->prev; } } diff --git a/src/TopScreen.cpp b/src/TopScreen.cpp index 663b218..767178a 100644 --- a/src/TopScreen.cpp +++ b/src/TopScreen.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -11,7 +12,7 @@ namespace cpp3ds { void TopScreen::draw(Drawable& obj, float x, float y, bool use3D) { if (use3D) { - float slider = 1.0f * obj.depth3d; + float slider = Input::get3DSlider() * obj.depth3d; obj.draw(left_screen, x - slider, y, use3D, true); obj.draw(right_screen, x + slider, y, use3D, false); } else {