Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove whitespace [Gun.io WhitespaceBot]

  • Loading branch information...
commit b86f5a67004f627d00b6dbae3f657ec97a34ebce 1 parent e09b49b
Gun.io Whitespace Robot authored

Showing 2 changed files with 74 additions and 24 deletions. Show diff stats Hide diff stats

  1. +50 0 .gitignore
  2. +24 24 solitaire.pl
50 .gitignore
... ... @@ -0,0 +1,50 @@
  1 +# Compiled source #
  2 +###################
  3 +*.com
  4 +*.class
  5 +*.dll
  6 +*.exe
  7 +*.o
  8 +*.so
  9 +*.pyc
  10 +
  11 +# Numerous always-ignore extensions
  12 +###################
  13 +*.diff
  14 +*.err
  15 +*.orig
  16 +*.log
  17 +*.rej
  18 +*.swo
  19 +*.swp
  20 +*.vi
  21 +*~
  22 +
  23 +*.sass-cache
  24 +# Folders to ignore
  25 +###################
  26 +.hg
  27 +.svn
  28 +.CVS
  29 +# OS or Editor folders
  30 +###################
  31 +.DS_Store
  32 +Icon?
  33 +Thumbs.db
  34 +ehthumbs.db
  35 +nbproject
  36 +.cache
  37 +.project
  38 +.settings
  39 +.tmproj
  40 +*.esproj
  41 +*.sublime-project
  42 +*.sublime-workspace
  43 +# Dreamweaver added files
  44 +###################
  45 +_notes
  46 +dwsync.xml
  47 +# Komodo
  48 +###################
  49 +*.komodoproject
  50 +.komodotools
48 solitaire.pl
@@ -85,7 +85,7 @@ sub _handle_mouse_button_up
85 85 : $layers->by_position( $left_stack_hotspot[0] + $space_between_stacks[0] * $_, $left_stack_hotspot[1] );
86 86 my @stack = ($layer, @{$layer->ahead});
87 87 $layer = pop @stack if scalar @stack;
88   -
  88 +
89 89 if(defined $layer
90 90 && $layer->data->{id} =~ m/\d+/
91 91 && $layer->data->{visible}
@@ -102,10 +102,10 @@ sub _handle_mouse_button_up
102 102 my $square = sub { my $n = shift; return $n*$n; };
103 103
104 104 my $calc_dx = sub {
105   - return ( _x($target) - _x($layer) );
  105 + return ( _x($target) - _x($layer) );
106 106 };
107   - my $calc_dy = sub {
108   - return ( _y($target) - _y($layer) );
  107 + my $calc_dy = sub {
  108 + return ( _y($target) - _y($layer) );
109 109 };
110 110
111 111 my $calc_dist = sub {
@@ -121,7 +121,7 @@ sub _handle_mouse_button_up
121 121 my $step_y = $calc_dy->() / $steps;
122 122
123 123 while($dist > 40) {
124   -
  124 +
125 125 #$w += $layer->clip->w - $x;
126 126 #$h += $layer->clip->h - $y;
127 127 $layer->pos(
@@ -131,7 +131,7 @@ sub _handle_mouse_button_up
131 131 #SDL::Video::update_rect($display, $x, $y, $w, $h);
132 132 SDL::Video::update_rect($display, 0, 0, 0, 0);
133 133 $fps->delay;
134   -
  134 +
135 135 $dist = $calc_dist->();
136 136 }
137 137 $layer->detach_xy(_x($target), _y($target));
@@ -146,7 +146,7 @@ sub _handle_mouse_button_up
146 146 sub event_loop
147 147 {
148 148 my $handler = shift;
149   -
  149 +
150 150 SDL::Events::pump_events();
151 151 while(SDL::Events::poll_event($event))
152 152 {
@@ -183,7 +183,7 @@ sub event_loop
183 183 foreach my $bmp_fn (<Shot*\.bmp>)
184 184 {
185 185 if (my ($new_index) = $bmp_fn =~ /Shot(\d+)\.bmp/)
186   - {
  186 + {
187 187 if ($new_index >= $screen_shot_index)
188 188 {
189 189 $screen_shot_index = $new_index + 1;
@@ -222,13 +222,13 @@ sub game
222 222 if(scalar @selected_cards) {
223 223 my @selected_cards_ = ();
224 224 push(@selected_cards_, $_->foreground) for @selected_cards;
225   -
  225 +
226 226 my @stack = scalar @selected_cards_
227 227 ? @{$selected_cards[0]->behind}
228 228 : ();
229 229 my $dropped = 0;
230 230 my @position_before = ();
231   -
  231 +
232 232 if(scalar @stack) {
233 233 # to empty field
234 234 if($stack[0]->data->{id} =~ m/empty_stack/
@@ -236,14 +236,14 @@ sub game
236 236 @position_before = @{$layers->detach_xy($stack[0]->pos->x, $stack[0]->pos->y)};
237 237 $dropped = 1;
238 238 }
239   -
  239 +
240 240 # to face-up card
241 241 elsif($stack[0]->data->{visible}
242 242 && can_drop($selected_cards[0]->data->{id}, $stack[0]->data->{id})) {
243 243 @position_before = @{$layers->detach_xy($stack[0]->pos->x, $stack[0]->pos->y + $space_between_stacks[1])};
244 244 $dropped = 1;
245 245 }
246   -
  246 +
247 247 if($dropped && scalar @position_before) {
248 248 $position_before[0] += $hotspot_offset; # transparent border
249 249 $position_before[1] += $hotspot_offset;
@@ -258,7 +258,7 @@ sub game
258 258 on_click => sub {
259 259 unless(scalar @selected_cards) {
260 260 my $layer = $layers->by_position($event->button_x, $event->button_y);
261   -
  261 +
262 262 if(defined $layer) {
263 263 if($layer->data->{id} =~ m/^\d+$/) {
264 264 if($layer->data->{visible}) {
@@ -314,7 +314,7 @@ sub game
314 314 on_keydown => sub {
315 315 },
316 316 };
317   -
  317 +
318 318 while($loop) {
319 319 event_loop($handler);
320 320 @rects = @{$layers->blit($display)};
@@ -328,7 +328,7 @@ sub can_drop {
328 328 my $card_color = int($card / 13);
329 329 my $target = shift;
330 330 my $stack = $layers->by_position($left_target_hotspot[0] + $space_between_stacks[0] * $card_color, $left_target_hotspot[1]);
331   -
  331 +
332 332 #my @stack = $layers->get_layers_behind_layer($stack);
333 333 #my @stack = $layers->get_layers_ahead_layer($stack);
334 334
@@ -336,23 +336,23 @@ sub can_drop {
336 336 if (exists($KING_CARDS{$card})) {
337 337 return 1 if $target =~ m/empty_stack/;
338 338 }
339   -
  339 +
340 340 # Aces can be put on empty field (at upper right)
341 341 if('0,13,26,39' =~ m/\b\Q$card\E\b/ && $target =~ m/empty_target_\Q$card_color\E/) {
342 342 return 1;
343 343 }
344   -
  344 +
345 345 my $are_nums = _is_num($card) && _is_num($target);
346 346
347 347 if ($are_nums
348 348 && $card == $target + 1
349 349 && $target == $stack->data->{id}
350 350 && $stack->data->{visible}
351   - )
  351 + )
352 352 {
353 353 return 1;
354 354 }
355   -
  355 +
356 356 if($are_nums
357 357 && '12,25,38,51' !~ m/\b\Q$card\E\b/
358 358 && ($card + 14 == $target || $card + 40 == $target
@@ -361,7 +361,7 @@ sub can_drop {
361 361 {
362 362 return 1;
363 363 }
364   -
  364 +
365 365 return 0;
366 366 }
367 367
@@ -392,12 +392,12 @@ sub init_background {
392 392 $layers->add(SDLx::Layer->new(SDL::Image::load('data/background.png'), {id => 'background'}));
393 393 $layers->add(SDLx::Layer->new(SDL::Image::load('data/empty_stack.png'), @rewind_deck_1_position, {id => 'rewind_deck'}));
394 394 $layers->add(SDLx::Layer->new(SDL::Image::load('data/empty_stack.png'), @rewind_deck_2_position, {id => 'empty_deck'}));
395   -
  395 +
396 396 $layers->add(
397 397 SDLx::Layer->new(SDL::Image::load('data/empty_target_' . $_ . '.png'),
398 398 $left_target_position[0] + $space_between_stacks[0] * $_, $left_target_position[1],
399 399 {id => 'empty_target_' . $_})) for(0..3);
400   -
  400 +
401 401 $layers->add(
402 402 SDLx::Layer->new(SDL::Image::load('data/empty_stack.png'),
403 403 $left_stack_position[0] + $space_between_stacks[0] * $_, $left_stack_position[1],
@@ -413,7 +413,7 @@ sub init_cards {
413 413 my $image = 'data/card_back.png';
414 414 my $visible = 0;
415 415 my ($x, $y) = @rewind_deck_1_position;
416   -
  416 +
417 417 if($_ < 28)
418 418 {
419 419 if($stack_position > $stack_index)
@@ -430,7 +430,7 @@ sub init_cards {
430 430 $y = $left_stack_position[1] + $space_between_stacks[1] * $stack_position;
431 431 $stack_position++;
432 432 }
433   -
  433 +
434 434 $layers->add(SDLx::Layer->new(SDL::Image::load($image), $x, $y, {id => $card_value[$_], visible => $visible}));
435 435 }
436 436 }

0 comments on commit b86f5a6

Please sign in to comment.
Something went wrong with that request. Please try again.