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
- Open Godot 4.6, click Create, name it
GodewValley, choose the Forward+ renderer, and set Version Control Metadata to Git. Godot creates.gitignore,.gitattributes,.editorconfigandicon.svgfor you. - In the FileSystem dock, create these folders:
audio/,graphics/,global/,premade/,scenes/characters/andscenes/levels/. - Copy the game’s art into
graphics/and its sounds intoaudio/, 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.
| Setting | Value | Why |
|---|---|---|
| Display → Window → Viewport Width / Height | 1920 / 1080 | Window size |
| Rendering → Textures → Canvas Textures → Default Texture Filter | Nearest | Keeps pixel art crisp instead of blurry |
| Layer Names → 2D Physics | 1 Terrain, 2 Player, 3 Objects, 4 Characters | Named 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.
- Switch on Show Built-in Actions and add W/A/S/D to
ui_up,ui_left,ui_downandui_right. The arrow keys and gamepad are already set up. - Add the new actions below, each with a deadzone of
0.2.
| Action | Key | Gamepad button |
|---|---|---|
left / right / up / down | A / D / W / S | Left stick |
action | Space | 0 (A) |
tool_backward | Q | 9 (LB) |
tool_forward | E | 10 (RB) |
style_toggle | T | 3 (Y) |
seed_forward | C | 1 (B) |
day_change | Tab | 11 (D-pad up) |
build | M | 13 (D-pad left) |
diagnose | N | 14 (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.
| Row | Direction | First frame |
|---|---|---|
| 0 | down | 0 |
| 1 | left | 33 |
| 2 | right | 66 |
| 3 | up | 99 |
| Columns | Animation |
|---|---|
| 0–1 | idle |
| 2–5 | walk |
| 6–9 | axe |
| 10–13 | water |
| 14–17 | hoe |
| 18–21 | fish (20–21 are fish_idle) |
| 22–25 | sword |
| 26–29 | seed |
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:
| Tool | Time |
|---|---|
| axe, sword | 0.3s |
| hoe, fish | 0.4s |
| water | 0.5s |
| seed | about 0.53s |
Set the AnimationPlayer’s autoplay animation to idle_down.
💡 Shortcut: finish
axe_downcompletely, 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)
- Set the AnimationTree’s Tree Root to a new AnimationNodeBlendTree.
- Inside it, add a StateMachine node named
ToolStateMachine. Leave it unconnected to the output for now. We’ll connect it in a later part. - Inside the state machine, add six BlendSpace2D states:
Axe,Hoe,Sword,Water,FishandSeed. - 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. - Add the transitions:
Start → Axewith Advance Mode Auto; every tool ↔ every other tool with the default settings; and every tool →Endwith 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
HouseTileSetwith a TileMapLayer child. Give the TileMapLayer a new TileSet with 16px tiles and addwalls_nofloor.pngas 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 aspremade/HouseTileSet.tresand the scene aspremade/HouseTileSet.tscn. - Fisher animation: Create a new SpriteFrames resource and save it as
premade/fisher.tres. Use Add frames from sprite sheet onmachines/fisher.png, which is a 4×4 grid of 48px frames with one row per direction (down, left, right, up). Makedown,left,rightandupfrom all 4 frames of their row, not looping. Makedown_idle,left_idle,right_idleandup_idlefrom 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_leftuses frames 34–35 andidle_rightuses 67–68. Using the table above (33–34 and 66–67) is probably what was intended. - In the original
code_snippets.txt, theSEED_TEXTURESdictionary is missing its closing}. Add it before you paste that snippet.
Next time: we make the farmer walk!
