Advertisement
Guest User

Untitled

a guest
Jul 21st, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 2.11 KB | None | 0 0
  1. type Tile =
  2.     S | Z | L | J | T | O | I
  3.     with
  4.         static member All = [S; Z; L; J; T; O; I]
  5.  
  6.         static member project tile rotation =
  7.             // Table built from: http://tetris.wikia.com/wiki/SRS
  8.             match tile with
  9.             | O ->
  10.                 match rotation with
  11.                 | Zero ->       [1,0; 2,0; 1,1; 2,1]
  12.                 | Ninety ->     [1,0; 2,0; 1,1; 2,1]
  13.                 | OneEighty ->  [1,0; 2,0; 1,1; 2,1]
  14.                 | TwoSeventy -> [1,0; 2,0; 1,1; 2,1]
  15.             | J ->
  16.                 match rotation with
  17.                 | Zero ->       [0,0; 0,1; 1,1; 2,1]
  18.                 | Ninety ->     [1,0; 2,0; 1,1; 1,2]
  19.                 | OneEighty ->  [0,1; 1,1; 2,1; 2,2]
  20.                 | TwoSeventy -> [1,0; 1,1; 0,2; 1,2]
  21.             | L ->
  22.                 match rotation with
  23.                 | Zero ->       [0,1; 1,1; 2,1; 2,0]
  24.                 | Ninety ->     [1,0; 1,1; 1,2; 2,2]
  25.                 | OneEighty ->  [0,1; 1,1; 2,1; 0,2]
  26.                 | TwoSeventy -> [0,0; 1,0; 1,1; 1,2]
  27.             | I ->
  28.                 match rotation with
  29.                 | Zero ->       [0,1; 1,1; 2,1; 3,1]
  30.                 | Ninety ->     [2,0; 2,1; 2,2; 2,3]
  31.                 | OneEighty ->  [0,2; 1,2; 2,2; 3,2]
  32.                 | TwoSeventy -> [1,0; 1,1; 1,2; 1,3]
  33.             | S ->
  34.                 match rotation with
  35.                 | Zero ->       [1,0; 2,0; 0,1; 1,1]
  36.                 | Ninety ->     [1,0; 1,1; 2,1; 2,2]
  37.                 | OneEighty ->  [1,1; 2,1; 0,2; 1,2]
  38.                 | TwoSeventy -> [0,0; 0,1; 1,1; 1,2]
  39.             | Z ->
  40.                 match rotation with
  41.                 | Zero ->       [0,0; 1,0; 1,1; 2,1]
  42.                 | Ninety ->     [2,0; 1,1; 2,1; 1,2]
  43.                 | OneEighty ->  [0,1; 1,1; 1,2; 2,2]
  44.                 | TwoSeventy -> [1,0; 0,1; 1,1; 0,2]
  45.             | T ->
  46.                 match rotation with
  47.                 | Zero ->       [1,0; 0,1; 1,1; 2,1]
  48.                 | Ninety ->     [1,0; 1,1; 2,1; 1,2]
  49.                 | OneEighty ->  [0,1; 1,1; 2,1; 1,2]
  50.                 | TwoSeventy -> [1,0; 0,1; 1,1; 1,2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement