1,想写个贪吃蛇的游戏用的是VC60 有教程 但是遇见这个问题不知道选

就选console控制台程序就可以了。

想写个贪吃蛇的游戏用的是VC60 有教程 但是遇见这个问题不知道选

2,如何用javascript写一个贪吃蛇

哦,我之前写过。一开始也不会写。给你说个思路,你可以用<tr> + <td> 标签来写。<tr> 可以看作地图的 x 轴 <td> 看作 地图的 y 轴,把整个地图想象成一个坐标轴,移动蛇、转弯之类的就简单多了。

如何用javascript写一个贪吃蛇

3,用浏览器编程写入贪吃蛇代码怎么运行

你要在理解的基础上,参考别人的程序的而你完抄了别人的程序,当然是不能用的这个程序用的是30年前的TC写的,其中的#include <graphics.h>是TC特有的,目前的编译器早淘汰这个头文件了
用浏览器编程
浏览器运行再看看别人怎么说的。

用浏览器编程写入贪吃蛇代码怎么运行

4,用VC60写贪吃蛇要怎么操作

错误信息的意思是头文件结尾的地方不应该是结尾.和你编译C程序时如果大括号不匹配等情况下出现此错误是一回事,所以建议针对该头文件仔细查查.你如果新建工程之后不应该选择MFC,因为那个是建立头文件用的,你可以直接选Files选项里的C/C++ Header Files,然后编译时就会自动生成工程。
这里有,我试过了,可以运行http://www.easyx.cn/samples/view.aspx?id=58

5,用vs2012编写贪食蛇

写贪吃蛇,搞得简单点嘛,你就直接在控制台下搞定,看起来简陋点,但是意思到了嘛。先写个控制台类管理控制台,再写个类表示贪吃蛇,再写个类表示食物,流程嘛就是:int main() gameInit();//游戏资源初始化,游戏状态设置 while (1) //这里检测输入,改变游戏状态 switch (game_status) case PLAYING: gameScene(); break; case EXIT: .......; break; case RESTART: ... } } gameOver();//资源清理 return EXIT_SUCCESS;}
图形的话使用curses库就好了

6,在编写贪吃蛇中

这个是C语言中的吧int UP = 0110int DOWN = 0120int LEFT = 0113int RIGHT = 0115其它的一致。
//drawnode():绘画某一结点(蛇身或食物) //---------------------------------------------------------------------- private void drawnode(graphics g,node n) g.fillrect(n.x*nodewidth,n.y*nodeheight,nodewidth-1,nodeheight-1); } //---------------------------------------------------------------------- //updatescore():改变计分牌 //---------------------------------------------------------------------- public void updatescore() string s=score: +snakemodel.score; [page]labelscore.settext(s); } //---------------------------------------------------------------------- //begin():游戏开始,放置贪吃蛇 //---------------------------------------------------------------------- void begin() if(snakemodel==null||!snakemodel.running) snakemodel=new snakemodel(this,canvaswidth/nodewidth, this.canvasheight/nodeheight); (new thread(snakemodel)).start(); } } //---------------------------------------------------------------------- //main():主函数 //---------------------------------------------------------------------- public static void main(string[] args) greedsnake gs=new greedsnake(); } } /************************************************************************** *文件名:snakemodel.java *作者:c.jason *要点分析: *1)数据结构:matrix[][]用来存储地图上面的信息,如果什么也没有设置为false, * 如果有食物或蛇,设置为true;nodearray,一个linkedlist,用来保存蛇的每 * 一节;food用来保存食物的位置;而node类是保存每个位置的信息。 *2)重要函数: * changedirection(int newdirection) ,用来改变蛇前进的方向,而且只是 * 保存头部的前进方向,因为其他的前进方向已经用位置来指明了。 其中newdirection * 必须和原来的direction不是相反方向,所以相反方向的值用了同样的奇偶性。在测试 * 的时候使用了direction%2!=newdirection%2 进行判断。 * moveon(),用来更新蛇的位置,对于当前方向,把头部位置进行相应改变。如果越界, * 结束;否则,检测是否遇到食物(加头部)或身体(结束);如果什么都没有,加上头部, * 去掉尾部。由于用了linkedlist数据结构,省去了相当多的麻烦。 *************************************************************************/ import java.util.*; import javax.swing.*; //---------------------------------------------------------------------- //node:结点类 //---------------------------------------------------------------------- class node int x; int y; node(int x,int y) this.x=x; this.y=y; } } //---------------------------------------------------------------------- //snakemodel:贪吃蛇模型 //---------------------------------------------------------------------- class snakemodel implements runnable greedsnake gs; boolean[][] matrix;// 界面数据保存在数组里 linkedlist nodearray=new linkedlist(); node food; int maxx;//最大宽度 int maxy;//最大长度 int direction=2;//方向 boolean running=false; int timeinterval=200;// 间隔时间(速度) double speedchangerate=0.75;// 速度改变程度 [page]boolean paused=false;// 游戏状态 int score=0; int countmove=0; // up和down是偶数,right和left是奇数 public static final int up=2; public static final int down=4; public static final int left=1; public static final int right=3; //---------------------------------------------------------------------- //greedmodel():初始化界面 //---------------------------------------------------------------------- public snakemodel(greedsnake gs,int maxx,int maxy) this.gs=gs; this.maxx=maxx; this.maxy=maxy; matrix=new boolean[maxx][]; for(int i=0;i<maxx;++i) matrix[i]=new boolean[maxy]; arrays.fill(matrix[i],false);// 没有蛇和食物的地区置false } //初始化贪吃蛇 int initarraylength=maxx>20 ? 10 : maxx/2; for(int i=0;i<initarraylength;++i) int x=maxx/2+i; int y=maxy/2; nodearray.addlast(new node(x,y)); matrix[x][y]=true;// 蛇身处置true } food=createfood(); matrix[food.x][food.y]=true;// 食物处置true } //---------------------------------------------------------------------- //changedirection():改变运动方向 //---------------------------------------------------------------------- public void changedirection(int newdirection) if(direction%2!=newdirection%2)// 避免冲突 direction=newdirection; } } //---------------------------------------------------------------------- //moveon():贪吃蛇运动函数 //----------------------------------------------------------------------

7,怎样用vb编写贪吃蛇游戏

蛇类int 蛇长int 方向int 速度function 移动(遍利蛇长。0读的是方向,其他读前一个的位置,并判断死亡,0碰墙,0碰其他)function 加长(蛇长加一)function 变向(接收键盘上下左右,改变int 方向)function 加速(速度加一)果类int 位置Xint 位置Yfunction 产生果(随机X Y)function 果消失(dimiss原果)流程:产生墙产生蛇产生果接收第一个方向,蛇.移动接收键盘输入,蛇.变向蛇0碰果,1果消失 2蛇.加长 3果生成累计N次,蛇速+1
把代码复制到空窗体中按f5运行即可。 option explicit private withevents timer1 as timer private withevents label1 as label dim gfangxiang as boolean dim hwb as single dim she() as shenti dim x as long, y as long dim zhuangtai(23, 23) as long private type shenti f as long x as long y as long end type private sub form_keydown(keycode as integer, shift as integer) dim c as long if keycode = 27 then end if keycode = 32 then if timer1.enabled = true then timer1.enabled = false label1.visible = true else timer1.enabled = true label1.visible = false end if end if c = ubound(she) if gfangxiang = true then exit sub select case keycode case 37 if she(c).f = 2 then exit sub she(c).f = 0 gfangxiang = true case 38 if she(c).f = 3 then exit sub she(c).f = 1 gfangxiang = true case 39 if she(c).f = 0 then exit sub she(c).f = 2 gfangxiang = true case 40 if she(c).f = 1 then exit sub she(c).f = 3 gfangxiang = true end select end sub private sub form_load() me.autoredraw = true me.backcolor = &hc000& me.fillcolor = 255 me.fillstyle = 0 me.scalewidth = 24 me.scaleheight = 24 me.windowstate = 2 set timer1 = controls.add("vb.timer", "timer1") set label1 = controls.add("vb.label", "label1") label1.autosize = true label1.backstyle = 0 label1 = "暂停" label1.forecolor = rgb(255, 255, 0) label1.fontsize = 50 chushihua end sub private sub form_resize() on error goto 1: with me if .windowstate <> 1 then .cls .scalemode = 3 hwb = .scaleheight / .scalewidth .scalewidth = 24 .scaleheight = 24 label1.move (me.scalewidth - label1.width) / 2, (me.scaleheight - label1.height) / 2 huatu me.line (x, y)-(x + 1, y + 1), rgb(255, 255, 0), bf end if end with 1: end sub private sub timer1_timer() dim c as long, i as long on error goto 2: qingchu c = ubound(she) select case she(c).f case 0 if zhuangtai(she(c).x - 1, she(c).y) = 2 then c = c + 1 redim preserve she(c) she(c).f = she(c - 1).f she(c).x = she(c - 1).x - 1 she(c).y = she(c - 1).y chanshengshiwu goto 1: elseif zhuangtai(she(c).x - 1, she(c).y) = 1 then goto 2: end if case 1 if zhuangtai(she(c).x, she(c).y - 1) = 2 then c = c + 1 redim preserve she(c) she(c).f = she(c - 1).f she(c).x = she(c - 1).x she(c).y = she(c - 1).y - 1 chanshengshiwu goto 1: elseif zhuangtai(she(c).x, she(c).y - 1) = 1 then goto 2: end if case 2 if zhuangtai(she(c).x + 1, she(c).y) = 2 then c = c + 1 redim preserve she(c) she(c).f = she(c - 1).f she(c).x = she(c - 1).x + 1 she(c).y = she(c - 1).y chanshengshiwu goto 1: elseif zhuangtai(she(c).x + 1, she(c).y) = 1 then goto 2: end if case 3 if zhuangtai(she(c).x, she(c).y + 1) = 2 then c = c + 1 redim preserve she(c) she(c).f = she(c - 1).f she(c).x = she(c - 1).x she(c).y = she(c - 1).y + 1 chanshengshiwu goto 1: elseif zhuangtai(she(c).x, she(c).y + 1) = 1 then goto 2: end if end select zhuangtai(she(0).x, she(0).y) = 0 for i = 0 to c select case she(i).f case 0 she(i).x = she(i).x - 1 case 1 she(i).y = she(i).y - 1 case 2 she(i).x = she(i).x + 1 case 3 she(i).y = she(i).y + 1 end select next tiaozheng 1: gfangxiang = false zhuangtai(she(c).x, she(c).y) = 1 huatu exit sub 2: if msgbox("游戏结束,点“是”重新开始游戏,点“否”", vbyesno, "贪吃蛇") = vbyes then chushihua else end end if end sub private sub chushihua() me.cls timer1.enabled = true timer1.interval = 200 erase zhuangtai redim she(2) she(0).f = 2 she(0).x = 9 she(0).y = 11 zhuangtai(9, 11) = 1 she(1).f = 2 she(1).x = 10 she(1).y = 11 zhuangtai(10, 11) = 1 she(2).f = 2 she(2).x = 11 she(2).y = 11 zhuangtai(11, 11) = 1 huatu chanshengshiwu end sub private sub qingchu() dim i as long for i = 0 to ubound(she) me.line (she(i).x, she(i).y)-(she(i).x + 1, she(i).y + 1), me.backcolor, bf next end sub private sub huatu() dim i as long for i = 0 to ubound(she) me.circle (she(i).x + 0.5, she(i).y + 0.5), 0.49, rgb(255, 255, 0), , , hwb next end sub private sub tiaozheng() dim i as long for i = 0 to ubound(she) - 1 she(i).f = she(i + 1).f next end sub private sub chanshengshiwu() randomize timer 1: x = int(rnd * 24) y = int(rnd * 24) if zhuangtai(x, y) > 0 then goto 1: zhuangtai(x, y) = 2 me.line (x, y)-(x + 1, y + 1), rgb(255, 255, 0), bf end sub 应该就是这个了

文章TAG:怎么用浏览器写贪吃蛇手游怎么  浏览  浏览器  
下一篇