Fix rendering issue

This commit is contained in:
Tibo De Peuter 2022-12-22 23:06:59 +01:00
parent f3bce99120
commit ef784c2dbc
9 changed files with 28 additions and 25 deletions

BIN
assets/entities/devil.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
assets/items/potion.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
assets/items/sword.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

View file

@ -29,8 +29,8 @@ levels: [
items: [
{
id: "sword",
x: 2,
y: 3,
x: 3,
y: 4,
name: "Zwaard",
description: "Meer schade tegen monsters",
useTimes: infinite,
@ -43,8 +43,8 @@ levels: [
},
{
id: "potion",
x: 3,
y: 1,
x: 4,
y: 2,
name: "Levensbrouwsel",
description: "Geeft een aantal levenspunten terug",
useTimes: 1,
@ -60,8 +60,8 @@ levels: [
entities: [
{
id: "devil",
x: 4,
y: 3,
x: 5,
y: 4,
name: "Duivel",
description: "Een monster uit de hel",
hp: 50,

View file

@ -42,8 +42,8 @@ levels: [
items: [
{
id: "key",
x: 0,
y: 1,
x: 1,
y: 2,
name: "Sleutel",
description: "Deze sleutel kan een deur openen",
useTimes: 1,
@ -58,8 +58,8 @@ levels: [
entities: [
{
id: "door",
x: 0,
y: 3,
x: 1,
y: 4,
name: "Deur",
description: "Deze deur kan geopend worden met een sleutel",
direction: up,
@ -84,8 +84,8 @@ levels: [
items: [
{
id: "sword",
x: 2,
y: 3,
x: 3,
y: 4,
name: "Zwaard",
description: "Meer schade tegen monsters",
useTimes: infinite,
@ -98,8 +98,8 @@ levels: [
},
{
id: "potion",
x: 3,
y: 1,
x: 4,
y: 2,
name: "Levensbrouwsel",
description: "Geeft een aantal levenspunten terug",
useTimes: 1,
@ -115,8 +115,8 @@ levels: [
entities: [
{
id: "devil",
x: 4,
y: 3,
x: 5,
y: 4,
name: "Duivel",
description: "Een monster uit de hel",
hp: 50,

View file

@ -94,5 +94,5 @@ toggleInventoryShown shown g@Game{ state = s@Playing{ player = p }}= newGame
-- Map all Physicals onto coordinates
putCoords :: Level -> [(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

View file

@ -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)]

View file

@ -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

View file

@ -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