精華區beta PttNewhand 關於我們 聯絡資訊
※ [本文轉錄自 phsygarden 看板] 作者: assyrian () 看板: phsygarden 標題: 陽春射擊遊戲(assyrian) 時間: Sat Jan 12 01:00:27 2008 按大寫P開始執行 方向鍵是移動 TAB鍵是開火 --#BBSLUA -- Author: assyrian -- Title: 陽春射擊遊戲 -- Version: 1.0 -- Note: code寫的很醜陋= = -- Date: 2008/01/11 -- Interface: 0.115 point = {y,x,char,}; laser = {{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}}; for i=1,18 do for j=1,27,2 do laser[i][j]=''; end end target = {{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}}; for i=1,18 do for j=1,27,2 do target[i][j]=''; end end point.x= 27; point.y= 16; function draw(y,x,char) bbs.move(y,x); bbs.addstr(char); end function user_move(c) if c=='UP' then point.y=point.y-1; if point.y<1 then point.y=1; end end if c=='LEFT' then point.x=point.x-2; if point.x<15 then point.x=15; end end if c=='RIGHT' then point.x=point.x+2; if point.x>39 then point.x=39; end end if c=='DOWN' then point.y=point.y+1; if point.y>17 then point.y=17; end end if c=='' then end end function rand() p=math.random(); p=100*p; p=math.ceil(p); p=2*(1+p%11); return p; end function map1() bbs.color(1,34) bbs.addstr([[ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╚═╗ ╔═╝ ║ ║ ║ ║ ║ ║ ╔═╝ ╚═╗ ║ ║ ║   ║ ║ ║ ║     ║ ║ ║ ╚═╗ ╔═╝ ║ ║   ║ ║ ║ ║ ╔═╝ ╚═╗ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╚═╗ ╔═╝ ║ ║ ║ ║ ║ ║ ╔═╝ ╚═╗ ║ ║ ║ ║ ║ ║ ║ ║ ║ ]]) bbs.color(); end function map2() bbs.color(1,34) bbs.addstr([[ ║ ║ ║ ║ ║ ╚═╗ ╔═╝ ║ ║ ║ ║ ║ ║ ╔═╝ ╚═╗ ║ ║ ║   ║ ║ ║ ║     ║ ║ ║ ╚═╗ ╔═╝ ║ ║   ║ ║ ║ ║ ╔═╝ ╚═╗ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╚═╗ ╔═╝ ║ ║ ║ ║ ║ ║ ╔═╝ ╚═╗ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╚═╗ ╔═╝ ║ ║ ║ ║ ║ ]]) bbs.color(); end r=0; m=8; a={0}; incy=0; incy2=10; obj_counter=0; obj_counter1=0; obj_counter2=0; m1=10; shoot_counter=0; m2=4; m3=20; m4=80; shoot=nil; score=0; while true do bbs.clear(); r=r+1; obj_counter=obj_counter+1; obj_counter1=obj_counter1+1; obj_counter2=obj_counter2+1; if shoot then shoot_counter=shoot_counter+1; end if obj_counter1%m4==0 then for i=1,3 do p=rand(); --draw(2,60,p); if score<100 then target[1][1+p]='★'; elseif score<200 then target[1][1+p]='●'; elseif score<300 then target[1][1+p]='¥'; elseif score<400 then target[1][1+p]='㊣'; else target[1][1+p]='※'; end end end if r%m < m/2 then map1(); else map2(); end if shoot and shoot_counter%m2 == 0 then for i=1,17 do for j=1,27,2 do laser[i][j]=laser[i+1][j]; end end end for i=1,17 do for j=1,27,2 do draw(i,13+j,laser[i][j]); end end if obj_counter2%m3 == 0 then for i=18,2,-1 do for j=1,27,2 do target[i][j]=target[i-1][j]; end end end for i=2,18 do for j=1,27,2 do draw(i-1,14+j,target[i][j]); end end for i=1,27 do target[1][i]=''; end for i=1,17 do for j=1,29,2 do if laser[i][j]=='∥' and (target[i+1][j]=='★' or target[i+1][j]=='●' or target[i+1][j]=='¥' or target[i+1][j]=='㊣' or target[i+1][j]=='※' ) then laser[i][j]=''; target[i+1][j]=''; score=score+10; end end end --draw(10,26,'◆'); draw(point.y ,point.x ,'╩'); draw(20,10,'按TAB發射'); draw(21,10,score); if score>450 then draw(22,10,bbs.userid); draw(22,23,'按Ctrl+C放棄吧,後面沒搞頭了ㄎㄎ'); end --draw(2,66,score); if bbs.kbhit(0) then c=bbs.getch(); if c=='UP' or c=='DOWN' or c=='RIGHT' or c=='LEFT' then user_move(c); else if c=='TAB' then shoot=true; laser[point.y-1][point.x-14]='∥'; end end end end --#BBSLUA -- ※ 發信站: 批踢踢兔(ptt2.cc) ◆ From: 140.112.252.76 -- ※ 發信站: 批踢踢兔(ptt2.cc) ◆ From: 220.138.52.165 assyrian:轉錄至看板 smallme 01/12 01:08 -- ※ 發信站: 批踢踢兔(ptt2.cc) ◆ From: 220.138.52.165
sisay:回報:在最上面那個按TAB會錯誤推 01/12 01:18
FongChen:回報:最左邊掉下來的,在第六行、第八行會變亂碼推 01/12 01:59
chris:子彈會射完…?撞敵機也死不了><推 01/12 02:00
FongChen:好像不是射完,像是卡彈 囧"推 01/12 02:02
FongChen:回報:只要移到最右邊後,就會卡彈推 01/12 02:03
blueshadow27:不過再移到最左邊又能繼續射出子彈了 XD推 01/12 13:16
jackychc:轉錄至某隱形看板 01/14 18:12 ReverbHorn:轉錄至某隱形看板 02/11 18:33