凄く中途半端だけど「パイプドリーム」を再現した

なお,HSP.ソースと素材を公開します.

f:id:enthirt:20170407001347p:plain

 >||

#pack "pipe.png"
#packopt name "pipe dream"
randomize
buffer 1
picload "pipe.png"
screen 0,320,320

*set
tl = 32
curx = 0
cury = 0
imnxt = rnd(7)+1
hand = 0
tips = 0
dir = 0
counter = 1
speed = 320
score = 0
combo = 0
penaltya = 0
penaltyb = 0
tc = 0
dim board ,10,8
dim subboard ,10,8
dim cross ,10,8
repeat 10
C = cnt
repeat 8
board(C,cnt) = 0
subboard(C,cnt) = 0
cross(C,cnt)=0
loop
loop
sx = rnd(8)+1
sy = rnd(6)+1
if (sx+sy<7){
if (rnd(2)=0){
board(sx,sy) = 10
}else{
board(sx,sy) = 11
}
}else{
if (rnd(2)=0){
board(sx,sy) = 8
}else{
board(sx,sy) = 9
}
}
waterx = sx
watery = sy
tips = board(sx,sy)
subboard(sx,sy) = 0
if (tips=8):dir=0;l
if (tips=9):dir=1;u
if (tips=10):dir=2;r
if (tips=11):dir=3;d
dim nxt ,10
repeat 10
nxt(cnt) = rnd(7)+1
loop
gsel 0
gmode 2

*start
stick KEY
if (KEY=32)||(KEY=16):goto *main
redraw 0
color 32,32,32:boxf
color 255,255,255
pos 65,160
mes "PUSH SPACE KEY TO START"
redraw 1
await 16
goto *start

*main
time ++
tc ++
if (time>1500):counter ++
gosub *control
if (counter\speed=0): gosub *water
gosub *draw
await 16
goto *main

*control
stick KEY
if (KEY=1){
if (curx>0):curx--
};l
if (KEY=2){
if (cury>0):cury--
};u
if (KEY=4){
if (curx<9):curx++
};r
if (KEY=8){
if (cury<7):cury++
};d
if (KEY=16)||(KEY=32){
if (board(curx,cury)<8)&&(subboard(curx,cury)<2){
if *1:return
if (board(curx,cury)>0):penaltyb++
board(curx,cury)=imnxt
imnxt = nxt(hand\10)
nxt(hand\10)=rnd(7)+1
hand++
subboard(curx,cury)=1
}
}
if (KEY=64):time=2000:speed = 64
return

*water
tips = board(waterx,watery)
subboard(waterx,watery)++
gosub *comboandpenalty
gosub *compare
gosub *setdir
return

*comboandpenalty
combo = 0
penaltya = 0
repeat 10
C = cnt
repeat 8
if (board(C,cnt)=3):combo++
if (board(C,cnt)=1):penaltya++
loop
loop
return

*setdir
if (tips=3){
if (dir=0):dir=1
if (dir=3):dir=2
}
if (tips=4){
if (dir=0):dir=3
if (dir=1):dir=2
}
if (tips=5){
if (dir=2):dir=1
if (dir=3):dir=0
}
if (tips=6){
if (dir=1):dir=0
if (dir=2):dir=3
}
if (tips=8):dir=0;l
if (tips=9):dir=1;u
if (tips=10):dir=2;r
if (tips=11):dir=3;d
return

*initips
if (ptips=0):rgt=0:lft=0:up=0:dwn=0
if (ptips=1):rgt=1:lft=1:up=0:dwn=0
if (ptips=2):rgt=0:lft=0:up=1:dwn=1
if (ptips=3):rgt=1:lft=0:up=1:dwn=0
if (ptips=4):rgt=1:lft=0:up=0:dwn=1
if (ptips=5):rgt=0:lft=1:up=1:dwn=0
if (ptips=6):rgt=0:lft=1:up=0:dwn=1
if (ptips=7):rgt=1:lft=1:up=1:dwn=1
if (ptips=8):rgt=0:lft=1:up=0:dwn=0
if (ptips=9):rgt=0:lft=0:up=1:dwn=0
if (ptips=10):rgt=1:lft=0:up=0:dwn=0
if (ptips=11):rgt=0:lft=0:up=0:dwn=1
return

*compare
if (tips=1){
if (dir=0){
if (waterx-1>=0){
ptips = board(waterx-1,watery)
}else{
goto *gameover
}
gosub *initips
if (rgt=1){
score+100
waterx--
return
}else{
goto *gameover
}
}else{
if (waterx+1<10){
ptips = board(waterx+1,watery)
}else{
goto *gameover
}
gosub *initips
if (lft=1){
score+100
waterx++
return
}else{
goto *gameover
}
}
}
if (tips=2){
if (dir=1){
if (watery-1>=0){
ptips = board(waterx,watery-1)
}else{
goto *gameover
}
gosub *initips
if (dwn=1){
score+100
watery--
return
}else{
goto *gameover
}
}else{
if (watery+1<8){
ptips = board(waterx,watery+1)
}else{
goto *gameover
}
gosub *initips
if (up=1){
score+100
watery++
return
}else{
goto *gameover
}
}
}
if (tips=3){
if (dir=0){
if (watery-1>=0){
ptips = board(waterx,watery-1)
}else{
goto *gameover
}
gosub *initips
if (dwn=1){
score+100
watery--
return
}else{
goto *gameover
}
}else{
if (waterx+1<10){
ptips = board(waterx+1,watery)
}else{
goto *gameover
}
gosub *initips
if (lft=1){
score+100
waterx++
return
}else{
goto *gameover
}
}
}
if (tips=4){
if (dir=0){
if (watery+1<8){
ptips = board(waterx,watery+1)
}else{
goto *gameover
}
gosub *initips
if (up=1){
score+100
watery++
return
}else{
goto *gameover
}
}else{
if (waterx+1<10){
ptips = board(waterx+1,watery)
}else{
goto *gameover
}
gosub *initips
if (lft=1){
score+100
waterx++
return
}else{
goto *gameover
}
}
}
if (tips=5){
if (dir=2){
if (watery-1>=0){
ptips = board(waterx,watery-1)
}else{
goto *gameover
}
gosub *initips
if (dwn=1){
score+100
watery--
return
}else{
goto *gameover
}
}else{
if (waterx-1>=0){
ptips = board(waterx-1,watery)
}else{
goto *gameover
}
gosub *initips
if (rgt=1){
score+100
waterx--
return
}else{
goto *gameover
}
}
}
if (tips=6){
if (dir=2){
if (watery+1<8){
ptips = board(waterx,watery+1)
}else{
goto *gameover
}
gosub *initips
if (up=1){
score+100
watery++
return
}else{
goto *gameover
}
}else{
if (waterx-1>=0){
ptips = board(waterx-1,watery)
}else{
goto *gameover
}
gosub *initips
if (rgt=1){
score+100
waterx--
return
}else{
goto *gameover
}
}
}
if (tips=7){
if (dir=0){
if (waterx-1>=0){
ptips = board(waterx-1,watery)
}else{
goto *gameover
}
gosub *initips
if (rgt=1){
if (subboard(waterx,watery)<3){
score+100
}else{
score+(combo*combo)*1000
}
waterx--
return
}else{
goto *gameover
}
}
if (dir=1){
if (watery-1>=0){
ptips = board(waterx,watery-1)
}else{
goto *gameover
}
gosub *initips
if (dwn=1){
if (subboard(waterx,watery)<3){
score+100
}else{
score+(combo*combo)*1000
}
cross(waterx,watery)++
watery--
return
}else{
goto *gameover
}
}
if(dir=2){
if (waterx+1<10){
ptips = board(waterx+1,watery)
}else{
goto *gameover
}
gosub *initips
if (lft=1){
if (subboard(waterx,watery)<3){
score+100
}else{
score+(combo*combo)*1000
}
waterx++
return
}else{
goto *gameover
}
}
if(dir=3){
if (watery+1<8){
ptips = board(waterx,watery+1)
}else{
goto *gameover
}
gosub *initips
if (up=1){
if (subboard(waterx,watery)<3){
score+100
}else{
score+(combo*combo)*1000
}
cross(waterx,watery)++
watery++
return
}else{
goto *gameover
}
}
}
if (tips=8){
ptips = board(waterx-1,watery)
gosub *initips
if (rgt=1){
waterx--
return
}else{
goto *gameover
}
}
if (tips=9){
ptips = board(waterx,watery-1)
gosub *initips
if (dwn=1){
watery--
return
}else{
goto *gameover
}
}
if (tips=10){
ptips = board(waterx+1,watery)
gosub *initips
if (lft=1){
waterx++
return
}else{
goto *gameover
}
}
if (tips=11){
ptips = board(waterx,watery+1)
gosub *initips
if (up=1){
watery++
return
}else{
goto *gameover
}
}
return

*draw
redraw 0
color 32,32,32:boxf
repeat 10
pos cnt*tl,tl
gcopy 1,tl*nxt*2:gosub *drawa
if *3:gosub *drawb
return

*drawa
if (counter\10=0):fltm++
if (fltm>32):fltm = 0
if (dir=0){
gcopy 1,board(C,cnt)+(tl-fltm),tl,fltm,tl
}
if (dir=1){
gcopy 1,board(C,cnt),tl+(tl-fltm),tl,fltm
}
if (dir=2){
gcopy 1,board(C,cnt),tl,fltm,tl
}
if (dir=3){
gcopy 1,board(C,cnt),tl,tl,fltm
}
return
*drawb
return
*/
*gameover
color 32,32,32:boxf
color 255,255,255
pos 100,140
mes "POINTS:"+score
pos 100,160
mes "PENALTY:"+(penaltya+penaltyb)
fscore = score - (penaltya+penaltyb)*100
pos 100,180
mes "SCORE:"+ fscore

||<

*1:curx=waterx)&&(cury=watery

*2:hand\10+cnt)\10),64,tl,tl
pos 0,32
gcopy 1,256,64,tl,tl
loop
repeat 10
C = cnt
repeat 8
pos C*tl,64+cnt*tl
if (subboard(C,cnt)<2){
gcopy 1,board(C,cnt)*tl,0,tl,tl
}else: if (subboard(C,cnt)=3){
gcopy 1,288,tl,tl,tl
}else{
if (cross(C,cnt)=0){
gcopy 1,board(C,cnt)*tl,tl,tl,tl
}else{
gcopy 1,256,tl,tl,tl
}
}
if (C=waterx)&&(cnt=watery){
gcopy 1,256,64,tl,tl
}
;: gosub *drawwater
loop
loop
pos curx*tl,64+cury*tl
gcopy 1,tl*imnxt,64,tl,tl
color 255,255,255
pos 0,0
mes "TIME:"+tc/60
pos 100,0
mes "SCORE:"+score
redraw 1
return
/*
*drawwater
if ((board(waterx,watery)<3)||(board(waterx,watery)>6

*3:board(waterx,watery)>2)&&(board(waterx,watery)<7