3日間で短編小説用のゲームエンジンを作成する方法

ある雨の日、サンクトペテルブルクで、UE4での私のプロジェクトは読み込みを停止しました。そのため、私は自分のエンジンを作りたかったのです。 そして、 ある短編小説から、短編小説専用のエンジンを作るようになりました。 もっと知りたいのに、goto、gosub、その他の恐怖を恐れないのであれば、catへようこそ。

KDPV








目次










第1幕

すべては、N話を過ぎた友人私に片和少女を勧めたときに始まりました。 判明したように、App Storeの公式バージョンは、w3bsit3-dns.comの.ipaのみであり、期待されていません。



同じ友人は、私が3か月目にゲームを作成しようとしていることを知って、脱獄せずにKatavaをiPadに移植することを提案しました。 私はこのプログラムを1年半使用しており、その内部プログラミング言語の構文を知っているため(スマートBASICにはXcode用のSDKもあります)、スマートBASICが選択されました。



テキストを除くすべてのゲームファイルを含むアーカイブがすぐにダウンロードされました。 しかし、彼も私も、これが開発の利便性のために彼自身のエンジンの作成につながることを知りませんでした。



Act 2.開発



第2幕



1.テキスト



最初に、フォルダー(スポイラー)を作成しました。

フォルダー
/スプライト

/イベント

/ Bgs

/音楽

/シナリオ

/スクリプト

/スクリプト/ Ren_sB

/スクリプト/ Ren_sB /関数

/ Ui

/ Ui /メイン

/ Vfx



Katawa Shoujo Port.txtファイルは、すべてのスクリプトをロードします。

scenario$ = “Habr” {Scripts/colorcodes.txt} {Scripts/Ren_sB/render.txt}
      
      





colorcodes.txtファイルには、レンダーの名前のRGBカラーが含まれます。たとえば、 静音と彼女の青い選択を取ります。

 data "","107","174","239" dim colors$(1,2) read colors$(color,0)
      
      





基本的な準備が完了しました。テキストを表示するスクリプトを作成できます。 カタワでは、視覚的な短編のように、テキストがフィールドに表示され、このテキストが書かれているキャラクターの名前がテキストの上に書かれています。



speak.txtスクリプトがこれを担当します。



はじめに、load.txtファイルで、スプライトbg-say.png(レプリカのフィールド)とフォントplaytime_cyrillicのロードを登録しました。

 font "Font/playtime_cyrillic2.ttf" load a$ sprite "bg-say" load "UI/bg-say.png" sprite "bg-say" resize 1024,205 sprite "bg-say" at 0,screen_height()-205 sprite "bg-doublespeak" load "UI/bg-doublespeak.png" sprite "bg-doublespeak" resize 1024,205 sprite "bg-doublespeak" at 0,screen_height()-205 sprite "ctc-strip" load "UI/ctc-strip.png" get sprite "ctc_strip" size w,h sprite "ctc_strip" resize w*1.28,h*1.28 sprite "ctc_strip" at screen_width()-w*1.28-15,screen_height()-52 sprite "ctc_strip" delay 0.05
      
      







その後、スクリプトスクリプトで「|」記号をコマンド、チームゴール、セカンダリゴール、アクション、および属性の区切りとして使用することにしました。



表示テキスト:「1 | pers | text」

 1||[, ]
      
      







render.txtファイルはこのコマンドを読み取り、ラベルのみにリダイレクトします

render.txt
 graphics set toolbar off set orientation landscape file "Scenario/"&scenario$&".txt" readline hmm$ count = count+1 end = file_end("Scenario/"&scenario$&".txt") if end = 0 then goto count file "Scenario/"&scenario$&".txt" setpos 0 dim info$(count,5) for l=0 to count-1 file "Scenario/"&scenario$&".txt" readline line$ splite line$ to temp$,n with "|" for m = 0 to n-1 info$(l,m) = temp$(m) next m next l '  ,    ' show: for y = 0 to count-1 if info$(y,0) = "1" then gosub alone ... alone: {Scripts/Ren_sB/Functions/Speak.txt} return
      
      







speak.txt
 sprite "bg-say" show name$ = info$(y,1) text$ = info$(y,2) '     ' for color = 0 to 6 if name$ = colors$(color,0) then r = colors$(color,1) g = colors$(color,2) b = colors$(color,3) endif next color '   ' field 1 text name$ at 20,575 size 600,40 ro field 1 back alpha 0 field 1 font color r/255,g/255,b/255 field 1 font name a$ field 1 font size 28 field 2 text render$ at 20,615 size screen_width()-20,130 ro ml field 2 back alpha 0 field 2 font color 1,1,1 field 2 font size 28 field 2 font name a$ '  ' for k = 0 to len(text$)-1 '     ' gosub 3 render$ = substr$(text$,0,k) field 2 text render$ pause 0.025 next k '    ' sprite "ctc_strip" show ! sprite "ctc_strip" loop gosub 1 sprite "ctc_strip" hide
      
      







1
 1 x1 = touch_x(0) y1 = touch_y(0) if x1 > -1 or y1 > -1 then goto 2 slowdown goto 1 2 x1 = touch_x(0) y1 = touch_y(0) if x1 = -1 or y1 = -1 then return endif slowdown goto 2
      
      







3
 3 x1 = touch_x(0) y1 = touch_y(0) if x1 > -1 or y1 > -1 then tapped = 1 endif if tapped = 1 then if x1 = -1 or y1 = -1 then tapped = 0 if len(text$) = 0 then k = lengthmax - 1 else k = len(text$) - 1 endif return else return endif endif return
      
      







結果:



画像



「しかし、結局のところ、2人のキャラクターがカタワで同時に話すことができます!」これには別のコマンドがあります:「2 | pers1&pers2 | text1&text2」:

2 | Hisao&Lilly |「Hello!」と「Hello!」



render.txtに次の行を追加します。

render.txt
 ... show: ... if info$(y,0) = 2 then gosub together ... together: {Scripts/Ren_sB/Functions/Double_Speak.txt} return
      
      







Double_Speak.txtは次のコマンドを実行します。

Double_Speak.txt
 sprite "bg-doublespeak" show names$ = info$(y,1) '   ' nd = instr(names$,"&") name1$ = substr$(names$,0,nd-1) name2$ = substr$(names$,nd+1,len(names$)-1) texts$ = info$(y,2) td = instr(texts$,"&") text1$ = substr$(texts$,0,td-1) text2$ = substr$(texts$,td+1,len(texts$)-1) '     ' for color = 0 to 6 if name1$ = colors$(color,0) then r1 = colors$(color,1) g1 = colors$(color,2) b1 = colors$(color,3) endif next color for color = 0 to 6 if name2$ = colors$(color,0) then r2 = colors$(color,1) g2 = colors$(color,2) b2 = colors$(color,3) endif next color '  ' field 11 text name1$ at 20,575 size 300,40 ro field 11 back alpha 0 field 11 font color r1/255,g1/255,b1/255 field 11 font name a$ field 11 font size 28 field 12 text name2$ at 535,575 size 300,40 ro field 12 back alpha 0 field 12 font color r2/255,g2/255,b2/255 field 12 font name a$ field 12 font size 28 field 21 text render1$ at 20,615 size screen_width()/2-20,130 ro ml field 21 back alpha 0 field 21 font color 1,1,1 field 21 font size 28 field 21 font name a$ field 22 text render2$ at 535,615 size screen_width()/2-20,130 ro ml field 22 back alpha 0 field 22 font color 1,1,1 field 22 font size 28 field 22 font name a$ '     ' lengthmax = max(len(text1$),len(text2$)) lengthmin = min(len(text1$),len(text2$)) '  ' if len(text1$) = len(text2$) then for k = 0 to lengthmax-1 gosub 3 render1$ = substr$(text1$,0,k) field 21 text render1$ render2$ = substr$(text2$,0,k) field 22 text render2$ pause 0.025 next k endif if len(text1$) > len(text2$) then for k = 0 to lengthmax-1 gosub 3 render1$ = substr$(text1$,0,k) field 21 text render1$ if k < lengthmin then render2$ = substr$(text2$,0,k) field 22 text render2$ endif pause 0.025 next k endif if len(text2$) > len(text1$) then for k = 0 to lengthmax-1 gosub 3 render2$ = substr$(text2$,0,k) field 22 text render2$ if k < lengthmin then render1$ = substr$(text1$,0,k) field 21 text render1$ endif pause 0.025 next k endif '  ' sprite "ctc_strip" show ! sprite "ctc_strip" loop gosub 1 sprite "ctc_strip" hide
      
      









結果:



画像



これで、開発の最初の日が終わり、それで私の記事の最初の部分は終わります。 2番目の部分では、2日目、つまりグラフィック(スプライト、背景、イベント)と音楽を追加します。



記事の最後まで読んでくれたすべての人に感謝します。 次のパートでお会いしましょう!



All Articles