crisp-game-libで鳴らせるSE音8種類

JavaScript

手軽にブラウザゲームを作るためのJavaScriptライブラリcrisp-game-libで利用できるSound Effectは全8種類。

crisp-game-lib自体でプログラムを作って鳴らしてみました。
レトロ感あっていいです。

動画で実行しているプログラム

main.js

1title = "SE Type";
2 
3description = `
4 [Tap] to next
5`;
6 
7characters = [  // 6x6 "a" as first array
8];
9 
10options = {
11  theme: "crt",
12};
13 
14/** @type{Array.<SoundEffectType>} */
15let soundType = ["coin", "laser", "explosion", "powerUp", "hit", "jump", "select", "lucky"];
16 
17let no;
18 
19function update() {
20  // init
21  if(!ticks){
22    no = 0;
23  }
24 
25  // draw sound name
26  color("yellow");
27  let centerX = 100 / 2 - soundType[no].length * 6 / 2;
28  text(soundType[no], centerX, 50);
29 
30  // tap to next
31  if(input.isJustPressed){
32    no++;
33    if(no >= soundType.length) no = 0;
34  }
35 
36  // play sound
37  if(!(ticks % 60)){
38    play(soundType[no]);
39 
40  }
41 
42}

コメント

タイトルとURLをコピーしました