Polyspiral: Difference between revisions
m
→SDL full animation: Made window resizeable, compensates for resized widows by centering the polyspiral in the window
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.) |
Thundergnat (talk | contribs) m (→SDL full animation: Made window resizeable, compensates for resized widows by centering the polyspiral in the window) |
||
Line 1,479:
<lang perl6>use SDL2::Raw;
my $width
my $height =
SDL_Init(VIDEO);
Line 1,489:
SDL_WINDOWPOS_CENTERED_MASK,
$width, $height,
);
Line 1,515:
main: loop {
$angle = ($angle + $dir * $step) % τ;▼
($x1, $y1) = $width div 2, $height div 2;▼
while SDL_PollEvent($event) {
my $casted_event = SDL_CastEvent($event);
Line 1,526 ⟶ 1,523:
given $comm {
when 'K_LEFT' { $dir = -1 }
when 'K_RIGHT' { $dir = 1 }
when 'K_UP' { $step += $incr }
when 'K_DOWN' {
when 'K_PGUP' { $step += $incr*50 }
when 'K_PGDN' { $step -= $incr*50; $step = $step < $incr ?? $incr !! $step }
when 'K_SPACE' { $step = $step ?? 0 !! $incr }
}
}
}
when *.type == WINDOWEVENT {
if .event == 5 {
$width = .data1;
$height = .data2;
}
}
Line 1,538 ⟶ 1,541:
}
▲ $angle = ($angle + $dir * $step) % τ;
▲ ($x1, $y1) = $width div 2, $height div 2;
for ^$lines {
my $length = 3 + 3 * $_;
|