2011 · 03 · 02 (Wed) 09:41 ✎
3/2 20:10 ソースを読みやすいように修正、一部処理を修正。
某任(ryのゲームのパク(ryオマージュ作品です。いろいろ追加仕様を考えたりしましたが、シンプルにソース短く簡潔に!っていうのが
Luaridaでの方針なのでシンプルにいきました。
ゲームスタートしたらひたすら右へ強制スクロールしますので、タップして
青い「8」のバロン君を羽ばたかせてください。
バロン君は風船を背中に2つ付けています。
障害物に当たると風船が割れてしまいます。風船がなくなれば下の海(?)へ落ちて死亡です。
単に海へ落ちても死亡です。
動画
------------------------------
-- BaronTrip 反動2011/3 --
------------------------------
w,h = canvas.getviewSize()--画面サイズ取得
fsize = h / 16--キャラクタサイズ
map = {}--画面上の機雷格納用
for i=1 , 16 do
map[i] = {}
end
cnt = 1--スクロール用
x,y = 128,128--バロン君初期位置
yy = 0--落下速度
tflag = 0--押しっぱなし判定用
sc,hsc = 0,0--スコア、ハイスコア
mtk = 0--無敵時間
life = 2--風船の残り
scene = 1--ゲームシーン
function main() --//メイン//
while(true) do
-- Title --
if scene == 1 then
dialog("BaronTrip","TripStart!",1)
scene = 2
-- Game --
elseif scene == 2 then
mapmake()
for i=1,fsize,2 do
cnt = i
canvas.putCls(color(0,0,0))
canvas.putRect(0,h-2,fsize*16,h,color(0,0,255),1)
scroll()
man()
canvas.putflush()
end
sc = sc + 1
if sc > hsc then hsc = sc end
if mtk > 0 then
mtk = mtk - 1
end
-- GameOver --
elseif scene == 3 then
canvas.putflush()
yn = dialog("Game Over!!","Continue?",2)
if yn == 1 then
sc = 0
life = 2
yy = 0
y = 128
scene = 2
mtk = 3
else
system.exit()
end
end
end
end -- //メイン終わり//
function mapmake() -- //ランダムで*を生成//
for i=1,16 do
for j=1,15 do
map[j][i] = map[j+1][i]
end
end
for i=1,16 do
if math.random(0,20) == 0 then
map[16][i] = "*"
else
map[16][i] = nil
end
end
end --
function scroll() -- //画面描画とスクロール//
for i=1,16 do
for j=1,16 do
if (map[j][i] ~= nil) then
canvas.putText(map[j][i],j*fsize-cnt,i*fsize,fsize,color(255,255,255))
end
end
end
canvas.putText( "HI-SCORE=" .. hsc , 16* fsize,fsize*3,fsize,color(255,255,255))
canvas.putText( "SCORE=" .. sc , 16* fsize,fsize*4,fsize,color(255,255,255))
canvas.putText( "BaronTrip" , 16* fsize,fsize,fsize*2,color(255,255,0))
end --
function man() -- //バロン君処理//
tx,ty,b = touch()
if (tflag == 0) and (b ~= 1) and (life > 0)then
yy = yy - 1
tflag = 1
elseif (b == 1)then
tflag = 0
end
yy = yy + 0.05
y = y + yy
if y <= fsize then--天井
y = fsize
yy = 2
end
-- 当たり判定
if mtk == 0 then
for i=1,16 do
for j=3,5 do
if map[j][i] == "*" then
if (x + fsize - 12 > j * fsize - cnt) and (x < j * fsize + fsize - cnt) and (y + fsize - 12 > i * fsize ) and (y - 12 < i * fsize + fsize) then
mtk = 3
life = life - 1
yy = yy + 2
end
end
end
end
end
-- 海に落ちた?
if (y > h) then
scene = 3
end
-- バロン君と風船描画
canvas.putText("8",x,y,fsize,color(0,0,255))
if life == 2 then
canvas.putText("●●",x-12,y-24,fsize,color(255,0,0))
elseif life == 1 then
canvas.putText("●",x,y-24,fsize,color(255,0,0))
end
end --
main()
最終更新日 : 2016-03-27