マTiックス作った


またかよ。はい、またです。
今回はバッファでかく取り過ぎたせいか、実機ではもっさりします。
すっきり動かしたい場合はチューニングが必要ですので気をつけてください。

myApp = {};
myApp.quicktigame2d = require('com.googlecode.quicktigame2d');
Z=[];
S=[];
count=0;
star = "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨワヲン";
for(i=1536;i--;)S[i]=parseInt(Math.random()*1000)%star.length;

// create gameview
myApp.gameView = myApp.quicktigame2d.createGameView();
myApp.gameView.timerType = myApp.quicktigame2d.ENGINE_TIMER_DISPLAYLINK;
myApp.gameView.screen = {width:320, height:480};
myApp.gameView.size.width = 320;
myApp.gameView.size.height = 480;
myApp.gameView.fps = 30;
myApp.scene = myApp.quicktigame2d.createScene();
myApp.gameView.pushScene(myApp.scene);
myApp.dispfps = myApp.quicktigame2d.createTextSprite({
	text:'', 
	fontSize:12, 
	fontFamily:'Mosamosa', 
	width:320, 
	height:20, 
	x:10, 
	y:10
});
myApp.dispfps.color(1, 1, 1);
myApp.scene.add(myApp.dispfps);
myApp.vconsole = [];
for(i=0;i<6;i++){ 
	myApp.vconsole[i] = myApp.quicktigame2d.createTextSprite({text:'', fontSize:10, fontFamily:'Mosamosa', width:320, height:480, x:0, y:(i<3)?0:-80});
	myApp.scene.add(myApp.vconsole[i]);
	myApp.vconsole[i].rotateX((i<3)?70:90);
}
myApp.vconsole[0].color(0.8, 1.0, 0.8);
myApp.vconsole[1].color(0.0, 0.5, 0.0);
myApp.vconsole[2].color(0.0, 0.2, 0.0);
myApp.vconsole[3].color(0.8, 1.0, 0.8);
myApp.vconsole[4].color(0.0, 0.5, 0.0);
myApp.vconsole[5].color(0.0, 0.2, 0.0);

myApp.gameView.addEventListener('onload', function (event) {
	myApp.gameView.start();
});
myApp.gameView.addEventListener('enterframe', function(event) {
	myApp.dispfps.text = "マTiックス FPS:" + Math.floor(1000 / event.delta);

	count--;
	lBuf = ['', '', '', '', '', ''];
	for(i=1536;i--;){
		if (count <= 0) {
			if (i>=32) {
				if (Z[i-32]==16)Z[i]=16;
				Z[i-32]--;
			} else {
				Z[i]=(parseInt(Math.random()*1000)%16==0)?16:0;
			}
			if(Z[i]==16)S[i]=parseInt(Math.random()*1000)%star.length;
		}
		lBuf[0]=((Z[i]==16)?star[S[i]]:' ')+lBuf[0];
		lBuf[1]=((Z[i]>=9&&Z[i]<=15)?star[S[i]]:' ')+lBuf[1];
		lBuf[2]=((Z[i]>=1&&Z[i]<=8)?star[S[i]]:' ')+lBuf[2];
		lBuf[3]=((Z[i]==10)?star[S[i]]:' ')+lBuf[3];
		lBuf[4]=((Z[i]>=9&&Z[i]<=15)?star[S[i]]:' ')+lBuf[4];
		lBuf[5]=((Z[i]>=1&&Z[i]<=8)?star[S[i]]:' ')+lBuf[5];
		if(i%32==0)for(j=0;j<6;j++)lBuf[j]="\n"+lBuf[j];
	}
	for (j=0;j<6;j++) myApp.vconsole[j].text = lBuf[j];
	if (count <= 0) count = 2;
});

(function() {
	Ti.UI.setBackgroundColor('#000');
	var win = Ti.UI.createWindow({});
	win.add(myApp.gameView);
	win.open();
})();

たい☆すた作った


今回もソース超汚い。
テキストスプライトスゲー!ってなればいいと思うよ。

myApp = {};
myApp.quicktigame2d = require('com.googlecode.quicktigame2d');
Z=[];
S=[];
count=0;

// create gameview
myApp.gameView = myApp.quicktigame2d.createGameView();
myApp.gameView.timerType = myApp.quicktigame2d.ENGINE_TIMER_DISPLAYLINK;
myApp.gameView.screen = {width:320, height:480};
myApp.gameView.size.width = 320;
myApp.gameView.size.height = 480;
myApp.gameView.fps = 30;
myApp.scene = myApp.quicktigame2d.createScene();
myApp.gameView.pushScene(myApp.scene);
myApp.dispfps = myApp.quicktigame2d.createTextSprite({
	text:'', 
	fontSize:12, 
	fontFamily:'Mosamosa', 
	width:320, 
	height:20, 
	x:10, 
	y:10
});
myApp.dispfps.color(1, 1, 1);
myApp.scene.add(myApp.dispfps);
myApp.vconsole = [];
for(i=0;i<6;i++){ 
	myApp.vconsole[i] = myApp.quicktigame2d.createTextSprite({text:'', fontSize:20, width:320, height:480, x:0, y:0});
	myApp.scene.add(myApp.vconsole[i]);
}
myApp.vconsole[0].color(1, 1, 0.0);
myApp.vconsole[1].color(1, 1, 0.5);
myApp.vconsole[2].color(1, 1, 1.0);
myApp.vconsole[3].color(1, 1, 1.0);
myApp.vconsole[4].color(1, 1, 0.5);
myApp.vconsole[5].color(1, 1, 0.0);
myApp.vconsole[0].rotateX(80);
myApp.vconsole[1].rotateX(75);
myApp.vconsole[2].rotateX(70);
myApp.vconsole[3].rotateX(90);
myApp.vconsole[4].rotateX(85);
myApp.vconsole[5].rotateX(80);
myApp.vconsole[0].y = -30;
myApp.vconsole[1].y = -15;
myApp.vconsole[2].y =   0;
myApp.vconsole[3].y = -80;
myApp.vconsole[4].y = -65;
myApp.vconsole[5].y = -50;

myApp.gameView.addEventListener('onload', function (event) {
	myApp.gameView.start();
});
myApp.gameView.addEventListener('enterframe', function(event) {
	myApp.dispfps.text = "たい☆すた FPS:" + Math.floor(1000 / event.delta);

	count--;
	lBuf = ['', '', '', '', '', ''];
	star = [". ", " ゚", "* ", " ;", "+ ", "☆", " "];
	for(i=384;i--;){
		if (count <= 0) {
			Z[i]=(i>=16)?Z[i-16]:parseInt(Math.random()*1000)%6;
			S[i]=(i>=16)?S[i-16]:parseInt(Math.random()*1000)%7;
		}
		for(j=0;j<6;j++)lBuf[j]=((Z[i]==j)?star[S[i]]:' ')+lBuf[j];
		if(i%16==0)for(j=0;j<6;j++)lBuf[j]="\n"+lBuf[j];
	}
	for (j=0;j<6;j++) myApp.vconsole[j].text = lBuf[j];
	if (count <= 0) count = 2;
});

(function() {
	Ti.UI.setBackgroundColor('#000');
	var win = Ti.UI.createWindow({});
	win.add(myApp.gameView);
	win.open();
})();

Tiとりす作った


ソース超汚い。
でもapp.jsって名前で保存してビルドすれば動くから多分大丈夫です。

myApp = {};

myApp.quicktigame2d = require('com.googlecode.quicktigame2d');

// 565bytes TETRIS
B=[[-11],[-24],[2],[13],[-13],[-1],[2,-1]];for(i=0;i<7;i++)B[i].push(0,1,-12);h=17;Z=[];for(K=t=P=i=0;i<240;)Z[240+i]=Z[i]=++i%12<2||i>228?S="□":" ";P=s=e=0;

// create gameview
myApp.gameView = myApp.quicktigame2d.createGameView();
myApp.gameView.timerType = myApp.quicktigame2d.ENGINE_TIMER_DISPLAYLINK;
myApp.gameView.screen = {width:320, height:480};
myApp.gameView.size.width = 320;
myApp.gameView.size.height = 480;
myApp.gameView.fps = 30;
myApp.scene = myApp.quicktigame2d.createScene();
myApp.gameView.pushScene(myApp.scene);
myApp.dispfps = myApp.quicktigame2d.createTextSprite({
	text:'', 
	fontSize:12, 
	fontFamily:'Mosamosa', 
	width:320, 
	height:20, 
	x:10, 
	y:10
});
myApp.dispfps.color(1, 1, 1);
myApp.scene.add(myApp.dispfps);
myApp.vconsole = [];
for(i=0;i<20;i++){ 
	myApp.vconsole[i] = myApp.quicktigame2d.createTextSprite({
		text:'', 
		fontSize:20, 
		width:240, 
		height:20, 
		x:40, 
		y:30 + 20 * i
	});
	myApp.vconsole[i].color(1, 1, 1);
	myApp.scene.add(myApp.vconsole[i]);
}
myApp.alert = Ti.UI.createAlertDialog({
	title:'gameover', 
	message:'おかわり?', 
	buttonNames:['うん', 'ううん'], 
	cancel:1
});
myApp.alert.addEventListener('click', function(event) {
	if (event.index != 0) return;
	h=17;for(K=t=P=i=0;i<240;)Z[240+i]=Z[i]=++i%12<2||i>228?S="□":" ";e=0;
});
myApp.gameView.addEventListener('onload', function (event) {
	myApp.gameView.start();
});
myApp.gameView.addEventListener('enterframe', function(event) {
	myApp.dispfps.text = "Tiとりす とくてん:"+P+"てん FPS:" + Math.floor(1000 / event.delta);
	if (e==1)return;
	// 565bytes TETRIS
	E=B[t];if(s>=10){s=0;for(f=i=0;i<4;i++){f+=Z[12+(p=h+E[i])]==S;Z[240+p]=S;}if(f){for(i=0;i<4;i++)Z[h+E[i]]=S;t=++t%7;h=17;}else{h+=12;}}else{for(f=i=0;i<4;i++){Z[240+h+E[i]]=S;}s++;}for(k=1,i=19;i--;){for(j=11;--j&&Z[i*12+j]==S;);if(!j){P+=k++;for(j=++i*12;j>2*12;)Z[j]=Z[j---12];}} 
	// 出力はtextspriteへ
	lBuf = "";
	for(i=240;i--;){
		lBuf = Z[240+i] + lBuf;
		if (i%12==0) {
			myApp.vconsole[Math.floor(i/12)].text = lBuf;
			lBuf = "";
		}
		Z[240+i]=Z[i];
	}
	// gameover
	if (Z[5]==S&&e==0) {
		e=1;
		myApp.alert.show();
	}
});
myApp.startPos = null;
myApp.gameView.addEventListener('touchstart',function(event){
	myApp.startPos = event;
});
myApp.gameView.addEventListener('touchend',function(event){
	f=0;C=[];
	// フリック検出処理 
	if (event.x-myApp.startPos.x>10){d=1;for(i=0;i<4;i++)f+=Z[h+E[i]+d]==S;f?0:h+=d;return;}
	if (event.x-myApp.startPos.x<-10){d=-1;for(i=0;i<4;i++)f+=Z[h+E[i]+d]==S;f?0:h+=d;return;}
	// 565bytes TETRIS
	for(i=0;i<4;i++){p=E[i];v=Math.round(p/12);w=p-v*12;C[i]=w*12-v;if(Z[h+C[i]]==S)f=1;}t*!f?E=B[t]=C:0;
});
(function() {
	Ti.UI.setBackgroundColor('#000');
	var win = Ti.UI.createWindow({});
	win.add(myApp.gameView);
	win.open();
})();

Titanium Mobile でRPG開発進捗124日目


久々の更新になりました。
画面に見えないバグ取りや環境構築がメインです。
以下のとおり。

  • SDKを1.8.2へ乗り換えました
  • 1.8.2乗り換えの動作差分吸収
  • quickTiGame2dの動作差分吸収
  • 攻撃対象最適化ルーチン変更
  • 範囲攻撃ルーチン実装開始


見た目なんにもかわっとらーん!
自宅で会社の資料を作ることが多い期間だったので
ゲーム製作もすすむわけねーよー


いや、ここを乗り越えれば、あとは作るだけな筈なんです。
まだまだTiのセットアップ関連で苦しむことはあるかも。
SDKのバージョンアップって1.9系が来るとまた苦しむのかな...

Titanium Mobile SDK 1.8.1 で実機ビルド通らない


表題の通り。
以下のエラーでビルドが通らず。
解決方法が判明したので下へ下へ。


まずは問題のエラー晒す。

make_function_from_file
    self.compile_js(file_contents)
  File "/Users/ユーザー名/Library/Application Support/Titanium/mobilesdk/osx/1.8.1/iphone/compiler.py", line 476, in compile_js
    self.add_symbol(sym)
  File "/Users/ユーザー名/Library/Application Support/Titanium/mobilesdk/osx/1.8.1/iphone/compiler.py", line 429, in add_symbol
    print "[DEBUG] detected symbol: %s" % api
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py", line 351, in write
    data, consumed = self.encode(object, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 36: ordinal not in range(128)
Command /bin/sh failed with exit code 1


** BUILD FAILED **


The following build commands failed:
	PhaseScriptExecution Pre-Compile build/プロジェクト名.build/Debug-iphoneos/プロジェクト名.build/Script-241EAF36118E30260081A5BE.sh
(1 failure)
EXIT CODE WAS: 65

Exception detected in script:
Traceback (most recent call last):
  File "/Users/ユーザー名/Library/Application Support/Titanium/mobilesdk/osx/1.8.1/iphone/builder.py", line 1432, in main
    execute_xcode("iphoneos%s" % iphone_version,args,False)
  File "/Users/ユーザー名/Library/Application Support/Titanium/mobilesdk/osx/1.8.1/iphone/builder.py", line 1192, in execute_xcode
    output = run.run(args,False,False,o)
  File "/Users/ユーザー名/Library/Application Support/Titanium/mobilesdk/osx/1.8.1/iphone/run.py", line 39, in run
    sys.exit(rc)
SystemExit: 65
 


で、これの原因がPythonのデフォルトエンコーディングのお話らしい。
解決方法は以下のブログから拾いました。感謝。


昼行灯の通い路 - [Titanium Mobile]MacからAndroid実機転送時のエラー
http://blog.hirunokayoiji.net/?p=8


[Python] UnicodeEncodeErrorが発生した場合は、sitecustomize.pyでデフォルトのエンコーディングを指定する。 - SumiTomohikoの日記
http://d.hatena.ne.jp/SumiTomohiko/20070120/1169300624

Titanium Mobile でRPG開発進捗103日目


本日の進捗は以下のとおり。

  • グラフィックを自分のアイコンから変更
  • グラフィックもquickTiGame2d対応


quickTiGame2dはTi.UIに比べて非常にお上品な
動作をしますので、Ti.UIから乗り換える場合は
処理時間やダイナミズムの調整が必要です。


それと現在発生している問題について記載しておきます。
現在Spriteはおおよそ正常動作していて
そろそろ安心してquickTiGame2dが使える
一歩手前まで来ている感じがします。


発生している問題としては、ダンジョンを切り替える際に
Spriteの描画が正常に行われなくなる現象が
実機のみで2回に一回という定期的な状況で発生します。
状況がまったくわからんのでXcodeでログ見てみました。

Failed to make complete framebuffer object 8cd6 
[WARN] QuickTiGame2dSprite: Could not create OpenGL vertex err code=0x506


このあたりが怪しいかなと思っていますが
モジュール使ってるだけだと何が何やらわからん状態です。
助けて〜