- Return to Touhou Danmakufu
Note: This is an in-progress translation of the tutorial found here. It is meant to be worked through in order.
Touhou Danmakufu is based on the Touhou series of danmaku shooters. You can use it to create your own danmaku patterns, and even your own complete games. The coding language is based loosely off the C language, however it has been heavily simplified for the purpose of creating scripts easily. In this tutorial, we will explain how to create a simple Danmakufu script. This tutorial has been written specifically with the idea of teaching people with no prior programming experience.
Lesson 1: Our First Script
First, prior to making your own script, let's have a look at an existing Touhou Danmakufu script.
Installation
Installing is easy. First, go to the Touhou Danmakufu website. Then download the latest version of Touhou Danmakufu. (This should be the first link on the page.) Because it comes as a ZIP file, you can unzip and run it from wherever you want by opening the th_dnh.exe file in the main folder. If you have enabled "Hide extensions", it's possible that someone may have slipped a virus into the folder, so you should disable this feature if possible.
You can unpack the ZIP with various software. (The site mentions a program called "Vector", but the Windows ZIP utility should be fine.)
Settings
If you have a game pad, it's best if you set it up before starting to play with Touhou Danmakufu. Special settings such as this should be controlled with the pre-configure program "config.exe". Upon running config.exe, you should see this dialog.
The top half of the dialog displays the specifications for the environment you are running Danmakufu on. The bottom half displays the settings for the device (Windowed/Fullscreen, Window Size, Graphic Depth and Audio Source on the left) and the gamepad settings (the usual buttons for the Touhou games.)
Regular players of Touhou games will recognize this layout, however if the graphics become unstable, feel free to experiment with the right half of the dialog.
Setting the pad is easy, as this dialog shows. Simply highlight the button which you want to change, and press the button. They are, in order from top to bottom:
- Shot
- Bomb
- Focus
- Decide
- Cancel
- Pause
- Event Skip
It is also possible to set the same button to different behaviour, for example you might want to select the Shot button to be the Decide button, or the Bomb button to be Cancel.
Playing the Game
th_dnh.exe is the main part of Touhou Danmaku. When you run the program, you will see a menu, the meanings of which will be explained below.
All | Play all scripts within the main folder and subfolders. |
Single | Play one script within the main folder and subfolders. |
Plural | Play a continuous danmaku with more than one pattern. Only uses the plural scripts. |
Stage | Play a stage danmaku with enemies and bosses. Only uses the stage scripts. |
Directory | Play one script. Differs from "Single" by the choice of subdirectory. |
Random | Play one script randomly selected from the main folder and subfolders. |
Exit | Quits the program. |
Apart from "Exit", the player chooses a character and then a script to play.
All, Single, Plural, Stage
Only scripts are listed. Select the desired script, then press the decision button (Z key) to choose. Press the decision button again to play. If you use no continues, it's possible to save the replay. Replays will be shown at the bottom of the screen when you select a script; you can choose to play them back.
Directory
Scripts are listed along with directories. Navigate through the directories until you find the script you want, then select it.
Random
Selects a script at random from all the scripts. You can save replays, but you can't replay them.
Updating
To update Touhou Danmakufu, first extract the new th_dnh.zip elsewhere. Then, simply move everything to the old folder. This will overwrite all the older files in the main directory.
Lesson 2: Let's Make One!
So, small talk aside, let's now make a simple danmaku pattern. In this second and later lessons, we'll provide a summary of what we've learned in that lesson.
Summary
- Placing files in the script folder.
#TouhouDanmakufu
recognized as the first line in a script.script_enemy_main
defines the behaviour of the enemy.
A script that does nothing
First, let's make a script that does nothing. Place the file in the "scripts" folder, or if you prefer, you can make a new folder. Anyway, if the script is in the "scripts" folder, there are no restrictions.
So, let's create a file called Test.txt
. Touhou Danmakufu uses the .txt
format, an ordinary text file. You can use any text editor (for example Notepad) to edit the following:
#TouhouDanmakufu #Title [The title of the danmaku] #Text [The description of the danmaku] #ScriptVersion [2]
script_enemy_main { }
In the first line, #TouhouDanmakufu
represents a single script file for Touhou Danmakufu. For example, if you remove the #
or the entire line, the system will not recognize it as a Touhou Danmakufu script. In other words, if there is another error somewhere in the script then the system will still recognize it as a Touhou Danmakufu script (even though it won't actually load). Also, because it is a stand-alone danmaku script, it will appear in the Single list.
In the second line, #Title
gives the system the text that lies inside the square brackets []
. In this case, "The title of the danmaku" will be displayed.
In the third line, #Text
is a description of the script that appears within the square brackets. The description appears at the lower left of the screen when a particular script is selected. In this case, "The description of the danmaku" will display. If you need to use new lines in the caption, you can simply press the Enter key and go to the next line. In other words, the square brackets act like a triple-quote in Python; whatever is in the brackets (spaces, tabs, newlines etc.) will be displayed.
The fourth line specifies the version of the script. There are only two versions as of this current point in time, so this line should always read #ScriptVersion [2]
.
The last line, script_enemy_main
, describes the behaviour of the enemy. You could say it's the most important part of the Touhou Danmakufu script. But for now, let's just leave it at that; it does nothing.
So, to start the script, run Danmakufu and select the script "The name of the danmaku". You will see the game screen briefly, before going to "Clear", as there is no enemy left in the script.
Fixing the script
Is there a need to relaunch Danmakufu every time you modify the script? No, there's no need. If you have modified the script that's running, simply press Backspace and the script will run from the start.
If you modified a different script, you can just choose it from the regular list of scripts. However, if you change the #Title
tag, you must exit the current script list by pressing the Cancel button. If you are in Directory mode, returning to the parent directory will suffice.
Summary
- Placing files in the script folder.
#TouhouDanmakufu
recognized as the first line in a script.script_enemy_main
defines the behaviour of the enemy.
Next, we'll create an enemy.