Video summary

Make a Roguelite Mining Game in Godot 4 - Complete Beginner Tutorial

Main summary

Key takeaways

Technology

Tech/Build Summary (Godot 4 Mining Roguelite Tutorial)

Project goal & systems covered

  • Build a complete 2D mining roguelite in Godot 4 from scratch.
  • Core loops/systems introduced:
    • Player character (animated, smooth movement, collision)
    • Randomized mining gameplay (pickaxe swing, mining cooldown, hit detection)
    • Rocks & ore system (rock health, ore dropping, ore pickups)
    • Visual/audio polish (tweens for ore bounce/flash, sound effects)
    • Tile-based map generation & collision (TileMap layers, terrain/props, camera)
    • Procedural rock spawning based on spawnable tiles
  • Notes that the full Udemy course adds inventory, shop upgrades between runs, more level layouts, and oxygen survival.

Player setup (Scene/Nodes/Assets)

  • Starts from a blank Godot project and creates:
    • CharacterBody2D as player
    • Uses a top-down fantasy RPG sprite pack with sprite sheets and directional animations.
  • Creates animated_sprite_2D using AnimatedSprite2D and configures sprite sheet slicing:
    • Adjusts frame grid (e.g., from 4x4 to larger counts like 6x10 / 6x10 patterns)
  • Ensures pixel-art sharpness by switching filtering:
    • Per-sprite: texture.filter = nearest
    • Project-wide: set default texture filter in Project Settings > Rendering > Textures to nearest
  • Fixes resolution/scaling issues:
    • Changes viewport defaults (example: 320x180 scaling up to window override 1280x720)
  • Adds CollisionShape2D to the player:
    • Rectangle sized to match torso/feet, avoids head collision so the sprite can overlap visuals properly.

Movement & input (script organization + 4-directional control)

  • Player script:
    • Extends CharacterBody2D, removes jump/gravity-related code for a ground-based top-down setup.
    • Uses move_and_slide() for movement/collision handling.
  • Input system:
    • Adds actions in Input Map:
      • up/down/left/right (WASD)
      • later use_pickaxe (Space)
    • Switches movement to 4-direction input using get_vector(left, right, down, up) (instead of get_axis()-style).
  • Animation handling split into functions:
    • process_movement()
    • process_animation()
    • play_animation(prefix, direction) where prefix is idle or run
  • Direction tracking:
    • Introduces last_direction to keep facing direction when input stops.
  • Left/right animation optimization:
    • Uses FlipH on AnimatedSprite2D instead of duplicating left sprite animations (idle/run use shared frames).

Mining animation & state control (prevent animation conflicts)

  • Adds mining animations from a player actions sprite sheet:
    • swing_pickaxe_down, swing_pickaxe_right, swing_pickaxe_up
  • Mining animation settings:
    • Non-looping (single swing)
    • Tuned FPS (e.g., 10 FPS)
  • Adds mining input:
    • Input action: use_pickaxe mapped to Space
  • Introduces mining state flag:
    • is_mining boolean prevents idle/run logic from overriding swing animation.
    • Mining causes:
      • velocity set to zero
      • early return from movement/animation processing until mining completes.
  • Uses AnimatedSprite2D animation_finished signal:
    • When swing finishes, is_mining = false.

Pickaxe hit detection (Area2D hitbox + rotation/offset)

  • Adds mining hit detection:
    • An Area2D named hitbox
    • A CollisionShape2D (RectangleShape2D) inside it
  • Hitbox is dynamically positioned/rotated to appear in front of the player:
    • Stores initial hitbox_offset from editor settings
    • Updates based on last_direction using match on direction vectors
    • Adds rotation adjustments for up/down (e.g., 90 degrees)
  • Hitbox monitoring toggling:
    • hitbox.monitoring = false during normal animation loops
    • Set true only inside use_pickaxe() to avoid constant collision checks.

Rock identification & prioritization (closest overlap)

  • Rocks are made distinguishable by class_name:
    • Rock script sets class_name = rock
    • Ore script sets class_name = or (intent is consistent; subtitles may show a typo)
  • Hitbox body_entered signal:
    • Filters only detected bodies of type rock.
  • Handles edge case where the hitbox overlaps multiple rocks:
    • Adds detected_rocks: Array
    • Clears it each swing
    • Chooses the best target using distance:
      • get_most_overlapping() returns the closest rock by comparing hitbox.global_position.distance_to(rock.global_position).

Damage, breaking, destruction

  • Player has pickaxe_strength (starts at 1).
  • Rock script:
    • Stores health (health) loaded from resource max_health
    • Implements take_damage(amount):
      • health -= amount
      • if health <= 0 → destroy
    • _destroy():
      • uses queue_free() to remove the rock node.

Mining QoL: holding the key (cooldown timer)

  • Adds a Timer node: mining_timer
    • cooldown set to ~0.5 seconds
    • one_shot = true
  • Changes mining input behavior:
    • is_action_pressed("use_pickaxe") with timer stopped condition
    • mining_timer.start() in use_pickaxe()
  • Result:
    • Holding Space repeatedly swings at the cooldown rate.

Ore dropping (resources-based rock types)

Resource-driven rock/ore data model

  • Rocks use a custom Resource:
    • rock_data extends Resource
    • Exported fields:
      • texture
      • max_health
      • rarity (spawn weighting)
      • min_depth
      • or_data (linked ore resource)
  • Each rock scene uses one script but different resource instances (stone/iron/etc.).
  • Ores use a second custom Resource:
    • or_data extends Resource with exports:
      • name
      • texture
      • value (sell/inventory value)
  • Rock → ore linkage:
    • Rock resource includes an or_resource reference
    • When breaking a rock, its ore data is passed to the ore instance so the ore sprite matches the rock type.

Ore scene + spawn positioning

  • Creates an or scene:
    • Area2D with Sprite2D and CollisionShape2D
  • Rock script _drop_or():
    • preloads or_scene
    • instantiates ore at the rock position
    • finds parent containers:
      • adds rocks into rock_container
      • ores into or_container
    • hides then destroys the rock as needed later.

Visual polish: ore bounce + rock flash

  • Ore spawn tween:
    • Vertical bounce tween using Tween ease/trans (ease-out then ease-in)
    • Random horizontal offset using randf_range(-15, 15)
    • Tweens run in parallel via set_parallel(true)
  • Rock hit flash:
    • Uses Sprite2D modulate intensity increase then tweens back quickly (e.g., 0.1s).

Audio polish: hit and breaking sounds

  • Adds audio folders and imports two open-source sounds:
    • pickaxe hit
    • rock breaking
  • Player plays “pickaxe hit” only after confirming it hit a rock (typically on animation finished/mining resolution).
  • Rock plays “rock breaking” before removal:
    • Hide rock (visible = false)
    • Disable collision shape using set_deferred("disabled", true)
    • await sound.finished before queue_free()
    • Prevents invisible colliders and avoids cutting off sound.

Map building (TileMap layers, terrains, props, markers)

  • Builds a base_map scene template (inherited later).
  • Uses Godot 4 TileMap architecture:
    • TileMapLayer for ground and props
    • Terrain tools (terrain sets) for walkable ground edges and automatic tile connections
    • Paint props using another tile set (e.g., railways)
  • Adds:
    • player spawn as Marker2D
    • Camera2D that follows the player
  • Fixes map aesthetics:
    • Paint wall/edge/background tiles (using wall cave tile set) so you don’t see Godot default background.

Tile collision using physics layers

  • In the tile set:
    • Creates a Physics Layer
    • Assigns collision shapes to non-walkable areas using the tile editor collision tools (polygon/grid snapping).
  • Verifies:
    • player cannot walk off edges (collision blocks movement at map boundaries).

Procedural rock generation (spawn only on valid ground tiles)

  • Level script generates rocks automatically on ready.
  • Steps:
    1. Clear existing rocks from rock_container
    2. Determine valid spawn positions:
      • Add custom data layer to ground tile set: can_spawn_rocks (boolean)
      • Iterate through ground layer “used cells”
      • Exclude cells where the props layer is occupied (get_cell_source_id != -1)
      • Add cells with can_spawn_rocks == true to available_cells
    3. Shuffle available_cells and choose rock count by fill percentage:
      • e.g., fill_percentage = 0.4
      • num_rocks = int(available_cells.size() * fill_percentage)
    4. Instantiate and place rocks:
      • convert tile cell coords → local/pixel coords with ground_layer.map_to_local(cell)
      • place rocks into rock_container
    5. Position player at marker:
      • read player spawn Marker2D coordinates
      • call player.reset(position) (reset function added to player script).

Review/tutor focus

  • This is a complete beginner tutorial emphasizing:
    • step-by-step Godot scene setup
    • sprite sheet configuration
    • input mapping
    • signal-based animation state changes
    • correct collision/hitbox design
    • resource-driven content (rock/ore definitions)
    • procedural spawning using TileMap cell data + custom tile data layers
  • Repeatedly notes code organization:
    • splitting physics/animation into functions to prevent the physics_process method from getting messy.

Main speakers/sources

  • Single instructor (voice-over/tutor):
    • Author of “Make a Roguelite Mining Game in Godot 4 - Complete Beginner Tutorial”
    • Mentioned as a free tutorial and linked Udemy full course.

Rate this summary

Your feedback will help improve summaries.

Improve this summary

Reprocess with a stronger model when the summary feels incomplete or inaccurate.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video