Digesting Godot Valley – Part 1: Setting Up the Project

I have been recreating the project Godot Valley, and while I feel Chriz does a lovely job of explaining the how’s and why’s, I need the what’s for my brain to function. Here are my notes.


In this first part we start from a completely empty Godot 4.6 project and build the foundation for a cozy farming game: project settings, controls, global data, a fully animated player and an empty level. Nothing moves yet. That comes in Part 2. By the end you’ll press F5 and see your farmer standing in the world.

Step 0: Create the project

  1. Open Godot 4.6, click Create, name it GodewValley, choose the Forward+ renderer, and set Version Control Metadata to Git. Godot creates .gitignore, .gitattributes, .editorconfig and icon.svg for you.
  2. In the FileSystem dock, create these folders: audio/, graphics/, global/, premade/, scenes/characters/ and scenes/levels/.
  3. Copy the game’s art into graphics/ and its sounds into audio/, keeping their subfolders (characters/, tilesets/, icons/ and so on). Godot imports them automatically.

What you’ll learn: how a Godot project is organized, what res:// paths are, and how importing works.

Step 1: Project Settings

Open Project → Project Settings and switch on Advanced Settings in the top-right corner.

SettingValueWhy
Display → Window → Viewport Width / Height1920 / 1080Window size
Rendering → Textures → Canvas Textures → Default Texture FilterNearestKeeps pixel art crisp instead of blurry
Layer Names → 2D Physics1 Terrain, 2 Player, 3 Objects, 4 CharactersNamed collision layers

Step 2: Input Map

Go to Project Settings → Input Map. When you add a key, choose Physical Keycode so the controls work on any keyboard layout.

  1. Switch on Show Built-in Actions and add W/A/S/D to ui_up, ui_left, ui_down and ui_right. The arrow keys and gamepad are already set up.
  2. Add the new actions below, each with a deadzone of 0.2.
ActionKeyGamepad button
left / right / up / downA / D / W / SLeft stick
actionSpace0 (A)
tool_backwardQ9 (LB)
tool_forwardE10 (RB)
style_toggleT3 (Y)
seed_forwardC1 (B)
day_changeTab11 (D-pad up)
buildM13 (D-pad left)
diagnoseN14 (D-pad right)

What you’ll learn: why games use named actions instead of checking for specific keys.

Step 3: Global scripts (autoloads)

Create global/enums.gd:

extends Node

enum Style {BASIC, COWBOY, ENGLISH, BASEBALL, BEANIE, STRAW, CAP}
enum State {DEFAULT, FISHING, BUILDING, SHOP}
enum Tool {AXE, HOE, SWORD, WATER, FISH, SEED}
enum Machine {SPRINKLER, FISHER, SCARECROW, DELETE}
enum Seed {TOMATO, CORN, PUMPKIN, WHEAT}
enum Item {WOOD, APPLE, TOMATO, CORN, WHEAT, PUMPKIN, FISH}
enum Shop {MAIN, HAT}

Open Project Settings → Globals → Autoload and add res://global/enums.gd with the name Enum.

Next, create global/data.gd. It holds the game’s lookup tables: player skins, plant stats, shop prices and tool animations, all stored as const dictionaries keyed by the enums above. Here’s how it starts:

extends Node

const PLAYER_SKINS = {
	Enum.Style.BASIC: preload("res://graphics/characters/main/main_basic.png"),
	Enum.Style.BASEBALL: preload("res://graphics/characters/main/main_blue.png"),
	Enum.Style.COWBOY: preload("res://graphics/characters/main/main_cowboy.png"),
	Enum.Style.ENGLISH: preload("res://graphics/characters/main/main_grey.png"),
	Enum.Style.STRAW: preload("res://graphics/characters/main/main_straw.png"),
	Enum.Style.BEANIE: preload("res://graphics/characters/main/main_red.png")}
const TILE_SIZE = 16
const PLANT_DATA = {
	Enum.Seed.TOMATO: {
		'texture': "res://graphics/plants/tomato.png",
		'icon_texture': "res://graphics/icons/tomato.png",
		'name':'Tomato',
		'h_frames': 3,
		'grow_speed': 0.6,
		'death_max': 3,
		'reward': Enum.Item.TOMATO},
	# ...corn, pumpkin and wheat follow the same pattern
}
# Also add: MACHINE_UPGRADE_COST, HOUSE_COST, STYLE_UPGRADES, TOOL_STATE_ANIMATIONS

Autoload it as Data and make sure it sits below Enum in the list, because Data uses Enum.

What you’ll learn: enums, dictionaries, preload(), and autoloads (scripts you can reach from anywhere in the game).

Step 4: Player scene, nodes

Create a new scene with a CharacterBody2D root named Player and save it as scenes/characters/player.tscn.

Player (CharacterBody2D)       collision layer: 2   mask: 1 + 3
├── Sprite2D                   texture: main_basic.png, Hframes 33, Vframes 4
├── CollisionShape2D           CapsuleShape2D, radius 4, height 10
└── Animation (Node)
    ├── AnimationPlayer        Root Node: ../..  (the Player)
    └── AnimationTree          Root Node: ../..,  Anim Player: ../AnimationPlayer

The sprite sheet is 1584×192 pixels: 33 columns × 4 rows of 48px frames. Each row is one direction, so frame number = row × 33 + column.

RowDirectionFirst frame
0down0
1left33
2right66
3up99
ColumnsAnimation
0–1idle
2–5walk
6–9axe
10–13water
14–17hoe
18–21fish (20–21 are fish_idle)
22–25sword
26–29seed

What you’ll learn: scenes, node trees, sprite sheets, and collision layers and masks.

Step 5: Player animations (all 36 of them)

Make 8 animations × 4 directions, named with _down, _left, _right and _up on the end:

  • idle and fish_idle: 2 frames, length 0.4, looping
  • walk: 4 frames, length 0.8, looping
  • axe, water, hoe, fish, sword, seed: 4 frames, length 0.8, not looping

To add a keyframe, select the Sprite2D while the Animation panel is open and click the key icon next to Frame in the Inspector. Add a key every 0.2 seconds and set the track’s update mode to Discrete.

Each tool animation also needs a Call Method Track on Player that calls tool_use_emit at the moment the tool hits. This is how the animation tells the code “the axe just hit something”. The times are:

ToolTime
axe, sword0.3s
hoe, fish0.4s
water0.5s
seedabout 0.53s

Set the AnimationPlayer’s autoplay animation to idle_down.

💡 Shortcut: finish axe_down completely, then use Animation → Duplicate and only change the frame numbers. That makes the 36 animations much quicker.

Now create player.gd and attach it to Player. It only needs the function the method tracks call:

extends CharacterBody2D

func tool_use_emit():
	print('tool')

What you’ll learn: AnimationPlayer, keyframes, and method tracks (an animation calling your code).

Step 6: AnimationTree (tool state machine)

  1. Set the AnimationTree’s Tree Root to a new AnimationNodeBlendTree.
  2. Inside it, add a StateMachine node named ToolStateMachine. Leave it unconnected to the output for now. We’ll connect it in a later part.
  3. Inside the state machine, add six BlendSpace2D states: Axe, Hoe, Sword, Water, Fish and Seed.
  4. In each blend space, add 9 points that use that tool’s animations: (0,-1) → _up, (0,1) → _down, (0,0) → _down, every point with x = -1 → _left, and every point with x = +1 → _right.
  5. Add the transitions: Start → Axe with Advance Mode Auto; every tool ↔ every other tool with the default settings; and every tool → End with Switch Mode At End and Advance Mode Auto.

What you’ll learn: blend spaces (picking an animation from a direction) and state machines.

Step 7: Level scene

Create a new scene and save it as scenes/levels/level.tscn:

Level (Node2D)
├── Layers (Node2D)                   ← empty for now, tilemaps go here later
└── Objects (Node2D)  Y Sort Enabled ✔
    └── Player  (drag player.tscn in), position (186, 342)

Right-click level.tscn and choose Set as Main Scene. Press F5: your farmer should appear and play the idle animation.

What you’ll learn: instancing one scene inside another, Y-sorting, and choosing the main scene.

Step 8: Premade resources

These are resources we’ll use in later parts. Building them now is good practice with Godot’s editors.

  • House TileSet: Create a new scene: a Node2D named HouseTileSet with a TileMapLayer child. Give the TileMapLayer a new TileSet with 16px tiles and add walls_nofloor.png as an atlas (11×5 tiles). Add a physics layer (layer 1, no mask) and draw collision shapes on the wall tiles. Then add a terrain set in Match Corners and Sides mode with one terrain, and paint the peering bits so the walls connect automatically. Save the TileSet as premade/HouseTileSet.tres and the scene as premade/HouseTileSet.tscn.
  • Fisher animation: Create a new SpriteFrames resource and save it as premade/fisher.tres. Use Add frames from sprite sheet on machines/fisher.png, which is a 4×4 grid of 48px frames with one row per direction (down, left, right, up). Make down, left, right and up from all 4 frames of their row, not looping. Make down_idle, left_idle, right_idle and up_idle from the last 2 frames of their row, looping. Use speed 5 for all of them.
  • Code snippets: Add premade/code_snippets.txt, a text file of ready-made code we’ll paste in later.

What you’ll learn: TileSets, terrains (autotiling), painting collision shapes, and SpriteFrames.

Step 9: Save your progress

Commit your work so you can always get back to this point:

git add .
git commit -m "Starter project"

Fixes to the original project

Hi Chriz. A few mistakes from the original game that are worth knowing about:

  • In the original, idle_left uses frames 34–35 and idle_right uses 67–68. Using the table above (33–34 and 66–67) is probably what was intended.
  • In the original code_snippets.txt, the SEED_TEXTURES dictionary is missing its closing }. Add it before you paste that snippet.

Next time: we make the farmer walk!

Leave a Reply

Your email address will not be published. Required fields are marked *