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
- ubuntu stonking: libsdl-perl 2.548-6build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms