Player spawn point
This commit is contained in:
parent
d6db2f3e5f
commit
d084e4dba3
@ -6,6 +6,7 @@ cc_library(
|
|||||||
"art/game_player.c",
|
"art/game_player.c",
|
||||||
"art/game_tiles.c",
|
"art/game_tiles.c",
|
||||||
"map/game_map.c",
|
"map/game_map.c",
|
||||||
|
"map/game_map_entities.c",
|
||||||
],
|
],
|
||||||
hdrs = glob(["*.h", "art/*.h", "map/*.h"]),
|
hdrs = glob(["*.h", "art/*.h", "map/*.h"]),
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
|
@ -15,6 +15,8 @@ const char* game_title() {
|
|||||||
void game_init() {
|
void game_init() {
|
||||||
sys_init();
|
sys_init();
|
||||||
|
|
||||||
|
map_game_map_create_entities();
|
||||||
|
|
||||||
game_palette_init();
|
game_palette_init();
|
||||||
game_player_init();
|
game_player_init();
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ void game_player_anim_transition(game_player_anim anim);
|
|||||||
void game_player_anim_add_progress(uint8_t amt);
|
void game_player_anim_add_progress(uint8_t amt);
|
||||||
|
|
||||||
void game_player_init() {
|
void game_player_init() {
|
||||||
|
game_player_bbox.x = game_map_player_start_x;
|
||||||
|
game_player_bbox.y = game_map_player_start_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_player_update() {
|
void game_player_update() {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#ifndef CROCPARTY_GAME_MAP_H
|
#ifndef CROCPARTY_GAME_MAP_H
|
||||||
#define CROCPARTY_GAME_MAP_H
|
#define CROCPARTY_GAME_MAP_H
|
||||||
|
|
||||||
|
#include "game/game_collision.h"
|
||||||
#include "sys/sys.h"
|
#include "sys/sys.h"
|
||||||
|
|
||||||
extern sys_i32 game_map_player_start_x;
|
extern sys_i32 game_map_player_start_x;
|
||||||
extern sys_i32 game_map_player_start_y;
|
extern sys_i32 game_map_player_start_y;
|
||||||
extern sys_map map_game_map;
|
extern sys_map map_game_map;
|
||||||
|
|
||||||
|
void map_game_map_create_entities();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"iid": "7db5fd20-b0a0-11ee-9688-af2c6adbc1d6",
|
"iid": "7db5fd20-b0a0-11ee-9688-af2c6adbc1d6",
|
||||||
"jsonVersion": "1.5.3",
|
"jsonVersion": "1.5.3",
|
||||||
"appBuildId": 473703,
|
"appBuildId": 473703,
|
||||||
"nextUid": 108,
|
"nextUid": 110,
|
||||||
"identifierStyle": "Lowercase",
|
"identifierStyle": "Lowercase",
|
||||||
"toc": [],
|
"toc": [],
|
||||||
"worldLayout": "Free",
|
"worldLayout": "Free",
|
||||||
@ -3301,8 +3301,79 @@
|
|||||||
"tilePivotX": 0,
|
"tilePivotX": 0,
|
||||||
"tilePivotY": 0,
|
"tilePivotY": 0,
|
||||||
"biomeFieldUid": null
|
"biomeFieldUid": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type": "Entities",
|
||||||
|
"identifier": "entities",
|
||||||
|
"type": "Entities",
|
||||||
|
"uid": 109,
|
||||||
|
"doc": null,
|
||||||
|
"uiColor": null,
|
||||||
|
"gridSize": 8,
|
||||||
|
"guideGridWid": 0,
|
||||||
|
"guideGridHei": 0,
|
||||||
|
"displayOpacity": 1,
|
||||||
|
"inactiveOpacity": 0.6,
|
||||||
|
"hideInList": false,
|
||||||
|
"hideFieldsWhenInactive": true,
|
||||||
|
"canSelectWhenInactive": true,
|
||||||
|
"renderInWorldView": true,
|
||||||
|
"pxOffsetX": 0,
|
||||||
|
"pxOffsetY": 0,
|
||||||
|
"parallaxFactorX": 0,
|
||||||
|
"parallaxFactorY": 0,
|
||||||
|
"parallaxScaling": true,
|
||||||
|
"requiredTags": [],
|
||||||
|
"excludedTags": [],
|
||||||
|
"autoTilesKilledByOtherLayerUid": null,
|
||||||
|
"uiFilterTags": [],
|
||||||
|
"useAsyncRender": false,
|
||||||
|
"intGridValues": [],
|
||||||
|
"intGridValuesGroups": [],
|
||||||
|
"autoRuleGroups": [],
|
||||||
|
"autoSourceLayerDefUid": null,
|
||||||
|
"tilesetDefUid": null,
|
||||||
|
"tilePivotX": 0,
|
||||||
|
"tilePivotY": 0,
|
||||||
|
"biomeFieldUid": null
|
||||||
}
|
}
|
||||||
], "entities": [], "tilesets": [
|
], "entities": [
|
||||||
|
{
|
||||||
|
"identifier": "player_spawn",
|
||||||
|
"uid": 108,
|
||||||
|
"tags": [],
|
||||||
|
"exportToToc": false,
|
||||||
|
"allowOutOfBounds": false,
|
||||||
|
"doc": null,
|
||||||
|
"width": 16,
|
||||||
|
"height": 16,
|
||||||
|
"resizableX": false,
|
||||||
|
"resizableY": false,
|
||||||
|
"minWidth": null,
|
||||||
|
"maxWidth": null,
|
||||||
|
"minHeight": null,
|
||||||
|
"maxHeight": null,
|
||||||
|
"keepAspectRatio": false,
|
||||||
|
"tileOpacity": 1,
|
||||||
|
"fillOpacity": 1,
|
||||||
|
"lineOpacity": 1,
|
||||||
|
"hollow": false,
|
||||||
|
"color": "#BE4A2F",
|
||||||
|
"renderMode": "Rectangle",
|
||||||
|
"showName": true,
|
||||||
|
"tilesetId": null,
|
||||||
|
"tileRenderMode": "FitInside",
|
||||||
|
"tileRect": null,
|
||||||
|
"uiTileRect": null,
|
||||||
|
"nineSliceBorders": [],
|
||||||
|
"maxCount": 1,
|
||||||
|
"limitScope": "PerWorld",
|
||||||
|
"limitBehavior": "MoveLastOne",
|
||||||
|
"pivotX": 0,
|
||||||
|
"pivotY": 0,
|
||||||
|
"fieldDefs": []
|
||||||
|
}
|
||||||
|
], "tilesets": [
|
||||||
{
|
{
|
||||||
"__cWid": 6,
|
"__cWid": 6,
|
||||||
"__cHei": 20,
|
"__cHei": 20,
|
||||||
@ -3761,6 +3832,48 @@
|
|||||||
"overrideTilesetUid": null,
|
"overrideTilesetUid": null,
|
||||||
"gridTiles": [],
|
"gridTiles": [],
|
||||||
"entityInstances": []
|
"entityInstances": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__identifier": "entities",
|
||||||
|
"__type": "Entities",
|
||||||
|
"__cWid": 32,
|
||||||
|
"__cHei": 18,
|
||||||
|
"__gridSize": 8,
|
||||||
|
"__opacity": 1,
|
||||||
|
"__pxTotalOffsetX": 0,
|
||||||
|
"__pxTotalOffsetY": 0,
|
||||||
|
"__tilesetDefUid": null,
|
||||||
|
"__tilesetRelPath": null,
|
||||||
|
"iid": "658f1a30-b0a0-11ee-9688-d595f6278eea",
|
||||||
|
"levelId": 0,
|
||||||
|
"layerDefUid": 109,
|
||||||
|
"pxOffsetX": 0,
|
||||||
|
"pxOffsetY": 0,
|
||||||
|
"visible": true,
|
||||||
|
"optionalRules": [],
|
||||||
|
"intGridCsv": [],
|
||||||
|
"autoLayerTiles": [],
|
||||||
|
"seed": 9915028,
|
||||||
|
"overrideTilesetUid": null,
|
||||||
|
"gridTiles": [],
|
||||||
|
"entityInstances": [
|
||||||
|
{
|
||||||
|
"__identifier": "player_spawn",
|
||||||
|
"__grid": [15,7],
|
||||||
|
"__pivot": [0,0],
|
||||||
|
"__tags": [],
|
||||||
|
"__tile": null,
|
||||||
|
"__smartColor": "#BE4A2F",
|
||||||
|
"iid": "86fd73b0-b0a0-11ee-9688-65c9ba3d6485",
|
||||||
|
"width": 16,
|
||||||
|
"height": 16,
|
||||||
|
"defUid": 108,
|
||||||
|
"px": [120,56],
|
||||||
|
"fieldInstances": [],
|
||||||
|
"__worldX": 120,
|
||||||
|
"__worldY": 56
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"__neighbours": [{ "levelIid": "bf0dd810-b0a0-11ee-9688-3daed338bb0b", "dir": "e" }]
|
"__neighbours": [{ "levelIid": "bf0dd810-b0a0-11ee-9688-3daed338bb0b", "dir": "e" }]
|
||||||
@ -4097,6 +4210,31 @@
|
|||||||
"overrideTilesetUid": null,
|
"overrideTilesetUid": null,
|
||||||
"gridTiles": [],
|
"gridTiles": [],
|
||||||
"entityInstances": []
|
"entityInstances": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__identifier": "entities",
|
||||||
|
"__type": "Entities",
|
||||||
|
"__cWid": 32,
|
||||||
|
"__cHei": 18,
|
||||||
|
"__gridSize": 8,
|
||||||
|
"__opacity": 1,
|
||||||
|
"__pxTotalOffsetX": 0,
|
||||||
|
"__pxTotalOffsetY": 0,
|
||||||
|
"__tilesetDefUid": null,
|
||||||
|
"__tilesetRelPath": null,
|
||||||
|
"iid": "658f1a31-b0a0-11ee-9688-135042e10920",
|
||||||
|
"levelId": 107,
|
||||||
|
"layerDefUid": 109,
|
||||||
|
"pxOffsetX": 0,
|
||||||
|
"pxOffsetY": 0,
|
||||||
|
"visible": true,
|
||||||
|
"optionalRules": [],
|
||||||
|
"intGridCsv": [],
|
||||||
|
"autoLayerTiles": [],
|
||||||
|
"seed": 8688237,
|
||||||
|
"overrideTilesetUid": null,
|
||||||
|
"gridTiles": [],
|
||||||
|
"entityInstances": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"__neighbours": [{ "levelIid": "7db5fd22-b0a0-11ee-9688-e77df1dfa284", "dir": "w" }]
|
"__neighbours": [{ "levelIid": "7db5fd22-b0a0-11ee-9688-e77df1dfa284", "dir": "w" }]
|
||||||
|
12
game/map/game_map_entities.c
Normal file
12
game/map/game_map_entities.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "sys/sys.h"
|
||||||
|
#include "game_map.h"
|
||||||
|
|
||||||
|
sys_i32 game_map_player_start_x;
|
||||||
|
sys_i32 game_map_player_start_y;
|
||||||
|
|
||||||
|
// called by map_game_map_create_entities
|
||||||
|
void map_game_map_player_spawn_create(sys_i32 x, sys_i32 y) {
|
||||||
|
// center, because the entity has top-left positioning
|
||||||
|
game_map_player_start_x = x * TILE_SZ_MICROPIXEL + PIXEL_SZ_MICROPIXEL * 8;
|
||||||
|
game_map_player_start_y = y * TILE_SZ_MICROPIXEL + PIXEL_SZ_MICROPIXEL * 16;
|
||||||
|
}
|
@ -12,10 +12,20 @@ sys_map map_{{map_name}} = {
|
|||||||
.width={{width}},
|
.width={{width}},
|
||||||
.height={{height}},
|
.height={{height}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{% for entity_type in entity_types %}
|
||||||
|
void map_{{map_name}}_{{entity_type}}_create(sys_i32 x, sys_i32 y);
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
void map_{{map_name}}_create_entities() {
|
||||||
|
{% for entity in entities %}
|
||||||
|
map_{{map_name}}_{{entity.type}}_create({{entity.x}}, {{entity.y}});
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
""".lstrip()
|
""".lstrip()
|
||||||
|
|
||||||
def main(map_name, fname_ldtk, fname_c):
|
def main(map_name, fname_ldtk, fname_c):
|
||||||
width, height, tiles = load_mapdata(fname_ldtk)
|
width, height, tiles, entities = load_mapdata(fname_ldtk)
|
||||||
|
|
||||||
with open(fname_c, "wt") as output:
|
with open(fname_c, "wt") as output:
|
||||||
output.write(
|
output.write(
|
||||||
@ -24,6 +34,8 @@ def main(map_name, fname_ldtk, fname_c):
|
|||||||
tiles=tiles,
|
tiles=tiles,
|
||||||
width=width,
|
width=width,
|
||||||
height=height,
|
height=height,
|
||||||
|
entity_types=sorted(set(i["type"] for i in entities)),
|
||||||
|
entities=entities,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,7 +61,12 @@ def load_mapdata(fname_ldtk):
|
|||||||
|
|
||||||
if layer["__identifier"] == "entities":
|
if layer["__identifier"] == "entities":
|
||||||
for e in layer["entityInstances"]:
|
for e in layer["entityInstances"]:
|
||||||
raise NotImplementedError()
|
# TODO: Other fields?
|
||||||
|
entities.append({
|
||||||
|
"type": e["__identifier"],
|
||||||
|
"x": e["__worldX"] // 8,
|
||||||
|
"y": e["__worldY"] // 8,
|
||||||
|
})
|
||||||
|
|
||||||
x_min = 0
|
x_min = 0
|
||||||
y_min = 0
|
y_min = 0
|
||||||
@ -66,7 +83,7 @@ def load_mapdata(fname_ldtk):
|
|||||||
else:
|
else:
|
||||||
dense_tiles.append(255)
|
dense_tiles.append(255)
|
||||||
|
|
||||||
return width, height, dense_tiles
|
return width, height, dense_tiles, entities
|
||||||
|
|
||||||
|
|
||||||
def annot_xy(lst, w, h):
|
def annot_xy(lst, w, h):
|
||||||
|
Loading…
Reference in New Issue
Block a user