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();
})();