From ef784c2dbc9babf8a113c2d90734c4eefaf9f50a Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Thu, 22 Dec 2022 23:06:59 +0100 Subject: [PATCH] Fix rendering issue --- assets/entities/devil.png | Bin 0 -> 1548 bytes assets/items/potion.png | Bin 0 -> 1548 bytes assets/items/sword.png | Bin 0 -> 247 bytes levels/level3.txt | 12 ++++++------ levels/level4.txt | 20 ++++++++++---------- lib/RPGEngine/Input/Playing.hs | 2 +- lib/RPGEngine/Render/Core.hs | 7 +++++-- lib/RPGEngine/Render/Playing.hs | 2 +- test/Parser/GameSpec.hs | 10 +++++----- 9 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 assets/entities/devil.png create mode 100644 assets/items/potion.png create mode 100644 assets/items/sword.png diff --git a/assets/entities/devil.png b/assets/entities/devil.png new file mode 100644 index 0000000000000000000000000000000000000000..1ab3ef5e835c0ab5e02a4d93a4f4271c14cef8c3 GIT binary patch literal 1548 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKU~I{Bb`J1#c2+1T%1_J8No8Qr zm{>c}+T(D5NZbEqUF*A=U0r01LezJ!=ty4cB&gLAwJ?-@^6Y&JJe?;!dZe*KOr}OB zOg3gtX=#Bd%R%;z#giv5>Yh@O7nC9Rxb^VgAMgM2KmR8#@G5m#q^zOCm41p% zm}P$9wNs(j=1ksiFy(Uiw4HvYT`Xc7Svrk^0$e#$Z**K*H#tes^?9NE|BlzwPb{6V zn#HY;HDrNf+205CAFQLb?M+{navg0vCw}~=1oN)4Mz^zt`}$><7c#NTZ`9uVbp4ga zoBo%wb#;qacygG?NMQuI$ga#rQ?o4*iNVU|?X8_H=O!u@GbwV0r%=sDcJSRaojj*~Wr2C#}BnA4J12 zKEqgWNv=4wjbZ9FsC0%K*hRPBK4U~z4;KL022%iH+s@dQTt zOdtkK1I)?DnnCg~gFtL_0QUk|5ztl`h_Lg5G2t}GU10c@Hc}+T(D5NZbEqUF*A=U0r01LezJ!=ty4cB&gLAwJ?-@^6Y&JJe?;!dZe*KOr}OB zOg3gtX=#Bd%R%;z#giv5>Yh@O7nC9Rxb^VgAMgM2KmR8#@G5m#q^zOCm41p% zm}P$9wNs(j=1ksiFy(Uiw4HvYT`Xc7Svrk^0$e#$Z**K*H#tes^?9NE|BlzwPb{6V zn#HY;HDrNf+205CAFQLb?M+{navg0vCw}~=1oN)4Mz^zt`}$><7c#NTZ`9uVbp4ga zoBo%wb#;qacygG?NMQuI$ga#rOrRI)6Uj%)r1R?djqeVj;*V!1De#P{ptYs=`wLK^UJWS#U{$G|q}O z21}m?K4JfYOxA}G%vk;8?65E?OR~FBFLKon;}ftOa+NW>#8y!YsRGxrvV@r z{1OlcW0-5O8G>N|%=vd;e}t=_ar8a|$PjD+iV_Csns?uN2R8)7$goxfdkr}(FkArB zfvy=O4hs{Q8W4@u0A*2rWHn&6w;1+hkKzT8N|-mW*@i7DF${ni0=5>7K=wPD)BtiT WC-|!PZafnXa)PI;pUXO@geCxxa~uZ% literal 0 HcmV?d00001 diff --git a/assets/items/sword.png b/assets/items/sword.png new file mode 100644 index 0000000000000000000000000000000000000000..ba6438963489b3d5e2cb53c187f28576e595b3c5 GIT binary patch literal 247 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!5&W+#}Etus}oQ2HYf(IiZ}nK}B_nFTJXTiq6$e zny_`7HbXCq;jx0s5QZ+67J(f+g6AH2$m=b5vvm3bW^hh?Ow?e7D|vdw7Zz&|M6ku6{1-oD!M [(X, Y, Physical)] putCoords l@Level{ layout = lay } = concatMap (\(a, bs) -> map (\(b, c) -> (b, a, c)) bs) numberedList - where numberedStrips = zip [0::Int .. ] lay + where numberedStrips = reverse $ zip [0::Int .. ] $ reverse lay numberedList = map (\(x, strip) -> (x, zip [0::Int ..] strip)) numberedStrips \ No newline at end of file diff --git a/lib/RPGEngine/Render/Core.hs b/lib/RPGEngine/Render/Core.hs index 0c6754c..b04c9fe 100644 --- a/lib/RPGEngine/Render/Core.hs +++ b/lib/RPGEngine/Render/Core.hs @@ -23,7 +23,8 @@ unknownImage = "unknown.png" allEntities :: [(String, FilePath)] allEntities = [ ("player", "player.png"), - ("door", "door.png") + ("devil", "devil.png" ), + ("door", "door.png") ] allEnvironment :: [(String, FilePath)] @@ -39,7 +40,9 @@ allEnvironment = [ allItems :: [(String, FilePath)] allItems = [ ("dagger", "dagger.png"), - ("key", "key.png" ) + ("key", "key.png" ), + ("potion", "potion.png"), + ("sword", "sword.png" ) ] allGui :: [(String, FilePath)] diff --git a/lib/RPGEngine/Render/Playing.hs b/lib/RPGEngine/Render/Playing.hs index 6a2f589..f902178 100644 --- a/lib/RPGEngine/Render/Playing.hs +++ b/lib/RPGEngine/Render/Playing.hs @@ -48,7 +48,7 @@ renderLevel Level{ layout = l, items = i, entities = e } = level entities = renderEntities e renderLayout :: Layout -> Picture -renderLayout strips = pictures [setRenderPos 0 y (renderStrip (strips !! y)) | y <- [0 .. count]] +renderLayout strips = pictures [setRenderPos 0 (count - y) (renderStrip (strips !! y)) | y <- [0 .. count]] where count = length strips - 1 renderStrip :: [Physical] -> Picture diff --git a/test/Parser/GameSpec.hs b/test/Parser/GameSpec.hs index b2b7371..c441a22 100644 --- a/test/Parser/GameSpec.hs +++ b/test/Parser/GameSpec.hs @@ -11,8 +11,8 @@ import RPGEngine.Parse.TextToStructure (gameFile) spec :: Spec spec = do describe "Game" $ do - -- TODO There is a weird bug that caused this to go in an infinite loop. Fix later. - xit "Simple game" $ do + it "Simple game" $ do + pendingWith "There is a weird bug that caused this to go in an infinite loop. Fix later." let input = "player: {\n hp: 50,\n inventory: []\n}\n\nlevels: [\n {\n layout: {\n | * * * * * *\n | * s . . e *\n | * * * * * *\n },\n \n items: [],\n\n entities: []\n\n\n }\n]" correct = Game { state = Playing { @@ -37,9 +37,9 @@ spec = do (Right struct) = parseWith gameFile input structureToGame struct `shouldBe` correct it "More complex game" $ do - pendingWith "fix parsing first" + pendingWith "Still need to write this" it "Game with multiple levels" $ do - pendingWith "fix parsing first" + pendingWith "Still need to write this" describe "Player" $ do it "cannot die" $ do @@ -144,7 +144,7 @@ spec = do describe "Entities" $ do it "Simple entity" $ do - pendingWith "fix parsing first" + pendingWith "still need to write this" describe "Level" $ do it "Simple layout" $ do