Polyspiral: Difference between revisions
→SDL full animation: Add some more control options, make update speed not dependant on sleep. I'm just playing at this point.
Thundergnat (talk | contribs) m (→SDL full animation: Add pause function) |
Thundergnat (talk | contribs) (→SDL full animation: Add some more control options, make update speed not dependant on sleep. I'm just playing at this point.) |
||
Line 1,475:
===SDL full animation===
Uses the same basic algorithm but fully animated. Use the up / down arrow keys to speed up / slow down the update speed. Use PgUp / PgDn keys to increment / decrement animation speed by large amounts. Use left / right arrow keys to reverse the "direction" of angle change. Press Space bar to toggle animation
<lang perl6>use SDL2::Raw;
Line 1,502:
K_RIGHT => 79,
K_SPACE => 44,
K_PGUP => 75,
K_PGDN => 78,
);
Line 1,508 ⟶ 1,510:
my @rgb = (^$lines).map: { hsv2rgb(($_ * 360/$lines % 360)/360, 1, 1).list };
my ($x1, $y1);
my $dir = 1;
my $incr = .
my $step = $incr*100;
main: loop {
Line 1,526 ⟶ 1,527:
when 'K_LEFT' { $dir = -1 }
when 'K_RIGHT' { $dir = 1 }
when 'K_UP' { $
when 'K_DOWN' { if $
when 'K_PGUP' { $step += $incr*50 }
when 'K_PGDN' { $step -= $incr*50; $step = $step < $incr ?? $incr !! $step }
when 'K_SPACE' { $step = $step ?? 0 !! $incr }
}
Line 1,544 ⟶ 1,547:
@rgb.=rotate;
SDL_RenderPresent($render);
SDL_SetRenderDrawColor($render, 0, 0, 0, 0);
SDL_RenderClear($render);
|