Created
August 21, 2020 09:53
昔のADVゲームやRPGゲームでよく見かけたテキスト表示を行う最低限のプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String str = "abcdefg"; | |
int textSize = 60; | |
int intervalTime = 120; // 文字の表示間隔をミリ秒で指定 | |
void setup() { | |
size(300, 100); | |
textSize(textSize); | |
fill(248); | |
} | |
void draw() { | |
background(0); | |
int endIndex = min(millis()/intervalTime, str.length()); // 何文字目まで表示するのかを計算 | |
text(str.substring(0, endIndex), 0, textSize); // 実際に文字を表示 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
補足
昔のゲームでは文字の表示に合わせて効果音が鳴ったりもしましたが、その辺も再現したい場合はもう少し工夫が必要です
intervalTime
の値を変更すると文字の表示速度が変化します