module TypesConstants where import Graphics.Gloss.Data.Color (Color, makeColorI) import System.Random (StdGen) type Pos = (Float, Float) data Direction = U | R | D | L deriving (Eq, Show, Bounded, Read) --represents a 90 degree turn to the right turn :: Direction -> Direction turn U = R turn R = D turn D = L turn L = U --represents a 90 degree turn to the left turnLeft :: Direction -> Direction turnLeft U = L turnLeft R = U turnLeft D = R turnLeft L = D --stores the current states of the gameBoard, some only used in automatic mode data Board = Board { res :: (Int, Int), size :: (Int, Int), snake :: [Pos], food :: Pos, dir :: Direction, gameOver :: Bool, r :: StdGen, currentFood :: String, tumFoods :: [(String, Pos)], started :: Bool, automatic :: Bool } deriving (Show) --haskell operators working as food for the python allOps :: [String] allOps = [">>>", "***", "&&&", "^>>", ">>^", "<<<", "<<^", "^<<", "<+>", "+++", "++", "\\", "|||", "<*>", "<*>", "<*", "*>", "<|>", "<$>", "<$", "<**>", ">>=", ">>", "=<<", ">=>", "<=<", "<$!>", "(.)", "$", "<>"] {-for drawing the Haskell logo background image the gloss polygon function only draws convex polygons but the haskell logo is a concave polygon, so i split it into multiple convex polygons-} leftPartUpper :: [Pos] leftPartUpper = [(-135.0, 0.0), (-256.0, 179.0), (-166.0, 179.0), (-45.0, 0.0)] leftPartLower :: [Pos] leftPartLower = [(-256.0, -179.0), (-135.0, 0.0), (-45.0, 0.0), (-166.0, -179.0)] middlePartBig :: [Pos] middlePartBig = [(106, -179.0), (-136.0, 179.0), (-46.0, 179.0), (196.0, -179.0)] middlePartSmall :: [Pos] middlePartSmall = [(-136.0, -179.0), (-15.0, 0.0), (75.0, 0.0), (-45.0, -179.0)] rightPartUpper :: [Pos] rightPartUpper = [(256.0, 76.0), (56.0, 76.0), (96.0, 16.0), (256.0, 16.0)] rightPartLower :: [Pos] rightPartLower = [(256.0, -14.0), (116.0, -14.0), (156.0, -74.0), (256.0, -74.0)] --the colors for the haskell logo lilaDark :: Color lilaDark = makeColorI 69 58 98 255 lilaLight :: Color lilaLight = makeColorI 93 80 134 255 pinkBright :: Color pinkBright = makeColorI 143 78 139 255 tumBlue :: Color tumBlue = makeColorI 0 101 189 255 {- just for the video if i had more time I'd try to create more images or maybe even try to let the user create images -} rightTurnSpots :: [Pos] rightTurnSpots = [(-12.0, 4.0), (-12.0, 5.0), (-9.0, 5.0), (-8.0, 5.0), (-3.0, 5.0), (1.0, 5.0), (12.0, 5.0), (12.0, -7.0), (11.0, -7.0), (7.0, -7.0), (6.0, -7.0), (2.0, -7.0), (-4.0, -7.0)] leftTurnSpots :: [Pos] leftTurnSpots = [(-9.0, -7.0), (-8.0, -7.0), (-3.0, -6.0), (1.0, -6.0), (11.0, 4.0), (7.0, 4.0), (6.0, 4.0), (2.0, 4.0), (-4.0, 4.0)] -- didn't want to use this originally, but now is used for generating the random foods in automatic mode foodPositionsTUM2 :: [Pos] foodPositionsTUM2 = [(-10.0, 4.0), (-11.0, 4.0), (-12.0, 4.0), (-12.0, 5.0), (-11.0, 5.0), (-10.0, 5.0), (-9.0, 5.0), (-9.0, 4.0), (-9.0, 3.0), (-9.0, 2.0), (-9.0, 1.0), (-9.0, 0.0), (-9.0, -1.0), (-9.0, -2.0), (-9.0, -3.0), (-9.0, -4.0), (-9.0, -5.0), (-9.0, -6.0), (-9.0, -7.0), (-8.0, -7.0), (-8.0, -6.0), (-8.0, -5.0), (-8.0, -4.0), (-8.0, -3.0), (-8.0, -2.0), (-8.0, -1.0), (-8.0, 0.0), (-8.0, 1.0), (-8.0, 2.0), (-8.0, 3.0), (-8.0, 4.0), (-8.0, 5.0), (-7.0, 5.0), (-6.0, 5.0), (-5.0, 5.0), (-4.0, 5.0), (-3.0, 5.0), (-3.0, 4.0), (-3.0, 3.0), (-3.0, 2.0), (-3.0, 1.0), (-3.0, 0.0), (-3.0, -1.0), (-3.0, -2.0), (-3.0, -3.0), (-3.0, -4.0), (-3.0, -5.0), (-3.0, -6.0), (-2.0, -6.0), (-1.0, -6.0), (0.0, -6.0), (1.0, -6.0), (1.0, -5.0), (1.0, -4.0), (1.0, -3.0), (1.0, -2.0), (1.0, -1.0), (1.0, 0.0), (1.0, 1.0), (1.0, 2.0), (1.0, 2.0), (1.0, 3.0), (1.0, 3.0), (1.0, 4.0), (1.0, 5.0), (2.0, 5.0), (3.0, 5.0), (4.0, 5.0), (5.0, 5.0), (6.0, 5.0), (7.0, 5.0), (8.0, 5.0), (9.0, 5.0), (10.0, 5.0), (11.0, 5.0), (12.0, 5.0), (12.0, 4.0), (12.0, 3.0), (12.0, 2.0), (12.0, 1.0), (12.0, 0.0), (12.0, -1.0), (12.0, -2.0), (12.0, -3.0), (12.0, -4.0), (12.0, -5.0), (12.0, -6.0), (12.0, -7.0), (11.0, -7.0), (11.0, -6.0), (11.0, -5.0), (11.0, -4.0), (11.0, -3.0), (11.0, -2.0), (11.0, -1.0), (11.0, 0.0), (11.0, 1.0), (11.0, 2.0), (11.0, 3.0), (11.0, 4.0), (10.0, 4.0), (9.0, 4.0), (8.0, 4.0), (7.0, 4.0), (7.0, 3.0), (7.0, 2.0), (7.0, 1.0), (7.0, 0.0), (7.0, -1.0), (7.0, -2.0), (7.0, -3.0), (7.0, -4.0), (7.0, -5.0), (7.0, -6.0), (7.0, -7.0), (6.0, -7.0), (6.0, -6.0), (6.0, -5.0), (6.0, -4.0), (6.0, -3.0), (6.0, -2.0), (6.0, -1.0), (6.0, 0.0), (6.0, 1.0), (6.0, 2.0), (6.0, 3.0), (6.0, 4.0), (5.0, 4.0), (4.0, 4.0), (3.0, 4.0), (2.0, 4.0), (2.0, 3.0), (2.0, 2.0), (2.0, 1.0), (2.0, 0.0), (2.0, -1.0), (2.0, -2.0), (2.0, -3.0), (2.0, -4.0), (2.0, -5.0), (2.0, -6.0), (2.0, -7.0), (1.0, -7.0), (0.0, -7.0), (-1.0, -7.0), (-2.0, -7.0), (-3.0, -7.0), (-4.0, -7.0), (-4.0, -7.0), (-4.0, -6.0), (-4.0, -5.0), (-4.0, -4.0), (-4.0, -3.0), (-4.0, -2.0), (-4.0, -1.0), (-4.0, 0.0), (-4.0, 1.0), (-4.0, 2.0), (-4.0, 3.0), (-4.0, 4.0), (-5.0, 4.0), (-6.0, 4.0), (-7.0, 4.0)]