Fix rendering issue
This commit is contained in:
parent
f3bce99120
commit
ef784c2dbc
9 changed files with 28 additions and 25 deletions
BIN
assets/entities/devil.png
Normal file
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
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
BIN
assets/items/sword.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 247 B |
|
@ -29,8 +29,8 @@ levels: [
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
id: "sword",
|
id: "sword",
|
||||||
x: 2,
|
x: 3,
|
||||||
y: 3,
|
y: 4,
|
||||||
name: "Zwaard",
|
name: "Zwaard",
|
||||||
description: "Meer schade tegen monsters",
|
description: "Meer schade tegen monsters",
|
||||||
useTimes: infinite,
|
useTimes: infinite,
|
||||||
|
@ -43,8 +43,8 @@ levels: [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "potion",
|
id: "potion",
|
||||||
x: 3,
|
x: 4,
|
||||||
y: 1,
|
y: 2,
|
||||||
name: "Levensbrouwsel",
|
name: "Levensbrouwsel",
|
||||||
description: "Geeft een aantal levenspunten terug",
|
description: "Geeft een aantal levenspunten terug",
|
||||||
useTimes: 1,
|
useTimes: 1,
|
||||||
|
@ -60,8 +60,8 @@ levels: [
|
||||||
entities: [
|
entities: [
|
||||||
{
|
{
|
||||||
id: "devil",
|
id: "devil",
|
||||||
x: 4,
|
x: 5,
|
||||||
y: 3,
|
y: 4,
|
||||||
name: "Duivel",
|
name: "Duivel",
|
||||||
description: "Een monster uit de hel",
|
description: "Een monster uit de hel",
|
||||||
hp: 50,
|
hp: 50,
|
||||||
|
|
|
@ -42,8 +42,8 @@ levels: [
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
id: "key",
|
id: "key",
|
||||||
x: 0,
|
x: 1,
|
||||||
y: 1,
|
y: 2,
|
||||||
name: "Sleutel",
|
name: "Sleutel",
|
||||||
description: "Deze sleutel kan een deur openen",
|
description: "Deze sleutel kan een deur openen",
|
||||||
useTimes: 1,
|
useTimes: 1,
|
||||||
|
@ -58,8 +58,8 @@ levels: [
|
||||||
entities: [
|
entities: [
|
||||||
{
|
{
|
||||||
id: "door",
|
id: "door",
|
||||||
x: 0,
|
x: 1,
|
||||||
y: 3,
|
y: 4,
|
||||||
name: "Deur",
|
name: "Deur",
|
||||||
description: "Deze deur kan geopend worden met een sleutel",
|
description: "Deze deur kan geopend worden met een sleutel",
|
||||||
direction: up,
|
direction: up,
|
||||||
|
@ -84,8 +84,8 @@ levels: [
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
id: "sword",
|
id: "sword",
|
||||||
x: 2,
|
x: 3,
|
||||||
y: 3,
|
y: 4,
|
||||||
name: "Zwaard",
|
name: "Zwaard",
|
||||||
description: "Meer schade tegen monsters",
|
description: "Meer schade tegen monsters",
|
||||||
useTimes: infinite,
|
useTimes: infinite,
|
||||||
|
@ -98,8 +98,8 @@ levels: [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "potion",
|
id: "potion",
|
||||||
x: 3,
|
x: 4,
|
||||||
y: 1,
|
y: 2,
|
||||||
name: "Levensbrouwsel",
|
name: "Levensbrouwsel",
|
||||||
description: "Geeft een aantal levenspunten terug",
|
description: "Geeft een aantal levenspunten terug",
|
||||||
useTimes: 1,
|
useTimes: 1,
|
||||||
|
@ -115,8 +115,8 @@ levels: [
|
||||||
entities: [
|
entities: [
|
||||||
{
|
{
|
||||||
id: "devil",
|
id: "devil",
|
||||||
x: 4,
|
x: 5,
|
||||||
y: 3,
|
y: 4,
|
||||||
name: "Duivel",
|
name: "Duivel",
|
||||||
description: "Een monster uit de hel",
|
description: "Een monster uit de hel",
|
||||||
hp: 50,
|
hp: 50,
|
||||||
|
|
|
@ -94,5 +94,5 @@ toggleInventoryShown shown g@Game{ state = s@Playing{ player = p }}= newGame
|
||||||
-- Map all Physicals onto coordinates
|
-- Map all Physicals onto coordinates
|
||||||
putCoords :: Level -> [(X, Y, Physical)]
|
putCoords :: Level -> [(X, Y, Physical)]
|
||||||
putCoords l@Level{ layout = lay } = concatMap (\(a, bs) -> map (\(b, c) -> (b, a, c)) bs) numberedList
|
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
|
numberedList = map (\(x, strip) -> (x, zip [0::Int ..] strip)) numberedStrips
|
|
@ -23,6 +23,7 @@ unknownImage = "unknown.png"
|
||||||
allEntities :: [(String, FilePath)]
|
allEntities :: [(String, FilePath)]
|
||||||
allEntities = [
|
allEntities = [
|
||||||
("player", "player.png"),
|
("player", "player.png"),
|
||||||
|
("devil", "devil.png" ),
|
||||||
("door", "door.png")
|
("door", "door.png")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -39,7 +40,9 @@ allEnvironment = [
|
||||||
allItems :: [(String, FilePath)]
|
allItems :: [(String, FilePath)]
|
||||||
allItems = [
|
allItems = [
|
||||||
("dagger", "dagger.png"),
|
("dagger", "dagger.png"),
|
||||||
("key", "key.png" )
|
("key", "key.png" ),
|
||||||
|
("potion", "potion.png"),
|
||||||
|
("sword", "sword.png" )
|
||||||
]
|
]
|
||||||
|
|
||||||
allGui :: [(String, FilePath)]
|
allGui :: [(String, FilePath)]
|
||||||
|
|
|
@ -48,7 +48,7 @@ renderLevel Level{ layout = l, items = i, entities = e } = level
|
||||||
entities = renderEntities e
|
entities = renderEntities e
|
||||||
|
|
||||||
renderLayout :: Layout -> Picture
|
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
|
where count = length strips - 1
|
||||||
|
|
||||||
renderStrip :: [Physical] -> Picture
|
renderStrip :: [Physical] -> Picture
|
||||||
|
|
|
@ -11,8 +11,8 @@ import RPGEngine.Parse.TextToStructure (gameFile)
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
describe "Game" $ do
|
describe "Game" $ do
|
||||||
-- TODO There is a weird bug that caused this to go in an infinite loop. Fix later.
|
it "Simple game" $ do
|
||||||
xit "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]"
|
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 {
|
correct = Game {
|
||||||
state = Playing {
|
state = Playing {
|
||||||
|
@ -37,9 +37,9 @@ spec = do
|
||||||
(Right struct) = parseWith gameFile input
|
(Right struct) = parseWith gameFile input
|
||||||
structureToGame struct `shouldBe` correct
|
structureToGame struct `shouldBe` correct
|
||||||
it "More complex game" $ do
|
it "More complex game" $ do
|
||||||
pendingWith "fix parsing first"
|
pendingWith "Still need to write this"
|
||||||
it "Game with multiple levels" $ do
|
it "Game with multiple levels" $ do
|
||||||
pendingWith "fix parsing first"
|
pendingWith "Still need to write this"
|
||||||
|
|
||||||
describe "Player" $ do
|
describe "Player" $ do
|
||||||
it "cannot die" $ do
|
it "cannot die" $ do
|
||||||
|
@ -144,7 +144,7 @@ spec = do
|
||||||
|
|
||||||
describe "Entities" $ do
|
describe "Entities" $ do
|
||||||
it "Simple entity" $ do
|
it "Simple entity" $ do
|
||||||
pendingWith "fix parsing first"
|
pendingWith "still need to write this"
|
||||||
|
|
||||||
describe "Level" $ do
|
describe "Level" $ do
|
||||||
it "Simple layout" $ do
|
it "Simple layout" $ do
|
||||||
|
|
Reference in a new issue