Site Logo


My Tutorials and Guides for Touhou Danmakufu ph3 (東方弾幕風ph3)

Welcome to my Danmakufu Tutorials for Touhou Danmakufu ph3! Unless otherwise stated, all tutorials are written by me, Sparen.

Para Español, haga clic aquí por favor.

These tutorials are meant to be step by step guides to teach you how to use the many functions of Danmakufu. There are many details, and do be aware that you will not be able to make a complex script in a day - take your time and learn the concepts. These guides are written in a way where they build upon each other, so it is highly suggested that you read them in order.

Additionally, I do not focus on making danmaku patterns in these tutorials. Those are for you, the scripter, to discover and implement using your own abilities, although some of my video tutorials will help teach the basics.

How to Use these Tutorials

These Danmakufu tutorials use Javascript, so I suggest that you turn it on for this site, as I have included comprehension questions that give feedback. This is so that you will have a better understanding of why things work the way they do.

EXERCISE: This is an exercise meant to give you experience working with the lesson content
CHECKPOINT: This is a question to make sure you understand the material

NOTE TO MOBILE USERS: I suggest using landscape mode (even though anything with a code block will wreck your view)

Other things to note

The Touhou Danmakufu Wiki and the ph3 Function list (documentation) will be linked on every tutorial page, and I also hope to integrate existing tutorials into the framework of this tutorial.

For my local copy of the Danmakufu Function Reference, refer to ph3 Function Reference (onsite).

All tutorials undergo peer-review. However, newer tutorials (especially brand new tutorials) will most likely have typos and errors. If you find incorrect/confusing information or typos, feel free to PM me via the Maidens of the Kaleidoscope Forum.

Since this is a work in progress, I am likely to change the order of later tutorials. Feel free to suggest things.

I hope you find this helpful!

General Resources

Coding Style Standards Guide

Backup DNH ph3 Documentation

Unit 1 - Introduction to Touhou Danmakufu ph3 [Single]

Lesson 1Introduction, Downloading Danmakufu
     • Introduction to Danmakufu and these tutorials
     • Other resources for learning Danmakufu
     • Danmakufu Wiki, Bulletforge
     • Downloading & updating Danmakufu
     • Installing scripts

Lesson 2Running and Using Danmakufu
     • Running Danmakufu and navigating Danmakufu's menus
     • Danmakufu's default controls

Lesson 3Danmakufu Framework
     • Script types in Danmakufu
     • Structure of a Danmakufu script
     • Danmakufu's routines

Lesson 4Danmakufu Syntax and Structures Part 1
     • Comments in Danmakufu
     • Local & Global Variables and Constants
     • Danmakufu's built-in math functions
     • Characters, Strings, and Arrays in Danmakufu

Lesson 5Danmakufu Syntax and Structures Part 2
     • Booleans and boolean expressions in Danmakufu
     • Danmakufu loops and control structures
     • Functions and tasks in Danmakufu
     • yield; usage and the wait() function
     • Danmakufu syntax and reserved keywords

Lesson 6Firing our First Bullet
     • Setting up a blank Single script
     • Setting attack settings in @Event
     • Creating, registering, and rendering an enemy
     • Setting the position of a Move Object
     • Dimensions and render priorities of the playing field
     • Enemy hitboxes
     • Closing and cleaning up Single scripts
     • Creating danmaku bullets
     • Aiming danmaku at the player from an object's position
     • Utilizing shot constant sheets

Lesson 7 Attack Flow and Our First Spellcard
     • Retrieving the Boss Scene Object
     • Designating a Single script as a spellcard
     • Handling spellcard bonuses in Danmakufu
     • Moving a Move Object
     • Creating rings and lines of danmaku with loops
     • Syncing spawning of danmaku to boss movement

Lesson 8 Introduction to Shotsheets and Bullet Properties
     • Shotsheets and Shot Constant sheets
     • Shotsheet-defined bullet shot properties
     • Properties of a Move Object
     • Passing object IDs to tasks for constant updating in parallel
     • Using ObjMove_AddPattern()
     • Shot object Auto-Delete and Spell Resist
     • Render Object properties and the difference between ObjMove and ObjRender

Extra Lesson 1 Recollection: Eternal Meek
     • Usage of the Danmakufu RNG via rand()
     • Float -> Int in Danmakufu
     • Recreating 0.12m's rand_int() in ph3
     • Using the RNG to recreate Eternal Meek

Lesson 9 Introduction to Lasers
     • Radial and Linear Hitboxes
     • Creating Loose and Straight Lasers
     • Laser Object Properties
     • Delay Lasers
     • Creating Non-Directional Lasers
     • Using ascent loops to pass unique IDs to object tasks
     • Using trigonometry to position objects x pixels from a point

Lesson 10 Angular Velocity and Curved Lasers
     • Angular Velocity in Danmakufu
     • Creating Curved Lasers
     • Properties of Curved Lasers
     • Lag with curved lasers
     • Curving bullet lines
     • Snaking bullet lines and curvy lasers
     • Passing direction multipliers into object tasks

Extra Lesson 2 Recollection: Moonlight Ray
     • Creating moving straight lasers
     • Recreating Moonlight Ray

Lesson 11 Using Trigonometry and Parametrics
     • Danmakufu's coordinate system
     • Creating rings of bullets with radius x pixels from a point
     • Creating ellipses of bullets around a point
     • Utilizing parametric equations in Danmakufu

Extra Lesson 3 Recollection: Border of Wave and Particle
     • History and concept behind Border of Wave and Particle
     • Recreating Border of Wave and Particle
     • Applications of and variations on Border of Wave and Particle

Unit 2 - Intermediate Touhou Danmakufu ph3 [Plural]

Lesson 12 Creating and Utilizing Plural Scripts
     • Setting up a blank Plural Script
     • Creating and Registering Boss Scene Objects

Lesson 13 Introduction to 2D Sprites
     • Creating 2D Sprite Objects
     • Assigning textures and source + dest rects to 2D Sprites
     • Rendering and positioning 2D Sprites
     • Animating an enemy using spritesheets
     • Render priorities and default render priorities

Lesson 14 Utilizing Blend Types in Danmakufu
     • Blend types supported natively in Danmakufu ph3
     • Alpha Compositing
     • Additive, Subtractive, and Multiplicative Blending, and their uses
     • Invert DestRGB and its uses

Lesson 15 Using Danmakufu's Sound Functions
     • Danmakufu's audio functions
     • Common file types for audio
     • Guidelines for sound assets in Danmakufu projects
     • Creating and manipulating Sound Objects
     • Assigning loop times to Sound Objects
     • Exporting to .ogg using Audacity

Lesson 16 Object Autodeletion and (0,0) Spawning
     • Handling TFinalize for Single scripts in a Plural
     • Terminating tasks to avoid (0,0) spawning errors
     • AutoDeleteObject
     • Disabling @MainLoop yield;

Lesson 17 Introduction to Text Functions and Fonts
     • Fonts
     • Installing Fonts in Danmakufu
     • Creating Text Objects
     • Setting size and color of Text Objects
     • Aligning and centering Text Objects
     • Danmakufu's escape characters and Syntactic Analysis
     • When to use Text Objects vs images containing text

Lesson 18 Creating and Using Functions and Libraries
     • Differences between Functions, Tasks, and Subroutines
     • Function Libraries
     • Usage of #include
     • Documentation

Lesson 19 Introduction to System Files
     • Usage of System Scripts
     • Changing the STG_Frame
     • Changing the position and size of the playing field
     • Displaying gameplay information such as score and lives
     • Setting custom Pause, End Scene, and Replay Save Scene scripts
     • Events commonly used in System Scripts
     • Changing the default spellcard sound effect

Lesson 20 Manipulating Pause and End Scene Files
     • Usage of Pause and End Scene scripts
     • Contents of a Pause or End Scene script
     • Menus and Virtual Keys (basics) in Danmakufu
     • Results of a Pause or End Scene script

Lesson 21 Customizing Replay Save Files
     • Replay Save Scripts
     • Contents of a Replay Save Script

Lesson 22 Implementing 2D Backgrounds in Background Scripts
     • Usage of Background Scripts
     • Contents of a Background Script
     • Creating static 2D background components in Background scripts
     • Creating scrolling 2D background components in Background scripts
     • Creating rotating 2D background components in Background scripts
     • Layering textures with varying Alpha and blend types
     • Background scripts and user experience

Extra Lesson 4 Recollection: This Side Down
     • The 2D Camera in Danmakufu ph3
     • 2D Camera functions
     • 2D Camera defaults
     • Implementing 2D screenshake in Danmakufu ph3
     • Implementing screenflip in Danmakufu ph3
     • Implementing rotation of the 2D camera in Danmakufu ph3

Unit 3 - Advanced Touhou Danmakufu ph3 [Stage]

Lesson 23 Basics of Stages in Danmakufu
     • Structure of a Stage Script
     • Running Plural Scripts from Stage Scripts
     • Playing Background music in Stage Scripts with Pause support

Lesson 24 Introduction to Common Data
     • Basics of Common Data
     • Usage of Common Data
     • Menus in Stage Scripts
     • Cross-Script Common Data

Lesson 25 Understanding and Manipulating @Event
     • Events in Danmakufu
     • Event Parameters and Return Values
     • Pitfalls when using Events

Lesson 26 Utilizing EV_USER with NotifyEventAll
     • User Event Types
     • Triggering User Events with NotifyEvent + NotifyEventAll

Lesson 27 Basics of Items
     • Basics of Items in Danmakufu
     • Item Object Functions
     • Creating Item Objects using NotifyEventAll

Lesson 28 Implementing Stage Enemies and Familiars
     • Creating Familiars using Render Objects or Shot Objects
     • Utilizing Familiars for symmetric bullet patterns via ID and dir parameter passing
     • Creating Stage Enemies using tasks and Enemy Object functions

Lesson 29 Introduction to Primitive Objects and 2D Sprite Lists
     • Primitives (Triangle List, Triangle Strip, Triangle Fan, Line List, Line Strip, Point List) in Danmakufu
     • Usage of Primitive Vertex functions in Danmakufu
     • 2D Sprite Lists in Danmakufu

Extra Lesson ?? Libraries: Circular Lifebar

Lesson ?? Introduction to 3D Sprites and 3D Backgrounds **Planned

Extra Lesson ?? Libraries: Dialogue System

Lesson ?? Utilizing the Log Window and Debug Functions **Planned

Lesson ?? Using Virtual Keys and Mouse Input **Planned

Lesson ?? Introduction to Player Scripts **Planned

Unit 4 - Super Advanced Touhou Danmakufu ph3 [Package]

Lesson ?? Introduction to Package Scripts **Planned

Lesson ?? Introduction to Area Common Data **Planned

Lesson ?? Understanding Replays and Replay Comments **Planned

Lesson ?? Creating Shotsheets **Planned

Lesson ?? Creating User-Defined Items **Planned

Lesson ?? Introduction to Render Targets **Planned

Lesson ?? Creating and Utilizing Shaders **Planned

Lesson ?? Creating and Utilizing Meshes **Planned

Lesson ?? Introduction to File Objects **Planned

Extra Unit - Misc. Tutorials for Touhou Danmakufu ph3

Lesson 1 How to Use Bulletforge

Lesson 2 Advertising on Youtube

Lesson 3 Asset and Code Protection

External Tutorials (Offsite)

Sparen's 0.12m to ph3 Transition Guide

Sparen's Basic Ph3 Item Tutorial (merged into Lesson 27)

Sparen's Danmakufu Tutorials (Video)