I saw the thread about Tetris on wiremod.com a couple of days ago, and I though "why not make several old hits using wiremod?". So here you are, my attempt to make Snake, enjoy the videos.
Video #1
Video #2
And some images:
Expression 2 source code:
@name Snake
@inputs Act Sc:wirelink Ws A S D Hp Hm Reset Sp Sm St Button
@outputs CL CD Nu NDir Mode In M V N Spd H W Size Stage Pos Dir Posn:array I EatenFood CurFPos LastPos GameO
@trigger all
interval(N)
if(first()|duped())
{
Dir = 1
GameO = 0
N = 500
Size = Sc:readCell(1048572)
H = Sc:readCell(1048572)
W = Sc:readCell(1048572)
Stage = 0
CurFPos = randint(1,H*W)
Pos=H*W/2
}
if(Reset)
{
Stage = 0
reset()
}
if(!Stage)
{
Size += Hp-Hm
N = 700
Sc:writeCell(1048572,32)
Sc:writeCell(1048573,32)
In += (Sm-Sp)*50
In = clamp(In,250,1000)
Spd = (In*-1+1050)
Posn = array()
EatenFood = 0
Mode = !Button
M = 1
Pos = 0
if(!first()&!duped()&!changed(Stage)){
if(St|changed(Act)&Act){Stage = 1 }
}
V = 14
if(changed(Stage)|first()|duped()){
Sc:writeCell(1048574,1)
Sc:writeCell(2+32*V,9000)
Sc:writeCell(3+32*V,9000)
Sc:writeCell(6+32*V,990000)
Sc:writeCell(10+32*V,990000)
Sc:writeCell(15+32*V,900000)
Sc:writeCell(20+32*V,752000)
Sc:writeCell(23+32*V,752000)
Sc:writeCell(26+32*V,9000)
Sc:writeCell(27+32*V,9000)
Sc:writeCell(28+32*V,9000)
Sc:writeCell(29+32*V,9000)
Sc:writeCell(1+32+32*V,9000)
Sc:writeCell(6+32+32*V,990000)
Sc:writeCell(7+32+32*V,990000)
Sc:writeCell(10+32+32*V,990000)
Sc:writeCell(14+32+32*V,900000)
Sc:writeCell(16+32+32*V,900000)
Sc:writeCell(20+32+32*V,752000)
Sc:writeCell(22+32+32*V,752000)
Sc:writeCell(26+32+32*V,9000)
Sc:writeCell(2+64+32*V,9000)
Sc:writeCell(6+64+32*V,990000)
Sc:writeCell(8+64+32*V,990000)
Sc:writeCell(10+64+32*V,990000)
Sc:writeCell(14+64+32*V,900000)
Sc:writeCell(15+64+32*V,900000)
Sc:writeCell(16+64+32*V,900000)
Sc:writeCell(20+64+32*V,752000)
Sc:writeCell(21+64+32*V,752000)
Sc:writeCell(26+64+32*V,9000)
Sc:writeCell(27+64+32*V,9000)
Sc:writeCell(3+96+32*V,9000)
Sc:writeCell(6+96+32*V,990000)
Sc:writeCell(9+96+32*V,990000)
Sc:writeCell(10+96+32*V,990000)
Sc:writeCell(13+96+32*V,900000)
Sc:writeCell(17+96+32*V,900000)
Sc:writeCell(20+96+32*V,752000)
Sc:writeCell(22+96+32*V,752000)
Sc:writeCell(26+96+32*V,9000)
Sc:writeCell(1+128+32*V,9000)
Sc:writeCell(2+128+32*V,9000)
Sc:writeCell(6+128+32*V,990000)
Sc:writeCell(10+128+32*V,990000)
Sc:writeCell(13+128+32*V,900000)
Sc:writeCell(17+128+32*V,900000)
Sc:writeCell(20+128+32*V,752000)
Sc:writeCell(23+128+32*V,752000)
Sc:writeCell(26+128+32*V,9000)
Sc:writeCell(27+128+32*V,9000)
Sc:writeCell(28+128+32*V,9000)
Sc:writeCell(29+128+32*V,9000)
}
}
if(Stage==1){
if(Ws & Dir != H & Dir != -H)
{
Dir = -H
}
elseif(S & Dir != -H & Dir != H)
{
Dir = H
}
elseif(A & Dir != 1 & Dir != -1)
{
Dir = -1
}
elseif(D & Dir != -1 & Dir != 1)
{
Dir = 1
}
if(changed(Stage)){
Sc:writeCell(1048572,Size)
Sc:writeCell(1048573,Size)
H = Sc:readCell(1048572)
W = Sc:readCell(1048572)
CurFPos = randint(1,H*W)
N = In
}
if(clk()){
if(Sc:readCell(Pos+Dir) == 200)
{
Stage = 2
}
Sc:writeCell(1048574,1)
if(!Mode){
if(!(Pos%H) & Dir == -1)
{
Pos+=H
}
if(!((Pos+1)%H) & Dir == 1)
{
Pos -= H
}
Pos += Dir
if(Pos>H*W)
{
Pos -= H*W
}
elseif(Pos < 0)
{
Pos += H*W
}
}
else
{
if(!(Pos%H) & Dir == -1)
{
Stage = 2
}
if(!((Pos+1)%H) & Dir == 1)
{
Stage = 2
}
Pos += Dir
if(Pos>H*W)
{
Stage = 2
}
elseif(Pos < 0)
{
Stage = 2
}
}
if(Pos == CurFPos)
{
EatenFood++
Posn:pushNumber(LastPos)
CurFPos = randint(1,H*W)
}
else
{
Posn:pushNumber(LastPos)
Posn:shift()
}
LastPos = Pos
I = 0
while(I
I++
Sc:writeCell(Posn[I,number],200)
}
Sc:writeCell(CurFPos,990000)
Sc:writeCell(Pos,752000)
}
}
if(clk()&Stage == 2){
if(changed(Stage)){N = 10 NDir = 1}
Sc:writeCell(Nu,900000)
if(NDir == 1){Nu++}
elseif(NDir == H){Nu+=H}
elseif(NDir == -1){Nu--}
elseif(NDir == -H){Nu-=H}
if((Sc:readCell(NDir+Nu)==900000)|(!(Nu%H) & NDir == -1)|(!((Nu+1)%H) & NDir == 1)|(Nu>(H*W)-W & NDir == H)|(Nu
if(CL){reset()}else{CD=1}
}
CL=0
if(CD)
{
if(NDir == 1){NDir = H}
elseif(NDir == H){NDir = -1}
elseif(NDir == -1){NDir = -H}
elseif(NDir == -H){NDir = 1}
CD = 0
CL=1
}
}
0 comments:
Post a Comment