Polyspiral: Difference between revisions
m
→SDL full animation: Add ability to "reverse" direction
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add a second fully animated version) |
Thundergnat (talk | contribs) m (→SDL full animation: Add ability to "reverse" direction) |
||
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 left / right arrow keys to reverse the "direction" of angle change.
<lang perl6>use SDL2::Raw;
Line 1,508:
my ($x1, $y1);
my $sleep = 0.03;
my $dir = 1;
main: loop {
$angle = ($angle + $dir * .01/π) % τ;
($x1, $y1) = $width div 2, $height div 2;
Line 1,520 ⟶ 1,521:
if ARROW_KEYS(.scancode) -> $comm {
given $comm {
when 'K_LEFT' { $
when 'K_RIGHT' { $
when 'K_UP' { $sleep -= .
when 'K_DOWN' { $sleep += .
}
}
Line 1,559 ⟶ 1,560:
}
( $r, $g, $b ).map: ((*+$m) * 255).Int
}</lang>▼
▲</lang>
=={{header|Phix}}==
|