• R/O
  • SSH

hyakutyping: コミット

ゲーム用のソースコード


コミットメタ情報

リビジョンf8f13679c15293b6e00aaea0c179e17bcdcbfc54 (tree)
日時2011-07-29 09:38:04
作者satofumi
コミッターsatofumi

ログメッセージ

効果音と音楽を再生するための記述を追加

変更サマリ

差分

diff -r 70c36996906a -r f8f13679c152 Makefile
--- a/Makefile Thu Jul 21 06:07:58 2011 +0900
+++ b/Makefile Fri Jul 29 09:38:04 2011 +0900
@@ -7,9 +7,9 @@
77 # Compile options
88 CC = g++
99 CXXFLAGS = -g -O0 -Wall -Werror -W $(INCLUDES) `sdl-config --cflags`
10-INCLUDES = -I$(LIB_DIR)/gui -I$(LIB_DIR)/connection -I$(LIB_DIR)/input -I$(LIB_DIR)/geometry -I$(LIB_DIR)/lua -I$(LIB_DIR)/common -I$(LIB_DIR)/math -I$(LIB_DIR)/system -I/usr/include/lua5.1
10+INCLUDES = -I$(LIB_DIR)/audio -I$(LIB_DIR)/gui -I$(LIB_DIR)/connection -I$(LIB_DIR)/input -I$(LIB_DIR)/geometry -I$(LIB_DIR)/lua -I$(LIB_DIR)/common -I$(LIB_DIR)/math -I$(LIB_DIR)/system -I/usr/include/lua5.1
1111 LDFLAGS = -L/usr/X11/lib
12-LDLIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_net -lluabind -llua5.1 -lGL -lboost_signals-mt
12+LDLIBS = `sdl-config --libs` -lSDL_mixer -lSDL_image -lSDL_ttf -lSDL_net -lluabind -llua5.1 -lGL -lboost_signals-mt
1313 #LDLIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_net -lluabind -llua5.1 -lboost_signals-mt -lGL32
1414
1515 STATE_PARSER = state_parse.rb
@@ -58,7 +58,7 @@
5858 -dot -Tpng $< > $@
5959
6060 OBJS = luabindTyping.o HistoryGraph.o Option.o
61-REQUIRE_LIBS = $(LIB_DIR)/lua/lua.a $(LIB_DIR)/lua/lua_luabind.a $(LIB_DIR)/gui/gui.a $(LIB_DIR)/input/input.a $(LIB_DIR)/geometry/geometry.a $(LIB_DIR)/system/sdl/system_sdl.a $(LIB_DIR)/system/system.a
61+REQUIRE_LIBS = $(LIB_DIR)/lua/lua.a $(LIB_DIR)/lua/lua_luabind.a $(LIB_DIR)/audio/sdl_mixer/audio_sdl.a $(LIB_DIR)/gui/gui.a $(LIB_DIR)/input/input.a $(LIB_DIR)/geometry/geometry.a $(LIB_DIR)/system/sdl/system_sdl.a $(LIB_DIR)/system/system.a
6262 $(REQUIRE_LIBS) :
6363 cd $(@D)/ && $(MAKE) $(@F)
6464
diff -r 70c36996906a -r f8f13679c152 hyakutyping.cpp
--- a/hyakutyping.cpp Thu Jul 21 06:07:58 2011 +0900
+++ b/hyakutyping.cpp Fri Jul 29 09:38:04 2011 +0900
@@ -11,6 +11,7 @@
1111 #include "luabindTyping.h"
1212 #include "lua_runStateMachine.h"
1313 #include "luabindInit.h"
14+#include "luabindAudio.h"
1415 #include "luabindGui.h"
1516 #include "luabindGeometry.h"
1617 #include "luabindCommon.h"
@@ -19,6 +20,7 @@
1920 #include "LuaHandler.h"
2021 #include "Screen.h"
2122 #include "fileExist.h"
23+#include "Audio.h"
2224 #include <iostream>
2325 #include <cstring>
2426 #include <cstdlib>
@@ -132,6 +134,7 @@
132134 luabindInput(L);
133135 luabindGeometry(L);
134136 luabindGui(L);
137+ luabindAudio(L);
135138 luabindTyping(L);
136139
137140 // デフォルト設定の読み出し
@@ -175,10 +178,8 @@
175178 }
176179
177180 // 音楽デバイスの初期化
178- // !!!
179-
180- // CD-ROM デバイスの初期化
181- // !!!
181+ Audio audio;
182+ audio.initialize();
182183
183184 // Lua スクリプトの起動
184185 lua_State* L = luabindInit();
diff -r 70c36996906a -r f8f13679c152 scripts/first_menu.lua
--- a/scripts/first_menu.lua Thu Jul 21 06:07:58 2011 +0900
+++ b/scripts/first_menu.lua Fri Jul 29 09:38:04 2011 +0900
@@ -98,19 +98,17 @@
9898 menu_:setIndex(selected_index_ - 1)
9999 end
100100
101- -- CD-ROM の検出
102- --if true then
103- if false then
104- cdrom_label_:setPosition(Point(8, 8))
105- layer_:push_front(cdrom_label_)
106- end
107-
108101 scheduler_fadein_id_ = scheduler_:insert(first_menu_fadein)
109102 end
110103
111104
112105 first_menu["Execute"] =
113106 function(state)
107+ -- 曲の再生を開始する
108+ if not back_music_:isPlaying() then
109+ back_music_:play(Music_menu_, 1000, BackMusic_Infinity, 1000)
110+ end
111+
114112 -- フェードイン
115113 scheduler_:execute()
116114 if fade_completed_ and (not menu_placed_) then
@@ -120,7 +118,6 @@
120118 end
121119
122120 redraw()
123-
124121 if menu_placed_ then
125122 expandMenu(menu_)
126123 end
@@ -159,7 +156,6 @@
159156
160157 first_menu["Exit"] =
161158 function(state)
162- layer_:remove(cdrom_label_)
163159 layer_:remove(version_label_)
164160 layer_:remove(title_label_)
165161 layer_:remove(menu_)
diff -r 70c36996906a -r f8f13679c152 scripts/kimariji_group.lua
--- a/scripts/kimariji_group.lua Thu Jul 21 06:07:58 2011 +0900
+++ b/scripts/kimariji_group.lua Fri Jul 29 09:38:04 2011 +0900
@@ -1,9 +1,10 @@
11 -- 決まり字のグループ管理
22 --
3--- $Id$
3+-- $Id: kimariji_group.lua,v 43a696b157fd 2010/05/16 02:23:01 Satofumi $
44
55 _G.kimariji_title_ = {}
66 _G.kimariji_group_ = {}
7+
78 local group_index_ = 0
89 local group_id_max_ = 1
910
diff -r 70c36996906a -r f8f13679c152 scripts/kimariji_typing.lua
--- a/scripts/kimariji_typing.lua Thu Jul 21 06:07:58 2011 +0900
+++ b/scripts/kimariji_typing.lua Fri Jul 29 09:38:04 2011 +0900
@@ -1,7 +1,7 @@
11 -- 決まり字の練習
22 --
33 -- Satofumi KAMIMURA
4--- $Id$
4+-- $Id: kimariji_typing.lua,v 3d779acf5d87 2010/05/22 15:22:51 Satofumi $
55
66 require("input_handler")
77 require("display_waka")
@@ -60,16 +60,13 @@
6060 kimariji_typing["Enter"] =
6161 function(state)
6262
63- -- 効果音を再生を中断
64- -- !!!
65-
6663 if state_ == DisplaySubTitle then
6764 -- サブタイトルの作成
6865 state:stateMachine():changeState(display_subtitle)
6966 state_ = DisplayWaka
7067
71- -- サブタイトル用の効果音を再生
72- -- !!!
68+ -- サブタイトル用の曲を再生
69+ back_music_:play(Music_prologue_, 100, 1, 100)
7370
7471 elseif state_ == DisplayWaka then
7572 text_input_:clear()
@@ -78,8 +75,8 @@
7875 typing_data_clear(TypingData_Kimariji)
7976 stop_watch_ = StopWatch()
8077
81- -- 音楽の再生を開始
82- -- !!!
78+ -- 曲の再生を開始する
79+ back_music_:play(Music_typing_, 100, BackMusic_Infinity, 100)
8380 end
8481
8582 start_sec_ = 0.0
@@ -156,6 +153,9 @@
156153 display_waka(waka_id_, 100, true)
157154 display_waka_yomibito(waka_id_, 100)
158155
156+ -- 曲の再生を止める
157+ back_music_:stop(1000)
158+
159159 -- 改行を待つ
160160 require("wait_enter")
161161 state:stateMachine():changeState(wait_enter)
diff -r 70c36996906a -r f8f13679c152 scripts/option_config.lua
--- a/scripts/option_config.lua Thu Jul 21 06:07:58 2011 +0900
+++ b/scripts/option_config.lua Fri Jul 29 09:38:04 2011 +0900
@@ -59,19 +59,18 @@
5959
6060
6161 function load_option_data()
62-
63- is_roman_index_ = _G.is_roman_ and 0 or 1
62+ is_roman_index_ = is_roman_ and 0 or 1
6463 option_input_:setIndex(is_roman_index_)
6564 option_input_:press(is_roman_index_ + 1)
6665
67- is_fullscreen_index_ = _G.is_fullscreen_ and 0 or 1
66+ is_fullscreen_index_ = is_fullscreen_ and 0 or 1
6867 option_screen_:setIndex(is_fullscreen_index_)
6968 option_screen_:press(is_fullscreen_index_ + 1)
7069
71- volume_music_:setIndex(_G.volume_music_)
72- volume_music_:press(_G.volume_music_ + 1)
73- volume_se_:setIndex(_G.volume_se_)
74- volume_se_:press(_G.volume_se_ + 1)
70+ volume_music_:setIndex(volume_music_index_)
71+ volume_music_:press(volume_music_index_ + 1)
72+ volume_se_:setIndex(volume_se_index_)
73+ volume_se_:press(volume_se_index_ + 1)
7574 end
7675
7776
@@ -79,31 +78,30 @@
7978
8079 if option_input_:clickedIndex() ~= is_roman_index_ then
8180 is_roman_index_ = option_input_:clickedIndex()
82- _G.is_roman_ = is_roman_index_ == 0 and true or false
81+ is_roman_ = is_roman_index_ == 0 and true or false
8382 end
8483
8584 if option_screen_:clickedIndex() ~= is_fullscreen_index_ then
8685 is_fullscreen_index_ = option_screen_:clickedIndex()
87- _G.is_fullscreen_ = is_fullscreen_index_ == 0 and true or false
86+ is_fullscreen_ = is_fullscreen_index_ == 0 and true or false
8887
8988 -- ウィンドウ設定を反映させる
90- if screen_:isFullscreen() ~= _G.is_fullscreen_ then
89+ if screen_:isFullscreen() ~= is_fullscreen_ then
9190 screen_:toggleScreen()
9291 end
9392 end
9493
95- if volume_music_:clickedIndex() ~= _G.volume_music_ then
96- _G.volume_music_ = volume_music_:clickedIndex()
97-
98- -- 音量の設定を反映させる
99- -- !!!
94+ -- 曲の音量設定を反映させる
95+ if volume_music_:clickedIndex() ~= volume_music_index_ then
96+ volume_music_index_ = volume_music_:clickedIndex()
97+ back_music_:setVolume(volume_music_index_ * 10)
10098 end
10199
102- if volume_se_:clickedIndex() ~= _G.volume_se_ then
103- _G.volume_se_ = volume_se_:clickedIndex()
104-
105- -- 音量の設定を反映させる
106- -- !!!
100+ -- 効果音の音量設定を反映させる
101+ if volume_se_:clickedIndex() ~= volume_se_index_ then
102+ volume_se_index_ = volume_se_:clickedIndex()
103+ local sound_effect = SoundEffect("")
104+ sound_effect:setMasterVolume(volume_se_index_ * 10)
107105 end
108106 end
109107
diff -r 70c36996906a -r f8f13679c152 scripts/option_save.lua
--- a/scripts/option_save.lua Thu Jul 21 06:07:58 2011 +0900
+++ b/scripts/option_save.lua Fri Jul 29 09:38:04 2011 +0900
@@ -10,8 +10,8 @@
1010
1111 buffer = buffer .. save_item("_G.is_roman_")
1212 buffer = buffer .. save_item("_G.is_fullscreen_")
13- buffer = buffer .. save_item("_G.volume_music_")
14- buffer = buffer .. save_item("_G.volume_se_")
13+ buffer = buffer .. save_item("_G.volume_music_index_")
14+ buffer = buffer .. save_item("_G.volume_se_index_")
1515
1616 save("savedata/option_data.lua", buffer)
1717 end
diff -r 70c36996906a -r f8f13679c152 scripts/practice_menu.lua
--- a/scripts/practice_menu.lua Thu Jul 21 06:07:58 2011 +0900
+++ b/scripts/practice_menu.lua Fri Jul 29 09:38:04 2011 +0900
@@ -1,7 +1,7 @@
11 -- タイピング練習
22 --
33 -- Satofumi KAMIMURA
4--- $Id$
4+-- $Id: practice_menu.lua,v 0f4334d7d817 2011/01/30 22:37:39 Satofumi $
55
66
77 -- state: タイピング練習
@@ -77,8 +77,12 @@
7777
7878 practice_menu["Execute"] =
7979 function(state)
80+ -- 曲の再生を開始する
81+ if not back_music_:isPlaying() then
82+ back_music_:play(Music_menu_, 1000, BackMusic_Infinity, 1000)
83+ end
84+
8085 redraw()
81-
8286 expandMenu(menu_)
8387
8488 -- メニューで選択された状態へ遷移させる
diff -r 70c36996906a -r f8f13679c152 scripts/shimonoku_typing.lua
--- a/scripts/shimonoku_typing.lua Thu Jul 21 06:07:58 2011 +0900
+++ b/scripts/shimonoku_typing.lua Fri Jul 29 09:38:04 2011 +0900
@@ -1,7 +1,7 @@
11 -- 下の句タイピング
22 --
33 -- Satofumi KAMIMURA
4--- $Id$
4+-- $Id: shimonoku_typing.lua,v 3d779acf5d87 2010/05/22 15:22:51 Satofumi $
55
66 -- \todo 和歌の入力後、Enter が押されたら waka_layer_ をフェードアウトさせる
77
@@ -60,16 +60,13 @@
6060
6161 shimonoku_typing["Enter"] =
6262 function(state)
63- -- 効果音を再生を中断
64- -- !!!
65-
6663 if state_ == DisplaySubTitle then
6764 -- サブタイトルの作成
6865 state:stateMachine():changeState(display_subtitle)
6966 state_ = DisplayWaka
7067
71- -- サブタイトル用の効果音を再生
72- -- !!!
68+ -- サブタイトル用の曲を再生
69+ back_music_:play(Music_prologue_, 100, 1, 100)
7370
7471 elseif state_ == DisplayWaka then
7572 text_input_:clear()
@@ -78,8 +75,8 @@
7875 typing_data_clear(TypingData_Shimonoku)
7976 stop_watch_ = StopWatch()
8077
81- -- 音楽の再生を開始
82- -- !!!
78+ -- 曲の再生を開始する
79+ back_music_:play(Music_typing_, 100, BackMusic_Infinity, 100)
8380 end
8481
8582 -- 入力処理の開始
@@ -172,6 +169,9 @@
172169 display_waka(waka_id_, 100, false)
173170 display_waka_yomibito(waka_id_, 100)
174171
172+ -- 曲の再生を止める
173+ back_music_:stop(1000)
174+
175175 -- 改行を待つ
176176 require("wait_enter")
177177 state:stateMachine():changeState(wait_enter)
diff -r 70c36996906a -r f8f13679c152 scripts/startup.lua
--- a/scripts/startup.lua Thu Jul 21 06:07:58 2011 +0900
+++ b/scripts/startup.lua Fri Jul 29 09:38:04 2011 +0900
@@ -13,7 +13,17 @@
1313
1414 _G.YomiageSecond = 12000.0 -- [msec]
1515
16+_G.Music_menu_ = "resources/music_menu.mp3"
17+_G.Music_typing_ = "resources/music_typing.mp3"
18+_G.Music_prologue_ = "resources/prologue.mp3"
19+
20+_G.Sound_input_terminated_ = "resources/input_terminated.ogg"
21+_G.Sound_miss_ = "resources/miss.ogg"
22+_G.Sound_type_ = "resources/type.ogg"
23+
1624 _G.screen_ = nil
25+_G.audio_ = nil
26+_G.back_music_ = nil
1727 _G.layer_manager_ = nil
1828 _G.layer_ = nil
1929 _G.waka_layer_ = nil
@@ -26,8 +36,6 @@
2636 _G.enter_label_ = nil
2737 _G.cursor_ = nil
2838 _G.cursor_label_ = nil
29-_G.cdrom_ = nil
30-_G.cdrom_label_ = nil
3139 _G.font_ = nil
3240 _G.rubi_font_ = nil
3341 _G.cycle_timer_ = nil
@@ -134,16 +142,18 @@
134142
135143 -- スクリーン設定を反映
136144 screen_ = Screen()
137- if (not screen_:isFullscreen()) and _G.is_fullscreen_ then
145+ if (not screen_:isFullscreen()) and is_fullscreen_ then
138146 screen_:toggleScreen()
139147 end
140148
141- -- 音量設定を反映
142- -- !!!
149+ -- 音源まわりの初期化
150+ audio_ = Audio()
151+ back_music_ = BackMusic()
143152
144- -- CD-ROM の検出
145- -- !!! ミュートのときは、検出しない
146- -- !!! 最初のメニューで CD-ROM のアイコンを左上に表示するようにする
153+ -- 音量設定を反映
154+ back_music_:setVolume(volume_music_index_ * 10)
155+ local sound_effect = SoundEffect("")
156+ sound_effect:setMasterVolume(volume_se_index_ * 10)
147157
148158 -- 共通リソースの初期化
149159 layer_manager_ = LayerManager()
@@ -186,10 +196,6 @@
186196 os.exit()
187197 end
188198
189- -- CD-ROM 認識ラベルの作成
190- cdrom_ = ImageSurface("resources/cdrom.png", true)
191- cdrom_label_ = Label(cdrom_)
192-
193199 -- ESC キーの登録
194200 escape_event_ = CallbackEvent()
195201 escape_event_:key(SDLK_ESCAPE, SDL_KEYDOWN, KMOD_NONE, 0)
旧リポジトリブラウザで表示