Jump to content

Polyspiral: Difference between revisions

m
→‎SDL full animation: Add ability to "reverse" direction
(→‎{{header|Perl 6}}: Add a second fully animated version)
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' { $sleepdir += .001-1 }
when 'K_RIGHT' { $sleepdir -= .001 if $sleep > .0011 }
when 'K_UP' { $sleep -= .0501; $sleep = 0 if $sleep < 0 }
when 'K_DOWN' { $sleep += .0501 }
}
}
Line 1,559 ⟶ 1,560:
}
( $r, $g, $b ).map: ((*+$m) * 255).Int
}</lang>
}
</lang>
 
=={{header|Phix}}==
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.