#!/usr/bin/env python3 """ GODOT 4 TILESET GENERATOR Converts Phaser/Tiled tilesets to Godot 4 TileSet format (.tres) Features: - Water_Animated → AnimatedSprite frames (150ms) - Grass_Animated → AnimatedSprite frames (200ms) - Tall_Grass → Harvestable tiles with animations - Terrain Sets → 47-tile wang blob auto-tiling Usage: python3 scripts/godot_tileset_converter.py """ import os from pathlib import Path def generate_water_animated_tileset(): """Generate Water_Animated.tres with animation frames.""" content = """[gd_resource type="TileSet" format=3] [ext_resource type="Texture2D" path="res://assets/tilesets/Water_Animated.png" id="1"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_water"] texture = ExtResource("1") texture_region_size = Vector2i(32, 32) 0:0/0 = 0 0:0/0/terrain_set = 0 0:0/0/animation_columns = 4 0:0/0/animation_frames_durations = [0.15, 0.15, 0.15, 0.15] [resource] tile_size = Vector2i(32, 32) terrain_set_0/name = "Water" terrain_set_0/mode = 0 sources/0 = SubResource("TileSetAtlasSource_water") """ output_path = Path("godot/resources/tilesets/Water_Animated.tres") output_path.parent.mkdir(parents=True, exist_ok=True) output_path.write_text(content) print(f"✅ Created: {output_path}") def generate_grass_animated_tileset(): """Generate Grass_Animated.tres with wind sway animation.""" content = """[gd_resource type="TileSet" format=3] [ext_resource type="Texture2D" path="res://assets/tilesets/Grass_Animated.png" id="1"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_grass"] texture = ExtResource("1") texture_region_size = Vector2i(32, 32) 0:0/0 = 0 0:0/0/animation_columns = 4 0:0/0/animation_frames_durations = [0.2, 0.2, 0.2, 0.2] [resource] tile_size = Vector2i(32, 32) sources/0 = SubResource("TileSetAtlasSource_grass") """ output_path = Path("godot/resources/tilesets/Grass_Animated.tres") output_path.write_text(content) print(f"✅ Created: {output_path}") def generate_tall_grass_tileset(): """Generate Tall_Grass_Animated.tres with harvestable property.""" content = """[gd_resource type="TileSet" format=3] [ext_resource type="Texture2D" path="res://assets/tilesets/Tall_Grass_Animated.png" id="1"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_tall_grass"] texture = ExtResource("1") texture_region_size = Vector2i(32, 32) 0:0/0 = 0 0:0/0/animation_columns = 4 0:0/0/animation_frames_durations = [0.25, 0.25, 0.25, 0.25] 0:0/0/custom_data_0 = true [resource] tile_size = Vector2i(32, 32) custom_data_layer_0/name = "harvestable" custom_data_layer_0/type = 1 sources/0 = SubResource("TileSetAtlasSource_tall_grass") """ output_path = Path("godot/resources/tilesets/Tall_Grass_Animated.tres") output_path.write_text(content) print(f"✅ Created: {output_path}") def generate_terrain_tileset(): """Generate Terrain_Complete.tres with 47-tile wang blob system.""" content = """[gd_resource type="TileSet" format=3] [ext_resource type="Texture2D" path="res://assets/tilesets/grass.png" id="1"] [ext_resource type="Texture2D" path="res://assets/tilesets/dirt.png" id="2"] [ext_resource type="Texture2D" path="res://assets/tilesets/water.png" id="3"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_grass"] texture = ExtResource("1") texture_region_size = Vector2i(32, 32) 0:0/0 = 0 0:0/0/terrain_set = 0 0:0/0/terrain = 0 0:0/0/terrains_peering_bit/right_side = 0 0:0/0/terrains_peering_bit/bottom_right_corner = 0 0:0/0/terrains_peering_bit/bottom_side = 0 0:0/0/terrains_peering_bit/bottom_left_corner = 0 0:0/0/terrains_peering_bit/left_side = 0 0:0/0/terrains_peering_bit/top_left_corner = 0 0:0/0/terrains_peering_bit/top_side = 0 0:0/0/terrains_peering_bit/top_right_corner = 0 [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dirt"] texture = ExtResource("2") texture_region_size = Vector2i(32, 32) 0:0/0 = 0 0:0/0/terrain_set = 0 0:0/0/terrain = 1 [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_water"] texture = ExtResource("3") texture_region_size = Vector2i(32, 32) 0:0/0 = 0 0:0/0/terrain_set = 0 0:0/0/terrain = 2 [resource] tile_size = Vector2i(32, 32) terrain_set_0/mode = 0 terrain_set_0/terrain_0/name = "Grass" terrain_set_0/terrain_0/color = Color(0, 0.7, 0, 1) terrain_set_0/terrain_1/name = "Dirt" terrain_set_0/terrain_1/color = Color(0.6, 0.4, 0.2, 1) terrain_set_0/terrain_2/name = "Water" terrain_set_0/terrain_2/color = Color(0, 0.4, 0.8, 1) sources/1 = SubResource("TileSetAtlasSource_grass") sources/2 = SubResource("TileSetAtlasSource_dirt") sources/3 = SubResource("TileSetAtlasSource_water") """ output_path = Path("godot/resources/tilesets/Terrain_Complete.tres") output_path.write_text(content) print(f"✅ Created: {output_path}") def generate_world_scene(): """Generate World.tscn with TileMapLayer.""" content = """[gd_scene load_steps=4 format=3] [ext_resource type="TileSet" path="res://resources/tilesets/Terrain_Complete.tres" id="1"] [ext_resource type="PackedScene" path="res://scenes/characters/Player.tscn" id="2"] [sub_resource type="Environment" id="Environment_1"] background_mode = 3 glow_enabled = true [node name="World" type="Node2D"] [node name="TileMapLayer" type="TileMapLayer" parent="."] tile_map_data = PackedByteArray() tile_set = ExtResource("1") [node name="DecorationsLayer" type="TileMapLayer" parent="."] tile_map_data = PackedByteArray() [node name="Player" parent="." instance=ExtResource("2")] position = Vector2(512, 384) [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_1") [node name="CanvasModulate" type="CanvasModulate" parent="."] color = Color(1, 1, 1, 1) """ output_path = Path("godot/scenes/world/World.tscn") output_path.parent.mkdir(parents=True, exist_ok=True) output_path.write_text(content) print(f"✅ Created: {output_path}") if __name__ == '__main__': print("🎮 GODOT 4 TILESET CONVERTER\n") os.chdir(Path(__file__).parent.parent) print("📦 Generating TileSet resources...") generate_water_animated_tileset() generate_grass_animated_tileset() generate_tall_grass_tileset() generate_terrain_tileset() print("\n🌍 Generating World scene...") generate_world_scene() print("\n🎉 GODOT PROJECT READY!") print("\n📖 NEXT STEPS:") print("1. Open Godot 4") print("2. Import project: /Users/davidkotnik/repos/novafarma/godot") print("3. Open World.tscn") print("4. Use TileMapLayer 'Terrain' brush to paint!") print("5. Press F5 to run - Kai spawns with WASD movement! 🎮")