MacbookとiPod touchを買ってきてにわかにやる気だったのですが、
依頼された仕事はAndroidでした。
死亡フラグみたいなもんだったわけです。
今回作ったのはアンドロイドやろうぜ!by GMO向けゲームでした。
利用規約等を見たところ、特に守秘義務が無かったので、
開発について覚えている限り書いてみようと思います。
アンドロイドやろうぜ!by GMOのゲームは、GoogleのAndroid SDKではなく、
AcrodiaのVIVID Runtimeという物を使います。
詳細については公式ページを参照下さい。
VIVID Runtime SDKはAndroid SDKと違い、C/C++/Objective-Cでの開発が可能です。
これらの言語で書いたソースをgccでコンパイルます。
ネイティブコード実行になるのでゲーム向きと言えるでしょう。
ただ、ARM向けにコンパイルされるので、x86のAndroid端末だと動かないと思います。(未検証)
開発環境
開発を始めるには、VIVID Runtime SDKが必要になります。これは、@GMOゲームセンター デベロッパーサイトにCPとして登録するとダウンロードすることが出来ます。
私が使用したのはバージョン 1.1でした。
これを任意のフォルダに解凍します。
例
C:\vivid_runtime_sdk_1_1
以上で開発環境の構築は完了です。簡単。
プログラム作成
例によってHello work!!プログラムを作ってみましょう。最小限のコードは次の通りです。
| 1 | #include <KD/kd.h> |
|---|---|
| 2 | |
| 3 | KDint kdMain(KDint argc, const KDchar *const * argv) |
| 4 | { |
| 5 | kdLogMessage("Hello work!!"); |
| 6 | return 0; |
| 7 | } |
main.cppとして保存します。
ビルドと実行
ビルドを行うためには設定ファイルを書く必要があります。どのプロジェクトでもだいたい同じだと思うので、まずは下記のサンプルをまるコピしてみてください。
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="Hello work"
ProjectGUID="{329BA7C7-513D-406D-BCC8-D813DCCD497A}"
RootNamespace="Platform"
Keyword="MakeFileProj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="0"
>
<Tool
Name="VCNMakeTool"
BuildCommandLine="C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe vs build "$(InputFilename)" $(ConfigurationName)"
ReBuildCommandLine="C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe vs rebuild "$(InputFilename)" $(ConfigurationName)"
CleanCommandLine="C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe vs clean "$(InputFilename)" $(ConfigurationName)"
Output="hello_work.exe"
PreprocessorDefinitions=""
IncludeSearchPath="C:\vivid_runtime_sdk_1_1\tools\gcc_toolchain\arm-runtime-eabi\usr\include"
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies="KD"
CompileAsManaged=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="0"
>
<Tool
Name="VCNMakeTool"
BuildCommandLine="C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe vs build "$(InputFilename)" $(ConfigurationName)"
ReBuildCommandLine="C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe vs rebuild "$(InputFilename)" $(ConfigurationName)"
CleanCommandLine="C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe vs clean "$(InputFilename)" $(ConfigurationName)"
Output="hello_work.exe"
PreprocessorDefinitions="KD_NDEBUG"
IncludeSearchPath="C:\vivid_runtime_sdk_1_1\tools\gcc_toolchain\arm-runtime-eabi\usr\include"
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies="KD"
CompileAsManaged=""
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File RelativePath=".\main.cpp"></File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>hello_work.vcprojとして保存します。
main.cppとhello_work.vcprojを同じフォルダに置き、
コマンドプロンプトでそのフォルダにcdします。
ビルドは次のコマンドになります。
C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe vs build hello_work.vcproj Debug
実行は次のコマンドになります。
C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe vs debug hello_work.vcproj Debug
実行すると、「Hello Work!!」と表示されるはずです。
(QEMUでエミュレーションしているようです。)
hello_work.vcprojの内容については見覚えのある人も多いと思いますが、
これはVisual Studioのプロジェクトファイルです。
よって、もちろんVisual Studioで開くことが出来ますし、そこからビルドすることも出来ます。
(Visual Studio Express Editionで確認。)
Visual Studio上から実行する場合についてはもう一つ設定ファイルが必要です。
次の内容をhello_work.vcproj.userとして保存します。
<?xml version="1.0" encoding="shift_jis"?> <VisualStudioUserFile ProjectType="Visual C++" Version="9.00" ShowAllFiles="false" > <Configurations> <Configuration Name="Debug|Win32" > <DebugSettings Command="C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe" WorkingDirectory="" CommandArguments="vs debug "$(InputFilename)" $(ConfigurationName)" Attach="false" DebuggerType="3" Remote="1" RemoteMachine="" RemoteCommand="" HttpUrl="" PDBPath="" SQLDebugging="" Environment="" EnvironmentMerge="true" DebuggerFlavor="0" MPIRunCommand="" MPIRunArguments="" MPIRunWorkingDirectory="" ApplicationCommand="" ApplicationArguments="" ShimCommand="" MPIAcceptMode="" MPIAcceptFilter="" /> </Configuration> <Configuration Name="Release|Win32" > <DebugSettings Command="C:\vivid_runtime_sdk_1_1\tools\thrip\thrip.exe" WorkingDirectory="" CommandArguments="vs debug "$(InputFilename)" $(ConfigurationName)" Attach="false" DebuggerType="3" Remote="1" RemoteMachine="" RemoteCommand="" HttpUrl="" PDBPath="" SQLDebugging="" Environment="" EnvironmentMerge="true" DebuggerFlavor="0" MPIRunCommand="" MPIRunArguments="" MPIRunWorkingDirectory="" ApplicationCommand="" ApplicationArguments="" ShimCommand="" MPIAcceptMode="" MPIAcceptFilter="" /> </Configuration> </Configurations> </VisualStudioUserFile>
ビルド(追加情報)
Visual Studioの設定ファイルからだと、設定出来る項目に限界があります。そのため、追加の設定ファイルも用意することになります。
追加設定については、hello_work.vcproj.configファイルで設定します。
内容はこんな感じです。
<?xml version="1.0" encoding="utf-8" ?>
<!-- This is a VIVID Runtime specific configuration file. Please see VIVID Runtime SDK documentation for details.-->
<config>
<!-- Common properties for all configurations. -->
<common>
<!-- Verbose compiler and linker output. -->
<verbose>true</verbose>
<!-- General options. -->
<!-- <warning_level>1</warning_level> -->
<!-- <optimization_level>3</optimization_level> -->
<!-- <include_symbols>false</include_symbols> -->
<!-- <thumb>true</thumb -->
<!-- <interworking>true</interworking -->
<!-- <pic>true</pic> -->
<!-- Determines whether the general options listed above are used. If false, you must supply the needed flags using compiler and linker options. -->
<enable_general_options>true</enable_general_options>
<!-- Determines whether the automatic options depending on the output target type (.a, .so, .exe) are used. If false, you must supply your own options. -->
<enable_automatic_options>true</enable_automatic_options>
<!-- Additional compiler flags passed directly to compiler. -->
<compiler_options></compiler_options>
<!-- Additional compiler flags passed directly to linker. -->
<linker_options></linker_options>
<!-- Postbuild action that points to an .exe or .bat -->
<!--postbuild_action></postbuild_action-->
</common>
<!-- Configuration specific overrides for "release" configuration. You can also add other configuration names here if available in the project. -->
<configuration name="release">
<!-- You can put any of the property values in the common section here as well. -->
</configuration>
<!-- Configuration specific overrides for "debug" configuration. -->
<configuration name="debug">
<!-- You can put any of the property values in the common section here as well. -->
</configuration>
</config>この内容については完全に把握出来ていないので、マニュアルを参照してください。
私が読んでもよくわかりませんでした。
リリース時に使用する設定情報を記載するファイルもあります。
これは、rpkという名前のフォルダを作り、その中にconfig.xmlという名前で配置するようです。
また、この2つのファイルを設定するアプリが用意されています。
コマンドプロンプトから次の様に起動します。
C:\vivid_runtime_sdk_1_1\tools\thrip\config.exe hello_work.vcproj.config rpk\config.xml
最後に
以上が基本的な開発環境設定になります。まとめて見るとそんなに複雑ではないのですが、
初心者がノーヒントの状態から内容を把握するのは大変でした。
あと、Eclipseでも開発出来るそうですが、私はVisual Studio派なので調べませんでした。
Eclipse派は自力で調べてください。