diff --git a/assets/levels/openquell.ldtk b/assets/levels/openquell.ldtk index 7c4316c..5a47f7c 100644 --- a/assets/levels/openquell.ldtk +++ b/assets/levels/openquell.ldtk @@ -1397,46 +1397,6 @@ "allowedRefTags": [], "tilesetUid": null }, - { - "identifier": "background", - "doc": null, - "__type": "String", - "uid": 13, - "type": "F_String", - "isArray": false, - "canBeNull": true, - "arrayMinLength": null, - "arrayMaxLength": null, - "editorDisplayMode": "Hidden", - "editorDisplayScale": 1, - "editorDisplayPos": "Above", - "editorLinkStyle": "StraightArrow", - "editorDisplayColor": null, - "editorAlwaysShow": false, - "editorShowInWorld": true, - "editorCutLongValues": true, - "editorTextSuffix": null, - "editorTextPrefix": null, - "useForSmartColor": false, - "exportToToc": false, - "searchable": false, - "min": null, - "max": null, - "regex": null, - "acceptFileTypes": null, - "defaultOverride": { - "id": "V_String", - "params": ["background1"] - }, - "textLanguageMode": null, - "symmetricalRef": false, - "autoChainRef": true, - "allowOutOfLevelRef": true, - "allowedRefs": "OnlySame", - "allowedRefsEntityUid": null, - "allowedRefTags": [], - "tilesetUid": null - }, { "identifier": "minmoves", "doc": null, @@ -1488,7 +1448,7 @@ "__bgColor": "#696A79", "bgColor": null, "useAutoIdentifier": false, - "bgRelPath": "../sprites/background1.png", + "bgRelPath": "../sprites/background4.png", "bgPos": "Cover", "bgPivotX": 0.5, "bgPivotY": 0.5, @@ -1501,7 +1461,6 @@ "id": "V_String", "params": ["Collect the yellow items"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 7, "__tile": null, "defUid": 14, "realEditorValues": [] } ], "layerInstances": [ @@ -1710,7 +1669,6 @@ "id": "V_String", "params": ["you can fly to the other side"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 6, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [6] }] } ], "layerInstances": [ @@ -1888,10 +1846,6 @@ "id": "V_String", "params": ["Take care and don't miss the walls"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [{ - "id": "V_String", - "params": ["background1"] - }] }, { "__identifier": "minmoves", "__type": "Int", "__value": 5, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [5] }] } ], "layerInstances": [ @@ -2015,7 +1969,6 @@ "id": "V_String", "params": ["Can you find your way out?"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 19, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [19] }] } ], "layerInstances": [ @@ -2186,7 +2139,6 @@ "id": "V_String", "params": ["Beware of the spikes, they are deadly!"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 5, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [5] }] } ], "layerInstances": [ @@ -2425,7 +2377,6 @@ "id": "V_String", "params": ["You can push the enemies around"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 5, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [5] }] } ], "layerInstances": [ @@ -2649,7 +2600,6 @@ "id": "V_String", "params": ["Stay alive, please!"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 8, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [8] }] } ], "layerInstances": [ @@ -2897,7 +2847,6 @@ "id": "V_String", "params": ["Once Again!"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 11, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [11] }] } ], "layerInstances": [ @@ -3182,7 +3131,6 @@ "id": "V_String", "params": ["Some things don't are as they appear"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 10, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [10] }] } ], "layerInstances": [ @@ -3398,7 +3346,6 @@ "id": "V_String", "params": ["How many secret doors are there?"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 10, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [10] }] } ], "layerInstances": [ @@ -3670,7 +3617,6 @@ "id": "V_String", "params": ["Somethimes there are multiple ways out"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 24, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [24] }] } ], "layerInstances": [ @@ -4014,7 +3960,6 @@ "id": "V_String", "params": ["Be careful"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 6, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [6] }] } ], "layerInstances": [ @@ -4198,7 +4143,6 @@ "id": "V_String", "params": ["Transients can only be passed once!"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 12, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [12] }] } ], "layerInstances": [ @@ -4450,7 +4394,6 @@ "id": "V_String", "params": ["You can do it!"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 12, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [12] }] } ], "layerInstances": [ @@ -4731,7 +4674,6 @@ "fieldInstances": [ { "__identifier": "level", "__type": "Int", "__value": 15, "__tile": null, "defUid": 11, "realEditorValues": [{ "id": "V_Int", "params": [15] }] }, { "__identifier": "description", "__type": "String", "__value": "", "__tile": null, "defUid": 12, "realEditorValues": [] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 23, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [23] }] } ], "layerInstances": [ @@ -5032,7 +4974,6 @@ "fieldInstances": [ { "__identifier": "level", "__type": "Int", "__value": 16, "__tile": null, "defUid": 11, "realEditorValues": [{ "id": "V_Int", "params": [16] }] }, { "__identifier": "description", "__type": "String", "__value": "", "__tile": null, "defUid": 12, "realEditorValues": [] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 5, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [5] }] } ], "layerInstances": [ @@ -5279,7 +5220,6 @@ "id": "V_String", "params": ["Use TAB to switch players"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 5, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [5] }] } ], "layerInstances": [ @@ -5491,7 +5431,6 @@ "id": "V_String", "params": ["Necessary is the sacrifice"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 3, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [3] }] } ], "layerInstances": [ @@ -5821,7 +5760,6 @@ "id": "V_String", "params": ["Invisible chains can bind you"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 10, "__tile": null, "defUid": 14, "realEditorValues": [{ "id": "V_Int", "params": [10] }] } ], "layerInstances": [ @@ -6031,7 +5969,6 @@ "id": "V_String", "params": ["Take care of each other"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 7, "__tile": null, "defUid": 14, "realEditorValues": [] } ], "layerInstances": [ @@ -6267,7 +6204,6 @@ "id": "V_String", "params": ["Use the switch to open the door"] }] }, - { "__identifier": "background", "__type": "String", "__value": "background1", "__tile": null, "defUid": 13, "realEditorValues": [] }, { "__identifier": "minmoves", "__type": "Int", "__value": 7, "__tile": null, "defUid": 14, "realEditorValues": [] } ], "layerInstances": [ diff --git a/assets/loader-levels.go b/assets/loader-levels.go index a654894..ba97dbd 100644 --- a/assets/loader-levels.go +++ b/assets/loader-levels.go @@ -254,7 +254,7 @@ func LoadLDTK(dir string) *ldtkgo.Project { } // do some sanity checks - properties := []string{"minmoves", "background", "level", "description"} + properties := []string{"minmoves", "level", "description"} need := len(properties) for idx, level := range project.Levels { diff --git a/game/levels.go b/game/levels.go index d6e7bdb..a43c87b 100644 --- a/game/levels.go +++ b/game/levels.go @@ -38,10 +38,9 @@ func NewLevel(game *Game, cellsize int, plan *ldtkgo.Level) *Level { gridcontainer := &grid.GridContainer{} - // FIXME: use plan.BGImage.Path here? systemlist = append(systemlist, systems.NewGridSystem(game.World, game.ScreenWidth, game.ScreenHeight, cellsize, - assets.Assets[plan.PropertyByIdentifier("background").AsString()])) + assets.Assets[util.GetBGImage(plan)])) systemlist = append(systemlist, systems.NewCollectibleSystem(game.World, cellsize)) diff --git a/util/ldtkhelpers.go b/util/ldtkhelpers.go index d3a1931..2b92e94 100644 --- a/util/ldtkhelpers.go +++ b/util/ldtkhelpers.go @@ -2,6 +2,8 @@ package util import ( "openquell/config" + "path/filepath" + "strings" "github.com/solarlune/ldtkgo" ) @@ -71,3 +73,7 @@ func GetPropertyToggleTile(entity *ldtkgo.Entity) *TileSetSubRect { return nil } + +func GetBGImage(plan *ldtkgo.Level) string { + return filepath.Base(strings.TrimSuffix(plan.BGImage.Path, ".png")) +}