made player position be fixed248_t
This commit is contained in:
@ -16,6 +16,13 @@ ENTITY_TYPE_MAP = {
|
||||
"npc": "ENTITY_TYPE_NPC",
|
||||
}
|
||||
|
||||
# Helper functions
|
||||
def floatToFixed248(value):
|
||||
# Converts a float to the fixed248_t used internally.
|
||||
high24 = int(value) & 0xFFFFFF
|
||||
low8 = int((value * 256.0 - high24) * 256.0) & 0xFF
|
||||
return (high24 << 8) | low8
|
||||
|
||||
# Check if the script is run with the correct arguments
|
||||
parser = argparse.ArgumentParser(description="Generate chunk header files")
|
||||
parser.add_argument('--output', required=True, help='Dir to output headers')
|
||||
@ -392,8 +399,8 @@ for ob in objectLayer['objects']:
|
||||
if 'x' not in ob or 'y' not in ob:
|
||||
print(f"Error: Player spawn object does not contain 'x' or 'y' key.")
|
||||
sys.exit(1)
|
||||
playerSpawnX = round(ob['x'])
|
||||
playerSpawnY = round(ob['y'])
|
||||
playerSpawnX = ob['x']
|
||||
playerSpawnY = ob['y']
|
||||
break
|
||||
|
||||
# Output header file.
|
||||
@ -421,7 +428,7 @@ with open(headerPath, 'w') as f:
|
||||
f.write("NULL, ")
|
||||
f.write("\n")
|
||||
f.write("};\n\n")
|
||||
f.write(f"#define WORLD_PLAYER_SPAWN_X {playerSpawnX}\n")
|
||||
f.write(f"#define WORLD_PLAYER_SPAWN_Y {playerSpawnY}\n")
|
||||
f.write(f"#define WORLD_PLAYER_SPAWN_X (fixed248_t){floatToFixed248(playerSpawnX)}\n")
|
||||
f.write(f"#define WORLD_PLAYER_SPAWN_Y (fixed248_t){floatToFixed248(playerSpawnY)}\n")
|
||||
|
||||
print(f"chunks.h generated at: {headerPath}")
|
Reference in New Issue
Block a user