pods::...terface(3pm)

πŸŽ€ pods::...terface(3pm) πŸŽ€

okay bestie, welcome to the User Contributed Perl Documentation corner of the group chat πŸ’– this page is pods::...terface(3pm), and it's serving Interface Physics and Rendering with the Controller with callbacks. we're so back.


🌸 NAME 🌸

SDLx::Controller::Interface β€” Interface Physics and Rendering with the Controller with callbacks. no cap, that's the whole name vibe πŸ¦‹

πŸ¦‹ CATEGORY πŸ¦‹

Extension, Controller β€” that's it, that's the category duo ✨

πŸŽ€ SYNOPSIS πŸŽ€

okay so here's the demo code, and we're keeping it exactly as it is, bestie:

        use SDL;
        use SDLx::App;
        use SDLx::Controller::Interface;

        #SDLx::App is a controller
        my $app = SDLx::App->new(width => 200, height => 200 );

        my $ball = SDLx::Controller::Interface->new( x=> 10, y => 50, v_x => 10, v_y=> 20 );
        #Set the initial state of the ball's physics, this is optional

        $ball->set_acceleration(
           sub {
                     my ($time, $current_state) = @_;
                     return( 0, -10, 0 ); # Return accelerations (x,y,rotation)
               }
        );

        my $ball_render = sub {
              my $state = shift;

              $app->draw_rect( undef, 0 );
              $app->draw_rect( [$state->x, $state->y, 10,10], [255,0,0,255] );
              $app->update();
        };

        $ball->attach( $app, $ball_render, @params );

        $app->run();

        $ball->detach(); #can be called at anytime (for example when ball 'dies')

🫢 DESCRIPTION 🫢

the original DESCRIPTION is giving mysterious silent treatment β€” literally no extra prose here, so we're sliding straight into the methods. periodt πŸ’…

✨ METHODS ✨

πŸ’… set_acceleration πŸ’…

this lets you set the acceleration callback, which defines the interface's behaviour in terms of x, y, and rotation. iconic.

         $interface->set_acceleration (
             sub {
                my ($time, $current_state) = @_;

                return ( $accel_x, $accel_y, $torque );
             }
         );

these accelerations are arbitrary and can be set to any frame of reference. your render callback will handle how to interpret it. iykyk πŸ’«

the callback will receive the time and the current state as a SDLx::Controller::State element.

πŸ¦‹ attach πŸ¦‹

attaches the interface to a controller with a render callback. we love a callback moment 🫢

         $interface->attach( $controller, $render, @params );

where $render is a callback that receives the interpolated SDLx::Controller::State.

         my $render = sub {
               my ($state, @params) = @_;
               # draw the current $state.
         };

the @params are any extra parameters you would like to pass to the $render callback. slay ✨

🌈 current 🌈

         my $current_state = $interface->current();

returns the current state of the interface as a SDLx::Controller::State. bestie, that's the now-now state πŸ’–

🌸 previous 🌸

         my $previous_state = $interface->previous();

returns the previous state of the interface as a SDLx::Controller::State. the before-times, but make it state πŸŽ€

πŸ’€ detach πŸ’€

         $interface->detach();

if $interface has been attach()'ed to any controller it will be detached now. boom, un-attached, bye-bye πŸ‘‹

πŸ™ˆ OTHER METHODS πŸ™ˆ

Don't use these unless you really really want to. seriously, bestie, this is the handle with care shelf.

πŸ”₯ acceleration πŸ”₯

call the acceleration callback once. one little callback, one little moment ⭐

🧚 interpolate 🧚

interpolate the current state. smooth moves only πŸ’«

πŸ’œ evaluate πŸ’œ

evaluate the new current and previous state. it's giving state inspection era πŸ”

πŸ‘‘ update πŸ‘‘

update the states by integrating with time. math girlies rise 🌈

🌟 AUTHORS 🌟

see "AUTHORS" in SDL. that's the whole authors section, no notes πŸ’…


and that's the page, bestie πŸ’– it's filed under pods::...terface(3pm), running with perl v5.42.3, dated 2026-08-19 β€” mwah, go render something iconic πŸŽ€βœ¨

πŸ“¦ where this page comes from