Racer challenge map #9
authorunc0rr
Thu, 19 Jun 2014 15:29:31 +0400
changeset 10335 d56b4c109abb
parent 10334 872da9a6a2b0
child 10336 3edfa6b68407
Racer challenge map #9
misc/OfficialChallenges/racer_#9.hwmap
share/hedgewars/Data/Scripts/OfficialChallenges.lua
tools/hwmap.hs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/OfficialChallenges/racer_#9.hwmap	Thu Jun 19 15:29:31 2014 +0400
@@ -0,0 +1,1 @@
+AAAB1nicLY9bjsMgDEUNNjhp2syGg8TCQR0f6M+R7ftIqE2apGZNrHkTb6XJ+cTtfuJ2PXE7nrjZ/M5uU6ZUpsrkgV6YytTf6rOwLlRulUQiEWnbyFQ5lhA0IEJWqVISOXw9M6UNB2FJmL/EZMcy5oUlGIIhKH1KTIkVbgsVn/OnUfoa8ZjXiO8eTAeTB/rJdA79rT4K6wLPAsdIJIyWhUyVYwnhCshN9qLqIvEOX38zfTYchOWD+Y/YvWMZ88ISDMEQlD4lpsQKt4WKj2dR+g9qCctS
\ No newline at end of file
--- a/share/hedgewars/Data/Scripts/OfficialChallenges.lua	Thu Jun 19 00:36:11 2014 +0200
+++ b/share/hedgewars/Data/Scripts/OfficialChallenges.lua	Thu Jun 19 15:29:31 2014 +0400
@@ -12,6 +12,8 @@
                 return("Racer Challenge #7")
             elseif LandDigest == "M1902370941Scripts/Multiplayer/Racer.lua" then
                 return("Racer Challenge #8")
+            elseif LandDigest == "M185940363Scripts/Multiplayer/Racer.lua" then
+                return("Racer Challenge #9")
             end
 -- challenges without border
         elseif LandDigest == "M-134869715Scripts/Multiplayer/Racer.lua" then
--- a/tools/hwmap.hs	Thu Jun 19 00:36:11 2014 +0200
+++ b/tools/hwmap.hs	Thu Jun 19 15:29:31 2014 +0400
@@ -15,9 +15,25 @@
 data LineType = Solid | Erasing
     deriving Eq
 
-data Chunk = Line LineType Word8 [(Int16, Int16)]
+data Chunk = SpecialPoints [(Int16, Int16)]
+    | Line LineType Word8 [(Int16, Int16)]
+
+transform :: ((Int16, Int16) -> (Int16, Int16)) -> [Chunk] -> [Chunk]
+transform f = map tf
+    where
+    tf (SpecialPoints p) = SpecialPoints $ map f p
+    tf (Line t r p) = Line t r $ map f p
+    
+scale f = transform (\(a, b) -> (a * f, b * f))
+mirror = transform (\(a, b) -> (4095 - a, b))
+translate dx dy = transform (\(a, b) -> (a + dx, b + dy))
 
 instance Binary Chunk where
+    put (SpecialPoints p) = do
+        forM_ p $ \(x, y) -> do
+            put x
+            put y
+            putWord8 0
     put (Line lt r ((x1, y1):ps)) = do
         let flags = r .|. (if lt == Solid then 0 else (1 `shift` 6))
         put x1
@@ -35,10 +51,34 @@
     mapM_ putWord8 $ BW.unpack $ BL.toStrict $ Z.compress b
 
 mapString :: B.ByteString
-mapString = B.pack . Base64.encode . BW.unpack . BL.toStrict . compressWithLength . BL.drop 8 . encode $ drawnMap
+mapString = B.pack . Base64.encode . BW.unpack . BL.toStrict . compressWithLength . BL.drop 8 . encode $ drawnMap01
 
 main = B.writeFile "out.hwmap" mapString
 
-drawnMap = [
-        Line Solid 7 [(0, 0), (2048, 1024), (1024, 768)]
-    ]
+drawnMap01 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
+    where
+    sp = translate 128 128 . scale 256 $ [SpecialPoints [
+        (6, 0)
+        , (1, 4)
+        , (4, 7)
+        , (7, 5)
+        ]]
+    base = scale 256 $ [
+        l [(5, 0), (5, 1)]
+        , l [(7, 0), (7, 1)]
+        , l [(8, 1), (6, 1), (6, 4)]
+        , l [(8, 1), (8, 6), (6, 6), (6, 7), (8, 7)]
+        , l [(7, 2), (7, 5), (5, 5)]
+        , l [(5, 3), (5, 8)]
+        , l [(6, 2), (4, 2)]
+        , l [(1, 1), (4, 1), (4, 7)]
+        , l [(3, 5), (3, 7), (2, 7), (2, 8)]
+        , l [(2, 1), (2, 2)]
+        , l [(0, 2), (1, 2), (1, 3), (3, 3), (3, 2)]
+        , l [(0, 5), (1, 5)]
+        , l [(1, 4), (4, 4)]
+        , l [(2, 4), (2, 6), (1, 6), (1, 7)]
+        , l [(0, 8), (8, 8)]
+        ]
+    l = Line Solid 0
+    
\ No newline at end of file