鬼触贪吃蛇-Crazy Snake——第一次正式发布
pascal吧
全部回复
仅看楼主
level 12
im_in_world 楼主
自己设计制作的丧心病狂贪吃蛇,关键特点是每一次【有效操作】时才对上一个【有效操作】作出反应,【有效操作】指蛇反应时除了让它【掉头】和【继续直走】之外的操作。
所以说这才是鬼触啊!!!
朋友问我:“这还不得玩疯掉!”
后来又说:“算了节约一下智商不玩了。。”
yun.baidu.com/pcloud/album/info?query_uk=2855560706&album_id=2438472470829129873
2014年04月05日 12点04分 1
level 12
im_in_world 楼主
很多地方做得并不好,还有待改进。比如说GAMEOVER界面会有更多的细节加入的!
2014年04月05日 12点04分 2
level 13
围观
2014年04月05日 12点04分 3
OwO
2014年04月05日 13点04分
level 9
挽一个尊,这么厉害的居然没人来看。。。。
2014年04月06日 07点04分 4
OwO你来了啊
2014年04月06日 07点04分
回复 im_in_world :当然
2014年04月06日 07点04分
level 12
im_in_world 楼主
//核心部分源码公开
procedure TfrmMain.FormKeyPress(Sender: TObject; var Key: char);
begin
if not sOnGame then Exit;
if Key='w' then vNowKey:=tdUp;
if Key='a' then vNowKey:=tdLeft;
if Key='s' then vNowKey:=tdDown;
if Key='d' then vNowKey:=tdRight;
end;
procedure TfrmMain.tmrMainTimer(Sender: TObject);
var
tTail:Longint;
begin
if not sOnGame then Exit;
if KeyAble[vNowKey,vLastKey] then begin
vDir:=vLastKey;
vLastKey:=vNowKey;
end;
vHead.X:=vHead.X+mvdX[vDir];
vHead.Y:=vHead.Y+mvdY[vDir];
if vHead.X>mpWidth then vHead.X:=1;
if vHead.X<1 then vHead.X:=mpWidth;
if vHead.Y>mpHeight then vHead.Y:=1;
if vHead.Y<1 then vHead.Y:=mpHeight;
if (vHead.X in [1..mpWidth])and(vHead.Y in [1..mpHeight]) then begin
if vMap[vHead.Y,vHead.X]=Nothing then
begin
vLeft:=vLeft+vLength-1;
if vLeft>mpHeight*mpWidth then vLeft:=vLeft-mpHeight*mpWidth;
vMap[vSnake[vLeft].Y,vSnake[vLeft].X]:=Nothing;
vBody[vLeft].Hide;
vLeft:=vLeft+1-vLength;
if vLeft<1 then vLeft:=vLeft+mpHeight*mpWidth;
if vBody[vLeft]<>Nil then vBody[vLeft].Picture:=frmMain.imgBody.Picture;
//tTail:=vLeft+vLength-1;
//if tTail>mpHeight*mpWidth then tTail:=tTail-mpHeight*mpWidth;
//if vBody[tTail]<>Nil then vBody[tTail].Picture:=frmMain.imgTail.Picture;
vLeft:=vLeft-1;
if vLeft<1 then vLeft:=vLeft+mpHeight*mpWidth;
vSnake[vLeft]:=vHead;
vMap[vHead.Y,vHead.X]:=SnakeBody;
NewBody(vLeft);
vBody[vLeft].Picture:=frmMain.imgHead.Picture;
end
else if vMap[vHead.Y,vHead.x]=SnakeBody then
begin
tTail:=vLeft+vLength-1;
if tTail>mpHeight*mpWidth then tTail:=tTail-mpHeight*mpWidth;
if (vSnake[tTail].X=vHead.X)and(vSnake[tTail].Y=vHead.Y) then begin
vLeft:=vLeft+vLength-1;
if vLeft>mpHeight*mpWidth then vLeft:=vLeft-mpHeight*mpWidth;
vMap[vSnake[vLeft].Y,vSnake[vLeft].X]:=Nothing;
vBody[vLeft].Hide;
vLeft:=vLeft+1-vLength;
if vLeft<1 then vLeft:=vLeft+mpHeight*mpWidth;
if vBody[vLeft]<>Nil then vBody[vLeft].Picture:=frmMain.imgBody.Picture;
//if vBody[tTail]<>Nil then vBody[tTail].Picture:=frmMain.imgTail.Picture;
vLeft:=vLeft-1;
if vLeft<1 then vLeft:=vLeft+mpHeight*mpWidth;
vSnake[vLeft]:=vHead;
vMap[vHead.Y,vHead.X]:=SnakeBody;
NewBody(vLeft);
vBody[vLeft].Picture:=frmMain.imgHead.Picture;
end else begin
GameOver;
end;
end
else if vMap[vHead.Y,vHead.X]=Food then
begin
if vBody[vLeft]<>Nil then vBody[vLeft].Picture:=frmMain.imgBody.Picture;
vLeft:=vLeft-1;
if vLeft<1 then vLeft:=vLeft+mpHeight*mpWidth;
vLength:=vLength+1;
vSnake[vLeft]:=vHead;
vMap[vHead.Y,vHead.X]:=SnakeBody;
NewBody(vLeft);
vBody[vLeft].Picture:=frmMain.imgHead.Picture;
NewFood;
end
else if vMap[vHead.Y,vHead.X]=Wall then
begin
GameOver;
end;
//Paint;
end;
end;
2014年04月06日 08点04分 7
delphi?
2014年04月06日 08点04分
回复 Fallen_Breath :Lazarus
2014年04月06日 09点04分
无法运行
2014年05月31日 14点05分
回复 岁月晨曦的痛 :这只是一段代码
2014年06月01日 07点06分
level 12
im_in_world 楼主
@EXPsta 求过目
2014年04月06日 08点04分 8
level 13
这么吊居然没人。。初一狗前来挽尊
2014年04月09日 07点04分 9
OwO
2014年04月09日 16点04分
同初一狗握爪
2014年11月25日 15点11分
回复 卡伊哆 :早就不是了
2014年11月25日 20点11分
回复 炽修罗—十月 :好吧没看时间……
2014年11月26日 11点11分
level 15
初一飘过,为了期中还是收藏不玩了。。[吐舌]
2014年04月10日 04点04分 10
OwO
2014年04月10日 13点04分
level 9
wasd无法控制啊。
2014年04月10日 17点04分 11
是这样的,每一个操作的时候才对上一个操作做出反应,最先按一个键,再按下一个时候才动.
2014年04月11日 07点04分
回复 im_in_world :弄不来,太麻烦。
2014年04月15日 23点04分
回复 ax_pokl :OwO所以才叫做鬼触贪吃蛇啊
2014年04月16日 13点04分
level 13
beauti
2014年04月11日 04点04分 12
[太开心](o゜▽゜)o☆
2014年04月11日 07点04分
level 7
牛!
2014年08月17日 01点08分 15
OvO
2014年08月17日 04点08分
level 5
我也是初一啊
2014年11月05日 07点11分 16
w我也是
2014年11月06日 05点11分
初一竟然就学编程了。。帅气。。我们大一才开课。
2014年12月30日 16点12分
level 11
主要图形打印麻烦。。lz怎么做的界面
——看我的小尾巴这才是标准的十五字
2014年11月23日 16点11分 17
直接用的TImage控件,还算是比较轻量级的,绘这几个图都还是挺利索的,但是我们学校的机子跑的时候会有闪烁。。
2014年11月23日 17点11分
回复 im_in_world :刷新的时候用学校的渣机不闪才怪(lp的LCL特性决定的)
2014年11月30日 14点11分
回复 im_in_world :你把默认值调成中文就不闪了——看我现在一发帖就是标准的十五字
2014年11月30日 14点11分
回复 曟_IIIV :OAO原来这样
2014年12月06日 12点12分
level 9
procedure TForm1.STBPaint(Sender: TObject);
begin
inc(FrameCount);
if (Now*86400000>(Old)) then begin
str(FrameCount,FPS);
old:=now*86400000+1000;
FrameCount:=0;
end;
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); { clear the matrix }
glLoadIdentity;
glRotatef(xrotangle, 1, 0, 0);
glRotatef(yrotangle, 0, 1, 0);
glTranslatef(-144-EX,-144-ey,-144-ez);
glEnable(GL_TEXTURE_2D);
glcolor3f(1,1,1);
glClearColor(0.0, 0.5, 1.0,1.0); // sets background color
for x1:=1 to 16 do begin
glTranslatef(16,0,0);
for y1:=1 to 16 do begin
glTranslatef(0,16,0);
for z1:=1 to 16 do begin
glTranslatef(0,0,16);
if chunk[x1,y1,z1].needupdate then begin
glDeleteLists(chunk[x1,y1,z1].renderlist,1);
chunk[x1,y1,z1].renderlist:=glGenlists(1);
glNewList(chunk[x1,y1,z1].renderlist,GL_COMPILE_AND_EXECUTE);
glBindTexture(GL_TEXTURE_2D,Textures);
glBegin(GL_QUADS);
for bx:=1 to 16 do
for by:=1 to 16 do
for bz:=1 to 16 do if chunk[x1,y1,z1].BID[bx,by,bz]>0 then begin
if (bz+1)>16 then
if z1+1>16 then B1:=1 else
B1:=chunk[x1,y1,z1+1].BID[bx,by,1]
else B1:=chunk[x1,y1,z1].BID[bx,by,bz+1];
if (bz-1)<1 then
if z1-1<1 then B2:=1 else
B2:=chunk[x1,y1,z1-1].BID[bx,by,16]
else B2:=chunk[x1,y1,z1].BID[bx,by,bz-1];
if (bx-1)<1 then
if x1-1<1 then B3:=1 else
B3:=chunk[x1-1,y1,z1].BID[16,by,bz]
else B3:=chunk[x1,y1,z1].BID[bx-1,by,bz];
if (bx+1)>16 then
if x1+1>16 then B4:=1 else
B4:=chunk[x1+1,y1,z1].BID[1,by,bz]
else B4:=chunk[x1,y1,z1].BID[bx+1,by,bz];
if (by+1)>16 then
if y1+1>16 then B5:=1 else
B5:=chunk[x1,y1+1,z1].BID[bx,1,bz]
else B5:=chunk[x1,y1,z1].BID[bx,by+1,bz];
if (by-1)<1 then
if y1-1<1 then B6:=1 else
B6:=chunk[x1,y1-1,z1].BID[bx,16,bz]
else B6:=chunk[x1,y1,z1].BID[bx,by-1,bz];
TexS:=Blocktemplate[chunk[x1,y1,z1].BID[bx,by,bz]].Texture;
if assigned(Blocktemplate[chunk[x1,y1,z1].BID[bx,by,bz]].RF) then
Blocktemplate[chunk[x1,y1,z1].BID[bx,by,bz]].RF;
end;
glend();
GLEndList;
chunk[x1,y1,z1].needupdate:=False;
end
else GLcalllist(chunk[x1,y1,z1].renderlist);
end;
glTranslatef(0,0,-256);
end;
glTranslatef(0,-256,0);
end;
gldisable(GL_TEXTURE_2D);
if selected then begin
glcolor3f(1,0,0);
drawborder((scx-1)*16+sex-1,(scy-1)*16+sey-1,(scz-1)*16+sez-1);
end else glcolor3f(1,1,1);
glEnter2D;
glBegin(GL_QUADS);
glVertex3f((STB.Width div 2)-15,(STB.Height div 2)-2,1);
glVertex3f((STB.Width div 2)+15,(STB.Height div 2)-2,1);
glVertex3f((STB.Width div 2)+15,(STB.Height div 2)+2,1);
glVertex3f((STB.Width div 2)-15,(STB.Height div 2)+2,1);
glVertex3f((STB.Width div 2)-2,(STB.Height div 2)-15,1);
glVertex3f((STB.Width div 2)+2,(STB.Height div 2)-15,1);
glVertex3f((STB.Width div 2)+2,(STB.Height div 2)+15,1);
glVertex3f((STB.Width div 2)-2,(STB.Height div 2)+15,1);
glend();
a:=bpos(ex,ey,ez);
L1.Caption:=FORMAT('P[%3d,%3d,%3d][%3d,%3d,%3d]Z%f Y%f FPS:'+FPS,
[a.cx,A.cy,a.cz,a.sx,A.sy,A.sz,XROTANGLE,YROTANGLE]);
glLeave2D;
glFlush();
STB.SwapBuffers;
end;
2014年12月07日 05点12分 19
level 9
rocedure TRC.SameFace;
begin
if BlockTemplate[B1].Transperent then begin
{front face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
end;
if BlockTemplate[B2].Transperent then begin
{Back Face}
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
end;
if BlockTemplate[B3].Transperent then begin
{Left Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
end;
if BlockTemplate[B4].Transperent then begin
{Rbxght Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by-1, bz-1);
end;
if BlockTemplate[B5].Transperent then begin
{Top Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by, bz);
end;
if BlockTemplate[B6].Transperent then begin
{Bottom Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by-1, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
end;
end;
procedure TRC.RounDiff;
begin
if BlockTemplate[B5].Transperent then begin
{Top Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by, bz);
end;
inc(TexS);
if BlockTemplate[B6].Transperent then begin
{Bottom Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by-1, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
end;
inc(TexS);
if BlockTemplate[B1].Transperent then begin
{front face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
end;
if BlockTemplate[B2].Transperent then begin
{Back Face}
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
end;
if BlockTemplate[B3].Transperent then begin
{Left Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
end;
if BlockTemplate[B4].Transperent then begin
{Rbxght Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by-1, bz-1);
end;
end;
procedure TRC.water;
begin
// glcolor4f(1,1,1,0.1);
if B1<>21 then begin
{front face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
end;
if B2<>21 then begin
{Back Face}
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
end;
if B3<>21 then begin
{Left Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
end;
if B4<>21 then begin
{Right Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by, bz);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by-1, bz-1);
end;
if B5<>21 then begin
{Top Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx-1, by, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx-1, by, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx, by, bz);
end;
if B6<>21 then begin
{Bottom Face}
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,3]); glVertex3f( bx-1, by-1, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,3]); glVertex3f( bx, by-1, bz-1);
glTexCoord2f( Texpos[TexS,0], Texpos[TexS,1]); glVertex3f( bx, by-1, bz);
glTexCoord2f( Texpos[TexS,2], Texpos[TexS,1]); glVertex3f( bx-1, by-1, bz);
end;
//glcolor4f(1,1,1,1);
end;
end.
2014年12月07日 05点12分 20
level 9
看明白了吗?
2014年12月07日 05点12分 21
OAO傻了,这真的只是2d绘制么QAQ
2014年12月07日 07点12分
level 9
如果输出汉子的话请用hzk16
2014年12月07日 05点12分 22
level 1
Pascal竟然能做出这么精彩的彩色画面来,一直学C系语言的我禁不住对其膜拜。
2014年12月30日 16点12分 23
1 2 尾页