Changes:
- use toggle tile for all toggling entities (transient, switch, door) - get rod of hard coded sprites (exception: particle class, to be fixed later) - changed switch sprite (rect instead of elipse)
This commit is contained in:
parent
f6f2172f11
commit
faf0fd99c2
@ -1,18 +0,0 @@
|
||||
Description: open the door
|
||||
MinMoves: 2
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
#######
|
||||
#o #
|
||||
# t #
|
||||
#> S <#
|
||||
# #
|
||||
# ^ #
|
||||
#######
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
Description: test obstacles
|
||||
MinMoves: 14
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
#############
|
||||
# t #
|
||||
#> S # #
|
||||
# ># ^#
|
||||
#< #W#####
|
||||
# o v# o#
|
||||
#############
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
Description: collect all yellow dots
|
||||
MinMoves: 7
|
||||
Background: background-lila
|
||||
|
||||
|
||||
# ############
|
||||
# #
|
||||
############ #
|
||||
# o S #
|
||||
# ######## ###
|
||||
+ #
|
||||
############ #
|
||||
# o # #
|
||||
# # ######## #
|
||||
# # o
|
||||
# ############
|
||||
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
Description: some enemies can be moved
|
||||
MinMoves: 5
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
|
||||
########
|
||||
# o <o#
|
||||
#v S # #
|
||||
# #### #
|
||||
|
||||
|
||||
# #### #
|
||||
# #
|
||||
# ^#
|
||||
########
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
Description: the more players the better
|
||||
MinMoves: 4
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
|
||||
########W#
|
||||
# v#
|
||||
# #
|
||||
#S s#
|
||||
############
|
||||
# o #
|
||||
######## #
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
Description: don't fall off the world
|
||||
MinMoves: 3
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
|
||||
W
|
||||
|
||||
|
||||
S # o
|
||||
|
||||
|
||||
|
||||
|
||||
o
|
||||
#
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
width=$(grep "width " ../../main.go | awk '{print $4}')
|
||||
height=$(grep "height " ../../main.go | awk '{print $4}')
|
||||
|
||||
read -p " Enter level name: " name
|
||||
read -p " Enter background: " background
|
||||
read -p "Enter description: " des
|
||||
|
||||
if test -z "$name"; then
|
||||
name="newlevel"
|
||||
fi
|
||||
|
||||
if test -z "$bbackground"; then
|
||||
background="background-lila"
|
||||
fi
|
||||
|
||||
w=$(($width/32))
|
||||
h=$(($height/32))
|
||||
|
||||
(
|
||||
echo "Description: $des"
|
||||
echo "Background: $background"
|
||||
|
||||
for x in $(seq 1 $h); do
|
||||
for y in $(seq 1 $w); do
|
||||
echo -n " "
|
||||
done
|
||||
echo
|
||||
done
|
||||
)
|
||||
@ -11,7 +11,7 @@
|
||||
"iid": "267e9380-d7b0-11ee-a97e-35bec9c19d52",
|
||||
"jsonVersion": "1.5.3",
|
||||
"appBuildId": 473703,
|
||||
"nextUid": 70,
|
||||
"nextUid": 76,
|
||||
"identifierStyle": "Capitalize",
|
||||
"toc": [],
|
||||
"worldLayout": "Free",
|
||||
@ -425,7 +425,48 @@
|
||||
"limitBehavior": "MoveLastOne",
|
||||
"pivotX": 0,
|
||||
"pivotY": 0,
|
||||
"fieldDefs": []
|
||||
"fieldDefs": [
|
||||
{
|
||||
"identifier": "Toggle",
|
||||
"doc": null,
|
||||
"__type": "Tile",
|
||||
"uid": 75,
|
||||
"type": "F_Tile",
|
||||
"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": ["64,128,32,32"]
|
||||
},
|
||||
"textLanguageMode": null,
|
||||
"symmetricalRef": false,
|
||||
"autoChainRef": true,
|
||||
"allowOutOfLevelRef": true,
|
||||
"allowedRefs": "OnlySame",
|
||||
"allowedRefsEntityUid": null,
|
||||
"allowedRefTags": [],
|
||||
"tilesetUid": 57
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"identifier": "Switch",
|
||||
@ -468,7 +509,7 @@
|
||||
"uid": 69,
|
||||
"type": "F_EntityRef",
|
||||
"isArray": false,
|
||||
"canBeNull": true,
|
||||
"canBeNull": false,
|
||||
"arrayMinLength": null,
|
||||
"arrayMaxLength": null,
|
||||
"editorDisplayMode": "RefLinkBetweenCenters",
|
||||
@ -497,6 +538,46 @@
|
||||
"allowedRefsEntityUid": 65,
|
||||
"allowedRefTags": [],
|
||||
"tilesetUid": null
|
||||
},
|
||||
{
|
||||
"identifier": "Toggle",
|
||||
"doc": null,
|
||||
"__type": "Tile",
|
||||
"uid": 74,
|
||||
"type": "F_Tile",
|
||||
"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": ["96,192,32,32"]
|
||||
},
|
||||
"textLanguageMode": null,
|
||||
"symmetricalRef": false,
|
||||
"autoChainRef": true,
|
||||
"allowOutOfLevelRef": true,
|
||||
"allowedRefs": "OnlySame",
|
||||
"allowedRefsEntityUid": null,
|
||||
"allowedRefTags": [],
|
||||
"tilesetUid": 57
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -570,6 +651,46 @@
|
||||
"allowedRefsEntityUid": 66,
|
||||
"allowedRefTags": [],
|
||||
"tilesetUid": null
|
||||
},
|
||||
{
|
||||
"identifier": "Toggle",
|
||||
"doc": null,
|
||||
"__type": "Tile",
|
||||
"uid": 71,
|
||||
"type": "F_Tile",
|
||||
"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": ["64,192,32,32"]
|
||||
},
|
||||
"textLanguageMode": null,
|
||||
"symmetricalRef": false,
|
||||
"autoChainRef": true,
|
||||
"allowOutOfLevelRef": true,
|
||||
"allowedRefs": "OnlySame",
|
||||
"allowedRefsEntityUid": null,
|
||||
"allowedRefTags": [],
|
||||
"tilesetUid": 57
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1053,13 +1174,13 @@
|
||||
},
|
||||
{
|
||||
"__cWid": 4,
|
||||
"__cHei": 6,
|
||||
"__cHei": 7,
|
||||
"identifier": "Entitymap",
|
||||
"uid": 57,
|
||||
"relPath": "../sprites/entitymap.png",
|
||||
"embedAtlas": null,
|
||||
"pxWid": 128,
|
||||
"pxHei": 192,
|
||||
"pxHei": 224,
|
||||
"tileGridSize": 32,
|
||||
"spacing": 0,
|
||||
"padding": 0,
|
||||
@ -1069,8 +1190,8 @@
|
||||
"customData": [],
|
||||
"savedSelections": [],
|
||||
"cachedPixelData": {
|
||||
"opaqueTiles": "000000000111111111111100",
|
||||
"averageColors": "1b47987d687d3b355c355c355c355c353c96faa8f166f299f5b7f853f799f777f222f888f444f765f555f53200000000"
|
||||
"opaqueTiles": "0000000001111111111111000000",
|
||||
"averageColors": "1b47987d687d3b355c355c355c355c353c96faa8f166f299f5b7f853f799f777f222f888f444f765f555f532e866ab85000000003743aa95"
|
||||
}
|
||||
}
|
||||
], "enums": [], "externalEnums": [], "levelFields": [
|
||||
@ -3960,7 +4081,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [192,224],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": -32,
|
||||
"__worldY": 1856
|
||||
},
|
||||
@ -3976,7 +4097,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [320,320],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 96,
|
||||
"__worldY": 1952
|
||||
},
|
||||
@ -4040,7 +4161,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [416,224],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 192,
|
||||
"__worldY": 1856
|
||||
}
|
||||
@ -4200,7 +4321,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [192,224],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 672,
|
||||
"__worldY": 1856
|
||||
},
|
||||
@ -4280,7 +4401,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [192,96],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 672,
|
||||
"__worldY": 1728
|
||||
},
|
||||
@ -4486,7 +4607,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [64,224],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 1248,
|
||||
"__worldY": 1856
|
||||
},
|
||||
@ -4518,7 +4639,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [128,160],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 1312,
|
||||
"__worldY": 1792
|
||||
},
|
||||
@ -4841,7 +4962,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [416,96],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 2304,
|
||||
"__worldY": 1728
|
||||
},
|
||||
@ -4857,7 +4978,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [416,352],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 2304,
|
||||
"__worldY": 1984
|
||||
},
|
||||
@ -4905,7 +5026,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [288,128],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 2176,
|
||||
"__worldY": 1760
|
||||
},
|
||||
@ -4921,7 +5042,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [192,256],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 2080,
|
||||
"__worldY": 1888
|
||||
},
|
||||
@ -4937,7 +5058,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [480,288],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 2368,
|
||||
"__worldY": 1920
|
||||
},
|
||||
@ -4953,7 +5074,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [480,64],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 2368,
|
||||
"__worldY": 1696
|
||||
},
|
||||
@ -4969,7 +5090,7 @@
|
||||
"height": 32,
|
||||
"defUid": 24,
|
||||
"px": [512,128],
|
||||
"fieldInstances": [],
|
||||
"fieldInstances": [{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 128, "w": 32, "h": 32 }, "__tile": null, "defUid": 75, "realEditorValues": [] }],
|
||||
"__worldX": 2400,
|
||||
"__worldY": 1760
|
||||
},
|
||||
@ -6072,15 +6193,18 @@
|
||||
"height": 32,
|
||||
"defUid": 66,
|
||||
"px": [352,160],
|
||||
"fieldInstances": [{ "__identifier": "Entity_ref", "__type": "EntityRef", "__value": {
|
||||
"entityIid": "81e502b0-d7b0-11ee-9add-6193c766edeb",
|
||||
"layerIid": "50624190-d7b0-11ee-968e-3dbcbdc42f40",
|
||||
"levelIid": "50621a80-d7b0-11ee-968e-a98c2d35fbdb",
|
||||
"worldIid": "267ee1a0-d7b0-11ee-a97e-53f0a359eae1"
|
||||
}, "__tile": null, "defUid": 69, "realEditorValues": [{
|
||||
"id": "V_String",
|
||||
"params": ["81e502b0-d7b0-11ee-9add-6193c766edeb"]
|
||||
}] }],
|
||||
"fieldInstances": [
|
||||
{ "__identifier": "Entity_ref", "__type": "EntityRef", "__value": {
|
||||
"entityIid": "81e502b0-d7b0-11ee-9add-6193c766edeb",
|
||||
"layerIid": "50624190-d7b0-11ee-968e-3dbcbdc42f40",
|
||||
"levelIid": "50621a80-d7b0-11ee-968e-a98c2d35fbdb",
|
||||
"worldIid": "267ee1a0-d7b0-11ee-a97e-53f0a359eae1"
|
||||
}, "__tile": null, "defUid": 69, "realEditorValues": [{
|
||||
"id": "V_String",
|
||||
"params": ["81e502b0-d7b0-11ee-9add-6193c766edeb"]
|
||||
}] },
|
||||
{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 96, "y": 192, "w": 32, "h": 32 }, "__tile": null, "defUid": 74, "realEditorValues": [] }
|
||||
],
|
||||
"__worldX": 128,
|
||||
"__worldY": 2912
|
||||
},
|
||||
@ -6096,15 +6220,10 @@
|
||||
"height": 32,
|
||||
"defUid": 65,
|
||||
"px": [224,224],
|
||||
"fieldInstances": [{ "__identifier": "Entity_ref", "__type": "EntityRef", "__value": {
|
||||
"entityIid": "7d975370-d7b0-11ee-9add-971995295000",
|
||||
"layerIid": "50624190-d7b0-11ee-968e-3dbcbdc42f40",
|
||||
"levelIid": "50621a80-d7b0-11ee-968e-a98c2d35fbdb",
|
||||
"worldIid": "267ee1a0-d7b0-11ee-a97e-53f0a359eae1"
|
||||
}, "__tile": null, "defUid": 68, "realEditorValues": [{
|
||||
"id": "V_String",
|
||||
"params": ["7d975370-d7b0-11ee-9add-971995295000"]
|
||||
}] }],
|
||||
"fieldInstances": [
|
||||
{ "__identifier": "Entity_ref", "__type": "EntityRef", "__value": null, "__tile": null, "defUid": 68, "realEditorValues": [null] },
|
||||
{ "__identifier": "Toggle", "__type": "Tile", "__value": { "tilesetUid": 57, "x": 64, "y": 192, "w": 32, "h": 32 }, "__tile": null, "defUid": 71, "realEditorValues": [] }
|
||||
],
|
||||
"__worldX": 0,
|
||||
"__worldY": 2976
|
||||
},
|
||||
|
||||
@ -17,53 +17,53 @@ var Tiles = InitTiles()
|
||||
// Tile: contains image, identifier (as used in level data) and
|
||||
// additional properties
|
||||
type Tile struct {
|
||||
Id, Ref string
|
||||
Sprite *ebiten.Image
|
||||
Class string
|
||||
Solid bool // wall brick
|
||||
Player bool // player sphere
|
||||
IsPrimary bool // primary player sphere
|
||||
Renderable bool // visible, has sprite
|
||||
Velocity bool // movable
|
||||
Collectible bool // collectible, vanishes once collected
|
||||
Transient bool // turns into brick wall when traversed
|
||||
Destroyable bool // turns into empty floor when bumped into twice
|
||||
Particle int // -1=unused, 0-3 = show image of slice
|
||||
Tiles []*ebiten.Image // has N sprites
|
||||
TileNames []string // same thing, only the names
|
||||
Obstacle bool // is an obstacle/enemy
|
||||
Direction int // obstacle business end shows into this direction
|
||||
Shader *ebiten.Shader
|
||||
Alpha *ebiten.Image
|
||||
Bond bool // denotes an entity which can have a relation to another
|
||||
Door bool // a door, can be manipulated by a switch
|
||||
Switch bool // opens|closes a door
|
||||
Id, Ref string
|
||||
Sprite *ebiten.Image
|
||||
ToggleSprite *ebiten.Image
|
||||
Solid bool // wall brick
|
||||
Player bool // player sphere
|
||||
IsPrimary bool // primary player sphere
|
||||
Renderable bool // visible, has sprite
|
||||
Velocity bool // movable
|
||||
Collectible bool // collectible, vanishes once collected
|
||||
Transient bool // turns into brick wall when traversed
|
||||
Destroyable bool // turns into empty floor when bumped into twice
|
||||
Particle int // -1=unused, 0-3 = show image of slice
|
||||
Tiles []*ebiten.Image // has N sprites
|
||||
TileNames []string // same thing, only the names
|
||||
Obstacle bool // is an obstacle/enemy
|
||||
Direction int // obstacle business end shows into this direction
|
||||
Shader *ebiten.Shader
|
||||
Alpha *ebiten.Image
|
||||
Bond bool // denotes an entity which can have a relation to another
|
||||
Door bool // a door, can be manipulated by a switch
|
||||
Switch bool // opens|closes a door
|
||||
}
|
||||
|
||||
func (tile *Tile) Clone() *Tile {
|
||||
newtile := &Tile{
|
||||
Id: tile.Id,
|
||||
Ref: tile.Ref,
|
||||
Sprite: tile.Sprite,
|
||||
Class: tile.Class,
|
||||
Solid: tile.Solid,
|
||||
Player: tile.Player,
|
||||
IsPrimary: tile.IsPrimary,
|
||||
Renderable: tile.Renderable,
|
||||
Velocity: tile.Velocity,
|
||||
Collectible: tile.Collectible,
|
||||
Transient: tile.Transient,
|
||||
Destroyable: tile.Destroyable,
|
||||
Particle: tile.Particle,
|
||||
Tiles: tile.Tiles,
|
||||
TileNames: tile.TileNames,
|
||||
Obstacle: tile.Obstacle,
|
||||
Direction: tile.Direction,
|
||||
Alpha: tile.Alpha,
|
||||
Shader: tile.Shader,
|
||||
Bond: tile.Bond,
|
||||
Door: tile.Door,
|
||||
Switch: tile.Switch,
|
||||
Id: tile.Id,
|
||||
Ref: tile.Ref,
|
||||
Sprite: tile.Sprite,
|
||||
ToggleSprite: tile.ToggleSprite,
|
||||
Solid: tile.Solid,
|
||||
Player: tile.Player,
|
||||
IsPrimary: tile.IsPrimary,
|
||||
Renderable: tile.Renderable,
|
||||
Velocity: tile.Velocity,
|
||||
Collectible: tile.Collectible,
|
||||
Transient: tile.Transient,
|
||||
Destroyable: tile.Destroyable,
|
||||
Particle: tile.Particle,
|
||||
Tiles: tile.Tiles,
|
||||
TileNames: tile.TileNames,
|
||||
Obstacle: tile.Obstacle,
|
||||
Direction: tile.Direction,
|
||||
Alpha: tile.Alpha,
|
||||
Shader: tile.Shader,
|
||||
Bond: tile.Bond,
|
||||
Door: tile.Door,
|
||||
Switch: tile.Switch,
|
||||
}
|
||||
|
||||
return newtile
|
||||
@ -86,7 +86,6 @@ func GetSprites(class []string) []*ebiten.Image {
|
||||
|
||||
func NewTilePlayer(isprimary bool) *Tile {
|
||||
tile := &Tile{
|
||||
Class: "sphere",
|
||||
Renderable: true,
|
||||
Player: true,
|
||||
Velocity: true,
|
||||
@ -105,29 +104,23 @@ func NewTilePlayer(isprimary bool) *Tile {
|
||||
return tile
|
||||
}
|
||||
|
||||
func NewTileBlock(class string) *Tile {
|
||||
func NewTileBlock() *Tile {
|
||||
return &Tile{
|
||||
Sprite: Assets[class],
|
||||
Class: class,
|
||||
Solid: true,
|
||||
Renderable: true,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTileCollectible(class string) *Tile {
|
||||
func NewTileCollectible() *Tile {
|
||||
return &Tile{
|
||||
Sprite: Assets[class],
|
||||
Class: class,
|
||||
Solid: false,
|
||||
Renderable: true,
|
||||
Collectible: true,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTileObstacle(class string, direction int) *Tile {
|
||||
func NewTileObstacle(direction int) *Tile {
|
||||
return &Tile{
|
||||
Sprite: Assets[class],
|
||||
Class: class,
|
||||
Solid: false,
|
||||
Renderable: true,
|
||||
Obstacle: true,
|
||||
@ -140,7 +133,6 @@ func NewTileParticle(class []string) *Tile {
|
||||
sprites := GetSprites(class)
|
||||
|
||||
return &Tile{
|
||||
Class: "particle",
|
||||
Solid: false,
|
||||
Renderable: false,
|
||||
Particle: 0,
|
||||
@ -148,57 +140,39 @@ func NewTileParticle(class []string) *Tile {
|
||||
}
|
||||
}
|
||||
|
||||
func NewTileTranswall(class []string) *Tile {
|
||||
sprites := GetSprites(class)
|
||||
|
||||
func NewTileTranswall() *Tile {
|
||||
return &Tile{
|
||||
Class: "transwall",
|
||||
Solid: false,
|
||||
Renderable: true,
|
||||
Transient: true,
|
||||
Tiles: sprites,
|
||||
Sprite: sprites[0], // initially use the first
|
||||
TileNames: class,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTileHiddenDoor(class, alpha string) *Tile {
|
||||
func NewTileHiddenDoor(alpha string) *Tile {
|
||||
return &Tile{
|
||||
Class: "hiddendoor",
|
||||
Solid: false,
|
||||
Renderable: true,
|
||||
Destroyable: true,
|
||||
Sprite: Assets[class],
|
||||
Alpha: Assets[alpha],
|
||||
Shader: Shaders["destruct"],
|
||||
}
|
||||
}
|
||||
|
||||
func NewTileSwitch(class []string) *Tile {
|
||||
sprites := GetSprites(class)
|
||||
|
||||
func NewTileSwitch() *Tile {
|
||||
return &Tile{
|
||||
Class: "switch",
|
||||
Solid: false,
|
||||
Renderable: true,
|
||||
Bond: true,
|
||||
Switch: true,
|
||||
Tiles: sprites,
|
||||
Sprite: sprites[0], // initially use the first
|
||||
}
|
||||
}
|
||||
|
||||
func NewTileDoor(class []string) *Tile {
|
||||
sprites := GetSprites(class)
|
||||
|
||||
func NewTileDoor() *Tile {
|
||||
return &Tile{
|
||||
Class: "door",
|
||||
Solid: false,
|
||||
Renderable: true,
|
||||
Bond: true,
|
||||
Door: true,
|
||||
Tiles: sprites,
|
||||
Sprite: sprites[0], // initially use the first
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,17 +181,17 @@ type TileRegistry map[string]*Tile
|
||||
|
||||
func InitTiles() TileRegistry {
|
||||
return TileRegistry{
|
||||
"floor": {Class: "floor", Renderable: false},
|
||||
"default": NewTileBlock("block-greycolored"),
|
||||
"solidorange": NewTileBlock("block-orange-32"),
|
||||
"floor": {Renderable: false},
|
||||
"default": NewTileBlock(),
|
||||
"solidorange": NewTileBlock(),
|
||||
"PlayerPrimary": NewTilePlayer(Primary),
|
||||
"PlayerSecondary": NewTilePlayer(Secondary),
|
||||
"Collectible": NewTileCollectible("collectible-orange"),
|
||||
"ObstacleStar": NewTileObstacle("obstacle-star", config.All),
|
||||
"ObstacleNorth": NewTileObstacle("obstacle-north", config.North),
|
||||
"ObstacleSouth": NewTileObstacle("obstacle-south", config.South),
|
||||
"ObstacleWest": NewTileObstacle("obstacle-west", config.West),
|
||||
"ObstacleEast": NewTileObstacle("obstacle-east", config.East),
|
||||
"Collectible": NewTileCollectible(),
|
||||
"ObstacleStar": NewTileObstacle(config.All),
|
||||
"ObstacleNorth": NewTileObstacle(config.North),
|
||||
"ObstacleSouth": NewTileObstacle(config.South),
|
||||
"ObstacleWest": NewTileObstacle(config.West),
|
||||
"ObstacleEast": NewTileObstacle(config.East),
|
||||
"Particle": NewTileParticle([]string{
|
||||
"particle-ring-1",
|
||||
"particle-ring-2",
|
||||
@ -226,22 +200,22 @@ func InitTiles() TileRegistry {
|
||||
"particle-ring-5",
|
||||
"particle-ring-6",
|
||||
}),
|
||||
"Transient": NewTileTranswall([]string{"transwall", "block-orange-32"}),
|
||||
"HiddenDoor": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor2": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor3": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor4": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor5": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor6": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor7": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor8": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor9": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor10": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor11": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor12": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor13": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"Switch": NewTileSwitch([]string{"switch1", "switch2"}),
|
||||
"Door": NewTileDoor([]string{"door1", "door2"}),
|
||||
"Transient": NewTileTranswall(),
|
||||
"HiddenDoor": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor2": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor3": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor4": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor5": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor6": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor7": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor8": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor9": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor10": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor11": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor12": NewTileHiddenDoor("damage"),
|
||||
"HiddenDoor13": NewTileHiddenDoor("damage"),
|
||||
"Switch": NewTileSwitch(),
|
||||
"Door": NewTileDoor(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 33 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 503 B |
Binary file not shown.
|
Before Width: | Height: | Size: 532 B After Width: | Height: | Size: 543 B |
BIN
assets/sprites/woddendoor.ase
Normal file
BIN
assets/sprites/woddendoor.ase
Normal file
Binary file not shown.
@ -7,6 +7,7 @@ import (
|
||||
// virtual location, aka tile address
|
||||
|
||||
type Renderable struct {
|
||||
Pos *Position // just for debugging, will not used as positiion!
|
||||
Image *ebiten.Image
|
||||
DamageImage *ebiten.Image
|
||||
Damaged int
|
||||
|
||||
@ -1,24 +1,10 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"log"
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
type Transient struct {
|
||||
Activated bool
|
||||
Sprites []string
|
||||
Current int // sprite index
|
||||
}
|
||||
|
||||
func (trans *Transient) GetNext() string {
|
||||
if len(trans.Sprites) > trans.Current {
|
||||
trans.Current++
|
||||
return trans.Sprites[trans.Current]
|
||||
}
|
||||
|
||||
log.Fatalf("not enough sprites in transient tile, have %d sprites, index requested: %d",
|
||||
len(trans.Sprites), trans.Current+1,
|
||||
)
|
||||
|
||||
return ""
|
||||
Wall *ebiten.Image
|
||||
}
|
||||
|
||||
@ -13,13 +13,18 @@ const (
|
||||
All
|
||||
)
|
||||
|
||||
const PLAYERSPEED int = 5
|
||||
const PARTICLE_LOOPWAIT time.Duration = 250 * time.Millisecond
|
||||
const LEVEL_END_WAIT time.Duration = 500 * time.Millisecond
|
||||
const version string = "1.2.2"
|
||||
const (
|
||||
PLAYERSPEED int = 5
|
||||
PARTICLE_LOOPWAIT time.Duration = 250 * time.Millisecond
|
||||
LEVEL_END_WAIT time.Duration = 500 * time.Millisecond
|
||||
version string = "1.2.3"
|
||||
|
||||
const MenuRectX int = 600
|
||||
const MenuRectY int = 0
|
||||
const MenuRectCellsize int = 32
|
||||
MenuRectX int = 600
|
||||
MenuRectY int = 0
|
||||
MenuRectCellsize int = 32
|
||||
|
||||
LDTK_Entity_Ref string = "Entity_ref"
|
||||
LDTK_Toggle_Tile string = "Toggle"
|
||||
)
|
||||
|
||||
var VERSION string // maintained by -x
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"openquell/grid"
|
||||
"openquell/observers"
|
||||
"openquell/systems"
|
||||
"openquell/util"
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
@ -173,20 +174,27 @@ func LevelToSlice(game *Game, level *ldtkgo.Level, tilesize int) (Map, Map) {
|
||||
tile := assets.Tiles[entity.Identifier]
|
||||
tile.Id = entity.IID
|
||||
|
||||
ref := entity.PropertyByIdentifier("Entity_ref")
|
||||
if ref != nil {
|
||||
if ref.Value != nil {
|
||||
refid := ref.Value.(map[string]interface{})
|
||||
tile.Ref = refid["entityIid"].(string)
|
||||
slog.Debug("LOAD TILE", "tileref",
|
||||
tile.Ref, "tileid", tile.Id,
|
||||
"name", entity.Identifier,
|
||||
"isswitch", tile.Switch,
|
||||
"isdoor", tile.Door,
|
||||
)
|
||||
}
|
||||
toggleRect := util.GetPropertyToggleTile(entity)
|
||||
if toggleRect != nil {
|
||||
tile.ToggleSprite = tileset.SubImage(
|
||||
image.Rect(toggleRect.X, toggleRect.Y,
|
||||
toggleRect.X+toggleRect.W,
|
||||
toggleRect.Y+toggleRect.H)).(*ebiten.Image)
|
||||
|
||||
}
|
||||
|
||||
tile.Ref = util.GetPropertyRef(entity)
|
||||
if tile.Transient {
|
||||
slog.Debug("LOAD TILE", "tileref",
|
||||
tile.Ref, "tileid", tile.Id,
|
||||
"name", entity.Identifier,
|
||||
"isswitch", tile.Switch,
|
||||
"isdoor", tile.Door,
|
||||
"togglerect", toggleRect,
|
||||
"tilerect", entity.TileRect,
|
||||
)
|
||||
|
||||
}
|
||||
tileRect := entity.TileRect
|
||||
|
||||
tile.Sprite = tileset.SubImage(
|
||||
|
||||
27
grid/grid.go
27
grid/grid.go
@ -126,7 +126,7 @@ func NewGrid(world *ecs.World,
|
||||
case tile.Transient:
|
||||
entity := transmapper.New()
|
||||
pos, render, transient = transmapper.Get(entity)
|
||||
transient.Sprites = tile.TileNames
|
||||
transient.Wall = tile.ToggleSprite
|
||||
|
||||
case tile.Destroyable:
|
||||
entity := destructiblemapper.New()
|
||||
@ -139,16 +139,16 @@ func NewGrid(world *ecs.World,
|
||||
case tile.Switch:
|
||||
entity := switchmapper.New()
|
||||
pos, render, _, switcher = switchmapper.Get(entity)
|
||||
switcher.CloseSprite = tile.Tiles[0]
|
||||
switcher.OpenSprite = tile.Tiles[1]
|
||||
switcher.CloseSprite = tile.Sprite
|
||||
switcher.OpenSprite = tile.ToggleSprite
|
||||
switcher.Ref = tile.Ref
|
||||
switches = append(switches, entity)
|
||||
|
||||
case tile.Door:
|
||||
entity := doormapper.New()
|
||||
pos, render, _, door = doormapper.Get(entity)
|
||||
door.CloseSprite = tile.Tiles[0]
|
||||
door.OpenSprite = tile.Tiles[1]
|
||||
door.CloseSprite = tile.Sprite
|
||||
door.OpenSprite = tile.ToggleSprite
|
||||
door.Id = tile.Id
|
||||
doors = append(doors, entity)
|
||||
|
||||
@ -156,11 +156,8 @@ func NewGrid(world *ecs.World,
|
||||
log.Fatalln("unsupported tile type encountered")
|
||||
}
|
||||
|
||||
// FIXME: this image is never being used because it is
|
||||
// being overwritten in game/levels.go:LevelToSlice(). The
|
||||
// image is taken from the LDTK map, not from the Tile{}
|
||||
// definition anymore
|
||||
render.Image = tile.Sprite
|
||||
render.Pos = pos
|
||||
|
||||
default:
|
||||
// empty cell, this is where the player[s] move. No
|
||||
@ -227,17 +224,5 @@ func (grid *Grid) SetFloorTile(point image.Point) {
|
||||
}
|
||||
|
||||
func (grid *Grid) SetSolidTile(tile *assets.Tile, point image.Point) {
|
||||
solidmapper := generic.NewMap4[
|
||||
components.Position,
|
||||
components.Renderable,
|
||||
components.Tilish,
|
||||
components.Solid](grid.World)
|
||||
|
||||
grid.Map[point] = tile
|
||||
|
||||
entity := solidmapper.New()
|
||||
pos, render, _, _ := solidmapper.Get(entity)
|
||||
|
||||
render.Image = tile.Sprite
|
||||
pos.Update(point.X*grid.Tilesize, point.Y*grid.Tilesize, grid.Tilesize)
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
package systems
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
. "openquell/components"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
@ -53,10 +54,13 @@ func (system *GridSystem) Draw(screen *ebiten.Image) {
|
||||
counter := 0
|
||||
for query.Next() {
|
||||
sprite, pos, _ := query.Get()
|
||||
|
||||
counter++
|
||||
op.GeoM.Reset()
|
||||
op.GeoM.Translate(float64(pos.X), float64(pos.Y))
|
||||
slog.Debug("rendering tile", "sprite", sprite)
|
||||
system.Cache.DrawImage(sprite.Image, op)
|
||||
|
||||
}
|
||||
|
||||
op.GeoM.Reset()
|
||||
|
||||
@ -72,6 +72,7 @@ func (system *PairSystem) Update() error {
|
||||
if ok {
|
||||
// player moved on top of the switch
|
||||
switcher.Toggle()
|
||||
|
||||
// open door
|
||||
door := system.World.Relations().Get(query.Entity(), relID)
|
||||
EntitiesToSwitch = append(EntitiesToSwitch,
|
||||
|
||||
@ -26,7 +26,7 @@ type TransientSystem struct {
|
||||
|
||||
type TransientToWall struct {
|
||||
Entity ecs.Entity
|
||||
NewSprite string
|
||||
NewSprite *ebiten.Image
|
||||
Position components.Position
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ func (system *TransientSystem) Update() error {
|
||||
EntitiestoMakeSolid = append(EntitiestoMakeSolid, TransientToWall{
|
||||
Entity: query.Entity(),
|
||||
Position: *transientposition,
|
||||
NewSprite: transient.GetNext(),
|
||||
NewSprite: transient.Wall,
|
||||
})
|
||||
slog.Debug("transient added to make solid")
|
||||
}
|
||||
@ -91,18 +91,20 @@ func (system *TransientSystem) Update() error {
|
||||
system.World.RemoveEntity(convertible.Entity)
|
||||
|
||||
// replace with solid entity
|
||||
slog.Debug("transient add solid")
|
||||
slog.Debug("transient add solid", "wall", convertible.NewSprite.Bounds())
|
||||
entity := system.SolidMapper.New()
|
||||
pos, render, _, _ := system.SolidMapper.Get(entity)
|
||||
|
||||
// set it up apropriately
|
||||
pos.Set(&convertible.Position)
|
||||
render.Image = assets.Assets[convertible.NewSprite]
|
||||
render.Image = convertible.NewSprite
|
||||
render.Pos = pos
|
||||
slog.Debug("new render", "render", render)
|
||||
|
||||
// also setup the grid tile with a new solid, so that
|
||||
// collision detection works
|
||||
system.GridContainer.Grid.SetSolidTile(
|
||||
assets.NewTileBlock(convertible.NewSprite),
|
||||
assets.NewTileBlock(),
|
||||
convertible.Position.Point(),
|
||||
)
|
||||
}
|
||||
|
||||
48
util/ldtkhelpers.go
Normal file
48
util/ldtkhelpers.go
Normal file
@ -0,0 +1,48 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"openquell/config"
|
||||
|
||||
"github.com/solarlune/ldtkgo"
|
||||
)
|
||||
|
||||
type TileSetSubRect struct {
|
||||
X, Y, W, H int
|
||||
}
|
||||
|
||||
func Map2Subrect(raw map[string]any) *TileSetSubRect {
|
||||
|
||||
// we need to translate this map for less typing
|
||||
return &TileSetSubRect{
|
||||
W: int(raw["w"].(float64)),
|
||||
H: int(raw["h"].(float64)),
|
||||
X: int(raw["x"].(float64)),
|
||||
Y: int(raw["y"].(float64)),
|
||||
}
|
||||
}
|
||||
|
||||
func GetPropertyRef(entity *ldtkgo.Entity) string {
|
||||
ref := entity.PropertyByIdentifier(config.LDTK_Entity_Ref)
|
||||
if ref != nil {
|
||||
if ref.Value != nil {
|
||||
refid := ref.Value.(map[string]interface{})
|
||||
ref := refid["entityIid"].(string)
|
||||
|
||||
if ref != "" {
|
||||
return ref
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetPropertyToggleTile(entity *ldtkgo.Entity) *TileSetSubRect {
|
||||
|
||||
ref := entity.PropertyByIdentifier(config.LDTK_Toggle_Tile)
|
||||
if ref != nil {
|
||||
return Map2Subrect(ref.AsMap())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user