1. 优客号首页
  2. 用户投稿

javascript实现贪吃蛇小游戏

javascript实现贪吃蛇小游戏本文实例为大家分享了js实现贪吃蛇小游戏的具体代码,供大家参考,具体内容如下 Docume</p> </div> <div class="entry-content clearfix"> <p>本文实例为大家分享了js实现贪吃蛇小游戏的具体代码,供大家参考,具体内容如下</p> <p><!DOCTYPE html><html><head> <meta charset=”UTF-8″> <title>Document</title></head><body></body><script> // 贪吃蛇: // 键盘的方向键,控制蛇的方向,碰撞食物,实现增加长度的效果,撞到墙壁或自身,游戏结束 // 分析: // 地图:提供边界 // 食物:随机出现,可以被碰撞(坐标重复) // 蛇:初始的固定长度,移动,改变方向,碰撞食物,碰撞墙,碰撞自己(坐标重复) class Map{ constructor(){ // 提前设定将来的地图的样式数据 this.w = 800; this.h = 400; this.c = “#ccc”; // 执行创建地图方法 this.createEle(); } createEle(){ this.mapEle = document.createElement(“div”); this.mapEle.style.cssText = `width:${this.w}px;height:${this.h}px;background:${this.c};margin:0 auto;position:relative;border:solid 10px black;`; document.body.appendChild(this.mapEle); } } class Food{ constructor(){ // 提前设定将来的食物的样式数据 this.w = 20; this.h = 20; this.c = “red”; this.x = 0; this.y = 0; // 执行创建食物方法 this.createEle(); } createEle(){ this.foodEle = document.createElement(“div”); // 设置left和top时要注意,将地图假设成了20个像素的一个格子,注意位置的换算 this.foodEle.style.cssText = `width:${this.w}px;height:${this.h}px;background:${this.c};position:absolute;left:${this.x * this.w}px;top:${this.y * this.h}px;`; // console.log(m.mapEle); m.mapEle.appendChild(this.foodEle); } randomPos(){ // 随机位置,随机产生的是格子的位置,不是真正的像素 this.x = random(0,(m.w-this.w) / this.w); this.y = random(0,(m.h-this.h) / this.h); // 设置位置时,要换算成像素,然后再生效 this.foodEle.style.left = this.x * this.w + “px”; this.foodEle.style.top = this.y * this.h + “px”; } } // 至少得有多个元素(蛇节)组成 // 每个元素都要有自己的标签,位置,宽高,颜色 // 单个元素,使用对象包含所有信息 // 所有元素怎么办?来个数组,包裹起来 class Snake{ constructor(){ // 1.提前设定将来的蛇节的样式数据 this.w = 20; this.h = 20; // 2.因为蛇由多个设计组成,每个蛇节都有自己的独立信息,所以数据结构设计成如下格式 this.body = [{ ele:null, x:4, y:3, c:randomColor() },{ ele:null, x:3, y:3, c:randomColor() },{ ele:null, x:2, y:3, c:randomColor() }]; // 7-1.提前设置默认方向 this.d = “right”; // 3.开始创建蛇节元素,设置样式 this.createEle(); } createEle(){ // 4.使用循环多次创建,因为有多个蛇节 for(var i=0;i<this.body.length;i++){ // 12.创建之前,需要判断元素是否已经存在,如果已经存在,不需要创建 if(!this.body[i].ele){ this.body[i].ele = document.createElement(“div”); m.mapEle.appendChild(this.body[i].ele); } this.body[i].ele.style.cssText = `width:${this.w}px;height:${this.h}px;background:${this.body[i].c};position:absolute;left:${this.body[i].x * this.w}px;top:${this.body[i].y * this.h}px;`; } // 找到蛇头 this.body[0].ele.innerHTML = “0”; // 5.延迟之后,开始移动 setTimeout(()=>{ this.move(); },300); } move(){ // 6.从最后一个元素向前找前一个元素的坐标,直到第一个 for(var i=this.body.length-1; i>0; i–){ this.body[i].x = this.body[i-1].x; this.body[i].y = this.body[i-1].y; } // 7.第一个元素根据默认方向,决定想哪走 switch(this.d){ case “left”: this.body[0].x -= 1; break; case “right”: this.body[0].x += 1; break; case “top”: this.body[0].y -= 1; break; case “bottom”: this.body[0].y += 1; break; } // 8.移动过程中,判断是否撞到边界,任意一个边界都不行 if(this.body[0].x < 0 || this.body[0].y < 0 || this.body[0].x > ((m.w-this.w) / this.w) || this.body[0].y > ((m.h-this.h) / this.h)){ alert(“撞墙了”); // 利用return的停止,结束程序 return; } // 9.移动过程中,判断是否与食物的坐标重复,如果重复 if(this.body[0].x === f.x && this.body[0].y === f.y){ // 给蛇增加一个蛇节 this.body.push({ ele:null, x:this.body[this.body.length-1].x, y:this.body[this.body.length-1].y, c:randomColor() }) // 刷新食物的坐标 f.randomPos(); } // 10.移动过程中,判断蛇头的坐标是否与某个任意一个蛇节的坐标重复 for(var i=1;i<this.body.length;i++){ if(this.body[0].x == this.body[i].x && this.body[0].y == this.body[i].y){ // 如果重复,撞到自己,结束程序 alert(“撞到自己了”); return; } } // 以上只是在修改坐标,生效了么?设置回去了么? // 走的过程中有可能吃到食物,增加一个蛇节(元素),创建元素 // 11.所以,使用创建蛇节方法,重新设置蛇节的位置以及判断是否需要创建新元素 this.createEle(); } direct(type){ // 14.处理键盘穿件来的code值 // 处理之前要先判断,当前是否按下了相反方向 // 如果是相反方向,直接结束判断,不执行 // 如果不是相反方向,改变初始的默认方向 switch(type){ case 37: if(this.d === “right”) break; this.d = “left”; break; case 38: if(this.d === “bottom”) break; this.d = “top”; break; case 39: if(this.d === “left”) break; this.d = “right”; break; case 40: if(this.d === “top”) break; this.d = “bottom”; break; } } } function random(a,b){ return Math.round(Math.random()*(a-b)+b) } function randomColor(){ return `rgb(${random(0,255)},${random(0,255)},${random(0,255)})` } var m = new Map(); var f = new Food(); // 为了测试,先用计时器,重复执行,看一看随机效果 // setInterval(() => { f.randomPos(); // }, 500); var s = new Snake(); // 13.当按下键盘时,将按下的键盘的code值,传给蛇的专属处理方法 document.onkeydown = function(eve){ var e = eve || window.event; var code = e.keyCode || e.which; s.direct(code); } // 因为后期要做不允许掉头的效果 // 所以,采取当前方法:两个分支处理方向</script></html></p> <p><noscript><img src="https://www.rkxy.com.cn//uploads/bcjs/2022/03/25/11340732410.jpg"></noscript><img class="j-lazy" alt="javascript实现贪吃蛇小游戏" src="https://www.youkehao.org.cn/wp-content/themes/justnews/themer/assets/images/lazy.png" data-original="https://www.rkxy.com.cn//uploads/bcjs/2022/03/25/11340732410.jpg"></p> <p>更多有趣的经典小游戏实现专题,分享给大家:</p> <p>C++经典小游戏汇总</p> <p>python经典小游戏汇总</p> <p>python俄罗斯方块游戏集合</p> <p>JavaScript经典游戏 玩不停</p> <p>java经典小游戏汇总</p> <p>javascript经典小游戏汇总</p> <p>以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p> <h3>想用js做一个贪吃蛇的背景图小格子怎么做</h3> <p>我原来用C语言,借助curses库实现了linux 终端下的贪吃蛇游戏。这个javascript版本的贪吃蛇是http://www.veryhuo.com/game/tanchishe.html 的学习笔记,实现的原理和C版本基本一样。</p> <p>//initialize snakefunction initSnake() { var pointer = randomPointer(len-1, len-1, WIDTH/2); for(var i = 0; i < len; i++) { var x = pointer[0] – i, y = pointer[1]; snake.push([x,y]); carrier[x][y] = “cover”; //标记snake body }}2.用js画出格子用document.createElent()方法创建出table->tr->td, 然后用document.appendChild()方法追加到id为“snakewrap”的元素上://initialize grid function initGrid() { var body = document.getElementsByTagName(“body”)[0]; var table = document.createElement(“table”), tbody = document.createElement(“tbody”) for(var j = 0; j < HEIGHT; j++) {   var col = document.createElement(“tr”);   for(var i = 0; i < WIDTH; i++) {   var row = document.createElement(“td”); gridElems[i][j] = col.appendChild(row);   } tbody.appendChild(col);   } table.appendChild(tbody); document.getElementById(“snakewrap”).appendChild(table);}3.生成食物的随机坐标function randomPointer(startX,startY,endX,endY) { startX = startX || 0; startY = startY || 0; endX = endX || WIDTH; endY = endY || HEIGHT; var p = [], x = Math.floor(Math.random()*(endX – startX)) + startX, y = Math.floor(Math.random()*(endY – startY)) + startY; //如果(x,y)有物体,则重新生成坐标 if(carrier[x][y]) { return randomPointer(startX,startY,endX,endY); } p[0] = x; p[1] = y; return p;}添加新的食物://addObject(“food”)function addObject(name) { var p = randomPointer(); //get random position var x = p[0]; var y = p[1]; carrier[x][y] = name; gridElems[x][y].className = name;}4.方向键按下动作事件监听:允许左上右下这4个按键来改变snake的运动方向,注意,如果方向相反的话,不生效。</p> <h3>用JAVA设计游戏:贪吃蛇游戏</h3> <p>用MVC方式实现的贪吃蛇游戏,共有4个类。运行GreedSnake运行即可。</p> <p>1./* * 程序名称:贪食蛇 * 原作者:BigF * 修改者:algo * 说明:我以前也用C写过这个程序,现在看到BigF用Java写的这个,发现虽然作者自称是Java的初学者, * 但是明显编写程序的素养不错,程序结构写得很清晰,有些细微得地方也写得很简洁,一时兴起之 * 下,我认真解读了这个程序,发现数据和表现分开得很好,而我近日正在学习MVC设计模式, * 因此尝试把程序得结构改了一下,用MVC模式来实现,对源程序得改动不多。 * 我同时也为程序增加了一些自己理解得注释,希望对大家阅读有帮助。</p> <h3>如何用Java语言写一个贪吃蛇游戏</h3> <p>设计游戏,首先就要设计界面。首先看一下我设计的一个界面。</p> <p>游戏区包含“得分信息”和贪吃蛇的游戏区,右边控制区有“开始”“暂停”“停止”按钮,等级选择单选框以及游戏排行榜。</p> <p>所以我们需要定义swing组件,并在类初始化时初始化这些组件,添加组件。因为后面设计游戏的时候,我们要确切知道游戏区的大小,所以这里设置游戏区固定大小值。本来想用布局来更好的管理,但作者对布局也掌握不够,所以就先设置固定大小吧。</p> <p>定义我们的游戏。贪吃蛇游戏其实就是包含很多细小网格,然后蛇在网格中移动。蛇由一连串的网格组成,为了视觉效果,蛇身用蓝色标记,食物用红色标记,背景白色。</p> <p>如第一张图片所示。所以,我们需要定义二维数组,保存网格信息,保存蛇身和食物的位置信息等。初始化时,还需要添加键盘事件控制上下左右移动。</p> <p>食物的位置信息是二维的,所以我简单定义了一个类用来保存二维信息。</p> <p>接着就是实现游戏的功能了。开始,暂停,停止按钮添加事件控制游戏开始。</p> <p>等级按钮定义游戏难度等。</p> <p>开始游戏后,我们定义一个定时器。蛇身按照指定的方向移动,方向是通过初始化时添加的键盘事件,键盘的上下左右按钮来控制。蛇身是连续的位置信息,保存到队列中,所以蛇身的移动就是队首增加一个位置,队尾减少位置,然后重新绘画游戏区就可以了。</p> <p> 在蛇身移动时进一步做吃掉食物、撞墙、撞到自己的处理。这是游戏的主要逻辑。</p> <p>最后,游戏结束我们弹出一个对话框提示是否保存游戏得分。我们制作了排行榜信息,只保留前10名的游戏得分。</p> <p>首先定义了一个实现Comparable接口的游戏得分类,按得分高,时间最早来排序。</p> <p>游戏结束时保存得分信息,看是否进入到排行榜中。而之前在初始化排行榜组件时就会加载游戏排行榜信息。<br /> 通过保存和读取排行榜信息,我们也熟悉一下文件读取操作,还有集合、排序算法的功能。</p> </p> <h3>谁会用java编写“贪吃蛇”小游戏</h3> <p>汗 要程序怎么这么点分啊 哭了 呵呵 不过你还是挺幸运 给你吧连连看的代码(基本算法)加了部分注释 import java.awt.*; import java.awt.event.*; public class lianliankan implements ActionListener { static String s=”no”; //用来纪录点击按钮的信息 int x0=0,y0=0,x=0,y=0,n1=0,n2=0; //用来纪录按钮的位置信息 Frame f,f1; Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b10; //用比较笨的方法添加了 Button b11,b12,b13,b14,b15,b16,b17,b18; //30个按钮来实现游戏界面 Button b19,b20,b21,b22,b23,b24,b25; //可以用数组实现,这是本人 Button b26,b27,b28,b29,b30,bc; //学java时,入门的联系,所以 Button b,ba,br,bt1,bt2; //有些东西很业余!!嘻嘻 Panel p1,p2,p3; TextField t; //用来显示一些随机信息,方法是下面的guli(). Label l; int d[][]={ //用来和界面的按钮建立映射关系 {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0} }; public static void main(String[] args) { lianliankan t=new lianliankan(); t.suiji(); t.go(); } public void actionPerformed(ActionEvent e) //再来一次按钮的响应事件。 { int d[][]={ {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0} }; this.d=d; suiji(); f.setVisible(false); f1.setVisible(false); s=”no”; go(); } public void go()//初始化界面 { l=new Label(“亲爱的玩家,”); f=new Frame(“连连看”); t=new TextField(); p2=new Panel(); p1=new Panel(); p3=new Panel(); bc=new Button(“退出”); br=new Button(“重列”); b=new Button(); b1=new Button(String.valueOf(d[1][1])); b2=new Button(String.valueOf(d[1][2])); b3=new Button(String.valueOf(d[1][3])); b4=new Button(String.valueOf(d[1][4])); b5=new Button(String.valueOf(d[1][5])); b6=new Button(String.valueOf(d[2][1])); b7=new Button(String.valueOf(d[2][2])); b8=new Button(String.valueOf(d[2][3])); b9=new Button(String.valueOf(d[2][4])); b10=new Button(String.valueOf(d[2][5])); b11=new Button(String.valueOf(d[3][1])); b12=new Button(String.valueOf(d[3][2])); b13=new Button(String.valueOf(d[3][3])); b14=new Button(String.valueOf(d[3][4])); b15=new Button(String.valueOf(d[3][5])); b16=new Button(String.valueOf(d[4][1])); b17=new Button(String.valueOf(d[4][2])); b18=new Button(String.valueOf(d[4][3])); b19=new Button(String.valueOf(d[4][4])); b20=new Button(String.valueOf(d[4][5])); b21=new Button(String.valueOf(d[5][1])); b22=new Button(String.valueOf(d[5][2])); b23=new Button(String.valueOf(d[5][3])); b24=new Button(String.valueOf(d[5][4])); b25=new Button(String.valueOf(d[5][5])); b26=new Button(String.valueOf(d[6][1])); b27=new Button(String.valueOf(d[6][2])); b28=new Button(String.valueOf(d[6][3])); b29=new Button(String.valueOf(d[6][4])); b30=new Button(String.valueOf(d[6][5])); p3.setLayout(null); p1.setSize(250,300); p2.setSize(100,40); p3.setSize(300,30); t.setSize(60,30); l.setSize(70,30); p1.setLayout(new GridLayout(6,5)); p1.setBackground(Color.pink); p1.setLocation(100,100); p2.setLocation(0,400); p3.setLocation(50,50); t.setLocation(230,2); l.setLocation(150,2); bc.setLocation(0,40); br.setLocation(0,100); f.add(p1); f.add(p2); f.add(p3); p3.add(l); p3.add(t); p2.add(bc); p2.add(br); p1.add(b1); p1.add(b2); p1.add(b3); p1.add(b4); p1.add(b5); p1.add(b6); p1.add(b7); p1.add(b8); p1.add(b9); p1.add(b10); p1.add(b11); p1.add(b12); p1.add(b13); p1.add(b14); p1.add(b15); p1.add(b16); p1.add(b17); p1.add(b18); p1.add(b19); p1.add(b20); p1.add(b21); p1.add(b22); p1.add(b23); p1.add(b24); p1.add(b25); p1.add(b26); p1.add(b27); p1.add(b28); p1.add(b29); p1.add(b30); f.pack(); f.setBounds(280,100,500,450); f.setResizable(false); f.setVisible(true); bc.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { ex(); } }); br.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { chonglie(); } }); b1.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(1,1,b1); } }); b2.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(1,2,b2); } }); b3.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(1,3,b3); } }); b4.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(1,4,b4); } }); b5.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(1,5,b5); } }); b6.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(2,1,b6); } }); b7.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(2,2,b7); } }); b8.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(2,3,b8); } }); b9.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(2,4,b9); } }); b10.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(2,5,b10); } }); b11.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(3,1,b11); } }); b12.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(3,2,b12); } }); b13.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(3,3,b13); } }); b14.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(3,4,b14); } }); b15.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(3,5,b15); } }); b16.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(4,1,b16); } }); b17.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(4,2,b17); } }); b18.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(4,3,b18); } }); b19.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(4,4,b19); } }); b20.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(4,5,b20); } }); b21.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(5,1,b21); } }); b22.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(5,2,b22); } }); b23.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(5,3,b23); } }); b24.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(5,4,b24); } }); b25.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(5,5,b25); } }); b26.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(6,1,b26); } }); b27.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(6,2,b27); } }); b28.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(6,3,b28); } }); b29.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(6,4,b29); } }); b30.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { wei(6,5,b30); } }); } public void ex() //退出界面,可用diolog来实现有模式的类型,更加符合 { f1=new Frame(“游戏作业”); f1.setLayout(new GridLayout(1,1)); bt1=new Button(“确定退出”); bt2=new Button(“再来一局”); f1.add(bt1); f1.add(bt2); f1.pack(); f1.setBounds(400,250,90,60); f1.setResizable(false); f1.show(); f1.setVisible(true); bt1.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { System.exit(0); } }); bt2.addActionListener(this); } public void suiji() //产生随机数,来填充游戏界面对应的数组的各个位置 { int m,n,k=0,k1,k2,k3; for(m=1;m<=15;m++) { k1=(int)(Math.random()*25+1); for(n=1;n<=2;n++) { k2=(int)(Math.random()*6+1); k3=(int)(Math.random()*5+1); while(d[k2][k3]!=0 && k!=30) { k2=(int)(Math.random()*6+1); k3=(int)(Math.random()*5+1); } this.d[k2][k3]=k1; k++; } } } public void guli() //随机信息 { int l=0; t.setText(“”); l=(int)(Math.random()*10); System.out.println(l); switch(l) { case 1: t.setText(“好!加油!”); break; case 3: t.setText(“你真棒!”); break; case 5: t.setText(“加快速度!”); break; case 6: t.setText(“不错啊!”); break; case 8: t.setText(“加油吧!”); break; case 9: t.setText(“够聪明!”); break; default: break; } } public void chonglie() //重列方法 { int save[],i,j,n=0,k2,k3,k; int d[][]={ {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0} }; save=new int[30]; for(n=0;n<30;n++) save[n]=0; //定义一个数组来保存当前的每个按钮位置上的信息 n=0; for(i=0;i<=6;i++) for(j=0;j<=5;j++) { if(this.d[i][j]!=0) { save[n]=this.d[i][j]; n++; } } n=n-1; this.d=d; while(n>=0) //产生随机位置,放置按钮 { k2=(int)(Math.random()*6+1); k3=(int)(Math.random()*5+1); while(d[k2][k3]!=0) { k2=(int)(Math.random()*6+1); k3=(int)(Math.random()*5+1); } this.d[k2][k3]=save[n]; n–; } f.setVisible(false); s=”no”; //这里一定要将按钮点击信息归为初始 go(); ling(); } public void ling() //将数组中为零的成员对应的按钮消去 { //用按钮类型的数组实现会简化得多, if(d[1][1]==0) b1.setVisible(false); if(d[1][2]==0) b2.setVisible(false); if(d[1][3]==0) b3.setVisible(false); if(d[1][4]==0) b4.setVisible(false); if(d[1][5]==0) b5.setVisible(false); if(d[2][1]==0) b6.setVisible(false); if(d[2][2]==0) b7.setVisible(false); if(d[2][3]==0) b8.setVisible(false); if(d[2][4]==0) b9.setVisible(false); if(d[2][5]==0) b10.setVisible(false); if(d[3][1]==0) b11.setVisible(false); if(d[3][2]==0) b12.setVisible(false); if(d[3][3]==0) b13.setVisible(false); if(d[3][4]==0) b14.setVisible(false); if(d[3][5]==0) b15.setVisible(false); if(d[4][1]==0) b16.setVisible(false); if(d[4][2]==0) b17.setVisible(false); if(d[4][3]==0) b18.setVisible(false); if(d[4][4]==0) b19.setVisible(false); if(d[4][5]==0) b20.setVisible(false); if(d[5][1]==0) b21.setVisible(false); if(d[5][2]==0) b22.setVisible(false); if(d[5][3]==0) b23.setVisible(false); if(d[5][4]==0) b24.setVisible(false); if(d[5][5]==0) b25.setVisible(false); if(d[6][1]==0) b26.setVisible(false); if(d[6][2]==0) b27.setVisible(false); if(d[6][3]==0) b28.setVisible(false); if(d[6][4]==0) b29.setVisible(false); if(d[6][5]==0) b30.setVisible(false); } public void wei(int w1,int w2,Button bz) //判断并纪录每次点击按钮的信息 { //当两次的按钮相同才能消去 if((s.trim()).equals(“no”)) { s=b1.getLabel(); x0=w1; y0=w2; n1=d[x0][y0]; b=bz; x=w1; y=w2; n2=d[x][y]; ba=bz; } else { x0=x; y0=y; n1=d[x0][y0]; b=ba; x=w1; y=w2; n2=d[x][y]; ba=bz; if(n1==n2 && ba!=b) { xiao(); } } } public void xiao() //这里是整个游戏最重要的部分,就是判断两个按钮在信息 { //相同的情况下能不能消去。</p> </p> <h3>各位大侠,本人新手跪拜写贪吃蛇的代码,只需提供具体步骤 编译环境 涉及的函数 无需具体代码!不胜感激呀</h3> <p>我这里有一个之前用js写的贪吃蛇,只要用浏览器就可以看到效果。你新建一个snake.html,然后右击->打开方式->记事本,把下面的代码复制到里面,然后保存好。</p> </p> <h3>求”贪吃蛇”小游戏JAVA源代码一份</h3> <p>贪吃蛇 import java.awt.*; import java.awt.event.*; public class GreedSnake //主类 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub new MyWindow(); } } class MyPanel extends Panel implements KeyListener,Runnable//自定义面板类,继承了键盘和线程接口 { Button snake[]; //定义蛇按钮 int shu=0; //蛇的节数 int food[]; //食物数组 boolean result=true; //判定结果是输 还是赢 Thread thread; //定义线程 static int weix,weiy; //食物位置 boolean t=true; //判定游戏是否结束 int fangxiang=0; //蛇移动方向 int x=0,y=0; //蛇头位置 MyPanel() { setLayout(null); snake=new Button[20]; food=new int [20]; thread=new Thread(this); for(int j=0;j<20;j++) { food[j]=(int)(Math.random()*99);//定义20个随机食物 } weix=(int)(food[0]*0.1)*60; //十位*60为横坐标 weiy=(int)(food[0]%10)*40; //个位*40为纵坐标 for(int i=0;i<20;i++) { snake[i]=new Button(); } add(snake[0]); snake[0].setBackground(Color.black); snake[0].addKeyListener(this); //为蛇头添加键盘监视器 snake[0].setBounds(0,0,10,10); setBackground(Color.cyan); } public void run() //接收线程 { while(t) { if(fangxiang==0)//向右 { try { x+=10; snake[0].setLocation(x, y);//设置蛇头位置 if(x==weix&&y==weiy) //吃到食物 { shu++; weix=(int)(food[shu]*0.1)*60; weiy=(int)(food[shu]%10)*40; repaint(); //重绘下一个食物 add(snake[shu]); //增加蛇节数和位置 snake[shu].setBounds(snake[shu-1].getBounds()); } thread.sleep(100); //睡眠100ms } catch(Exception e){} } else if(fangxiang==1)//向左 { try { x-=10; snake[0].setLocation(x, y); if(x==weix&&y==weiy) { shu++; weix=(int)(food[shu]*0.1)*60; weiy=(int)(food[shu]%10)*40; repaint(); add(snake[shu]); snake[shu].setBounds(snake[shu-1].getBounds()); } thread.sleep(100); } catch(Exception e){} } else if(fangxiang==2)//向上 { try { y-=10; snake[0].setLocation(x, y); if(x==weix&&y==weiy) { shu++; weix=(int)(food[shu]*0.1)*60; weiy=(int)(food[shu]%10)*40; repaint(); add(snake[shu]); snake[shu].setBounds(snake[shu-1].getBounds()); } thread.sleep(100); } catch(Exception e){} } else if(fangxiang==3)//向下 { try { y+=10; snake[0].setLocation(x, y); if(x==weix&&y==weiy) { shu++; weix=(int)(food[shu]*0.1)*60; weiy=(int)(food[shu]%10)*40; repaint(); add(snake[shu]); snake[shu].setBounds(snake[shu-1].getBounds()); } thread.sleep(100); } catch(Exception e){} } int num1=shu; while(num1>1)//判断是否咬自己的尾巴 { if(snake[num1].getBounds().x==snake[0].getBounds().x&&snake[num1].getBounds().y==snake[0].getBounds().y) { t=false; result=false; repaint(); } num1–; } if(x<0||x>=this.getWidth()||y<0||y>=this.getHeight())//判断是否撞墙 { t=false; result=false; repaint(); } int num=shu; while(num>0) //设置蛇节位置 { snake[num].setBounds(snake[num-1].getBounds()); num–; } if(shu==15) //如果蛇节数等于15则胜利 { t=false; result=true; repaint(); } } } public void keyPressed(KeyEvent e) //按下键盘方向键 { if(e.getKeyCode()==KeyEvent.VK_RIGHT)//右键 { if(fangxiang!=1)//如果先前方向不为左 fangxiang=0; } else if(e.getKeyCode()==KeyEvent.VK_LEFT) { if(fangxiang!=0) fangxiang=1; } else if(e.getKeyCode()==KeyEvent.VK_UP) { if(fangxiang!=3) fangxiang=2; } else if(e.getKeyCode()==KeyEvent.VK_DOWN) { if(fangxiang!=2) fangxiang=3; } } public void keyTyped(KeyEvent e) { } public void keyReleased(KeyEvent e) { } public void paint(Graphics g) //在面板上绘图 { int x1=this.getWidth()-1; int y1=this.getHeight()-1; g.setColor(Color.red); g.fillOval(weix, weiy, 10, 10);//食物 g.drawRect(0, 0, x1, y1); //墙 if(t==false&&result==false) g.drawString(“GAME OVER!”, 250, 200);//输出游戏失败 else if(t==false&&result==true) g.drawString(“YOU WIN!”, 250, 200);//输出游戏成功 } } class MyWindow extends Frame implements ActionListener//自定义窗口类 { MyPanel my; Button btn; Panel panel; MyWindow() { super(“GreedSnake”); my=new MyPanel(); btn=new Button(“begin”); panel=new Panel(); btn.addActionListener(this); panel.add(new Label(“begin后请按Tab键选定蛇”)); panel.add(btn); panel.add(new Label(“按上下左右键控制蛇行动”)); add(panel,BorderLayout.NORTH); add(my,BorderLayout.CENTER); setBounds(100,100,610,500); setVisible(true); validate(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public void actionPerformed(ActionEvent e)//按下begin按钮 { if(e.getSource()==btn) { try { my.thread.start(); //开始线程 my.validate(); } catch(Exception ee){} } } }</p> <div class="entry-copyright"><p>本文来自互联网用户投稿,该文观点仅代表作者本人,不代表优客号立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:https://www.youkehao.org.cn/article/64275.html</p> 如若内容造成侵权/违法违规/事实不符,请联系优客号进行投诉反馈,一经查实,立即删除!</div> </div> <div class="entry-footer"> <div class="entry-tag"></div> <div class="entry-action"> <div class="btn-zan" data-id="64275"><i class="fa fa-thumbs-up"></i> 赞 <span class="entry-action-num">(0)</span></div> </div> <div class="entry-bar"> <div class="entry-bar-inner clearfix"> <div class="author pull-left"> <a data-user="3" target="_blank" href="https://www.youkehao.org.cn/article/author" class="avatar"> <img alt='优客号' src='//www.youkehao.org.cn/wp-content/uploads/2022/04/e17ccc4ef1ae610a9b2744363f74e556.png' class='avatar avatar-60 photo' height='60' width='60' /> 优客号 </a> <span class="author-title">认证作者</span> </div> <div class="info pull-right"> <div class="info-item meta"> <a class="meta-item j-heart" href="javascript:;" data-id="64275"><i class="fa fa-heart"></i> <span class="data">0</span></a> <a class="meta-item" href="#comments"><i class="fa fa-comments"></i> <span class="data">0</span></a> </div> <div class="info-item share"> <a class="meta-item mobile j-mobile-share" href="javascript:;" data-id="64275"><i class="fa fa-share-alt"></i> 生成海报</a> <a class="meta-item wechat" href="javascript:;"> <i class="fa fa-wechat"></i> <span class="wx-wrap"> <span class="j-qrcode" data-text="https://www.youkehao.org.cn/article/64275.html"></span> <span>扫码分享到微信</span> </span> </a> <a class="meta-item weibo" href="http://service.weibo.com/share/share.php?url=https%3A%2F%2Fwww.youkehao.org.cn%2Farticle%2F64275.html&title=javascript%E5%AE%9E%E7%8E%B0%E8%B4%AA%E5%90%83%E8%9B%87%E5%B0%8F%E6%B8%B8%E6%88%8F&pic=https%3A%2F%2Fwww.youkehao.org.cn%2Fwp-content%2Fuploads%2F2022%2F11%2F11340732410-1.jpg&searchPic=true" target="_blank" rel="nofollow"><i class="fa fa-weibo"></i></a> <a class="meta-item qq" href="https://connect.qq.com/widget/shareqq/index.html?url=https%3A%2F%2Fwww.youkehao.org.cn%2Farticle%2F64275.html&title=javascript%E5%AE%9E%E7%8E%B0%E8%B4%AA%E5%90%83%E8%9B%87%E5%B0%8F%E6%B8%B8%E6%88%8F&pics=https%3A%2F%2Fwww.youkehao.org.cn%2Fwp-content%2Fuploads%2F2022%2F11%2F11340732410-1.jpg" target="_blank" rel="nofollow"><i class="fa fa-qq"></i></a> </div> <div class="info-item act"> <a href="javascript:;" id="j-reading"><i class="fa fa-file-text"></i></a> </div> </div> </div> </div> <div class="entry-page"> <div class="entry-page-prev" style="background-image: url();"> <a href="https://www.youkehao.org.cn/article/64274.html" title="Js图片点击切换轮播实现代码"> <span>Js图片点击切换轮播实现代码</span> </a> <div class="entry-page-info"> <span class="pull-left">« 上一篇</span> <span class="pull-right">2022年11月10日 12:02:01</span> </div> </div> <div class="entry-page-next" style="background-image: url(https://www.youkehao.org.cn/wp-content/uploads/2022/11/11340538680-1-480x300.jpg);"> <a href="https://www.youkehao.org.cn/article/64277.html" title="JS实现audio音频剪裁剪切复制播放与上传(步骤详解)"> <span>JS实现audio音频剪裁剪切复制播放与上传(步骤详解)</span> </a> <div class="entry-page-info"> <span class="pull-right">下一篇 »</span> <span class="pull-left">2022年11月10日 12:03:06</span> </div> </div> </div> <h3 class="entry-related-title">相关推荐</h3><ul class="entry-related-img clearfix cols-3 post-loop post-loop-image"><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/79585.html" title="理想L9“强敌”!法拉利首款SUV中国上市:差点就到500万" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/22105053560-480x300.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="理想L9“强敌”!法拉利首款SUV中国上市:差点就到500万" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/79585.html" title="理想L9“强敌”!法拉利首款SUV中国上市:差点就到500万" target="_blank"> 理想L9“强敌”!法拉利首款SUV中国上市:差点就到500万 </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月15日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/92811.html" title="如何在闲鱼卖货赚钱之选品那些事:实物类+虚拟类" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/17513699020-480x300.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="如何在闲鱼卖货赚钱之选品那些事:实物类+虚拟类" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/92811.html" title="如何在闲鱼卖货赚钱之选品那些事:实物类+虚拟类" target="_blank"> 如何在闲鱼卖货赚钱之选品那些事:实物类+虚拟类 </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月17日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/102713.html" title="angular.js – angular做点击购买时的遮罩层" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/13493922540-480x300.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="angular.js - angular做点击购买时的遮罩层" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/102713.html" title="angular.js – angular做点击购买时的遮罩层" target="_blank"> angular.js – angular做点击购买时的遮罩层 </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月19日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/104036.html" title="重磅 | 抖音独立电商app—抖音盒子正式上线!" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/00213025880-480x300.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="重磅 | 抖音独立电商app—抖音盒子正式上线!" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/104036.html" title="重磅 | 抖音独立电商app—抖音盒子正式上线!" target="_blank"> 重磅 | 抖音独立电商app—抖音盒子正式上线! </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月19日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/67005.html" title="MYSQL数据库GTID实现主从复制实现(超级方便)" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/03194098100-480x300.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="MYSQL数据库GTID实现主从复制实现(超级方便)" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/67005.html" title="MYSQL数据库GTID实现主从复制实现(超级方便)" target="_blank"> MYSQL数据库GTID实现主从复制实现(超级方便) </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月11日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/63675.html" title="IDEA maven依赖错误中包下面红色波浪线" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/210206630-2-480x300.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="IDEA maven依赖错误中包下面红色波浪线" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/63675.html" title="IDEA maven依赖错误中包下面红色波浪线" target="_blank"> IDEA maven依赖错误中包下面红色波浪线 </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月10日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/105052.html" title="javascript – 这里的这个函数是干嘛用的?" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/09140186020-480x300.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="javascript - 这里的这个函数是干嘛用的?" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/105052.html" title="javascript – 这里的这个函数是干嘛用的?" target="_blank"> javascript – 这里的这个函数是干嘛用的? </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月20日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/386.html" title="查酒驾逮到教育局副局长?官方回应:假消息,两人只是长得像" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/04/bb5c0342eb19404e9aedebbc31e57065-480x300.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="查酒驾逮到教育局副局长?官方回应:假消息,两人只是长得像" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/386.html" title="查酒驾逮到教育局副局长?官方回应:假消息,两人只是长得像" target="_blank"> 查酒驾逮到教育局副局长?官方回应:假消息,两人只是长得像 </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年4月23日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/60271.html" title="js实现小星星游戏" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/11461467580-480x300.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="js实现小星星游戏" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/60271.html" title="js实现小星星游戏" target="_blank"> js实现小星星游戏 </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月9日</span> <span class="item-meta-right"> </span> </div> </li><li class="item"> <div class="item-img"> <a class="item-thumb" href="https://www.youkehao.org.cn/article/42174.html" title="Python+redis通过限流保护高并发系统" target="_blank"> <img width="480" height="300" src="https://www.youkehao.org.cn/wp-content/uploads/2022/11/17450390710-480x300.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Python+redis通过限流保护高并发系统" /> </a> <a class="item-category" href="https://www.youkehao.org.cn/tougao" target="_blank">用户投稿</a> </div> <h2 class="item-title"> <a href="https://www.youkehao.org.cn/article/42174.html" title="Python+redis通过限流保护高并发系统" target="_blank"> Python+redis通过限流保护高并发系统 </a> </h2> <div class="item-meta"> <span class="item-meta-left">2022年11月2日</span> <span class="item-meta-right"> </span> </div> </li></ul> </div> <div id="comments" class="entry-comments"> <div id="respond" class="comment-respond"> <h3 id="reply-title" class="comment-reply-title">发表评论 <small><a rel="nofollow" id="cancel-comment-reply-link" href="/article/64275.html#respond" style="display:none;">取消回复</a></small></h3><div class="comment-form"><div class="comment-must-login">请登录后评论...</div><div class="form-submit"><div class="form-submit-text pull-left"><a href="https://www.youkehao.org.cn/lg">登录</a>后才能评论</div> <input name="submit" type="submit" id="must-submit" class="submit" value="发表"></div></div> </div><!-- #respond --> </div><!-- .comments-area --> </div> </article> </div> <aside class="sidebar"> <div id="wpcom-profile-2" class="widget widget_profile"><div class="profile-cover"><img src="//www.youkehao.org.cn/wp-content/themes/justnews/themer/assets/images/lazy.png" alt="优客号"></div> <div class="avatar-wrap"> <a target="_blank" href="https://www.youkehao.org.cn/article/author" class="avatar-link"><img alt='优客号' src='//www.youkehao.org.cn/wp-content/uploads/2022/04/e17ccc4ef1ae610a9b2744363f74e556.png' class='avatar avatar-120 photo' height='120' width='120' /></a></div> <div class="profile-info"> <p><span class="author-name">优客号</span><span class="author-group">认证作者</span></p> <p class="author-description"></p> </div> <div class="profile-posts"> <h3 class="widget-title"><span>最近文章</span></h3> <ul> <li><a href="https://www.youkehao.org.cn/article/140782.html" title="好文案,会双关">好文案,会双关</a></li> <li><a href="https://www.youkehao.org.cn/article/140781.html" title="文案里,那些春、夏、秋、冬。">文案里,那些春、夏、秋、冬。</a></li> <li><a href="https://www.youkehao.org.cn/article/140780.html" title="宿言:12个促销绝招儿,给你的滞销品来一针“强心剂”!">宿言:12个促销绝招儿,给你的滞销品来一针“强心剂”!</a></li> <li><a href="https://www.youkehao.org.cn/article/140779.html" title="2020年度十大文案来了!">2020年度十大文案来了!</a></li> <li><a href="https://www.youkehao.org.cn/article/140778.html" title="好的文案,要以细节为切入点。">好的文案,要以细节为切入点。</a></li> </ul> </div> </div><div id="wpcom-post-thumb-2" class="widget widget_post_thumb"><h3 class="widget-title"><span>读者推荐</span></h3> <ul> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140782.html" title="好文案,会双关">好文案,会双关</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140781.html" title="文案里,那些春、夏、秋、冬。">文案里,那些春、夏、秋、冬。</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140780.html" title="宿言:12个促销绝招儿,给你的滞销品来一针“强心剂”!">宿言:12个促销绝招儿,给你的滞销品来一针“强心剂”!</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140779.html" title="2020年度十大文案来了!">2020年度十大文案来了!</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140778.html" title="好的文案,要以细节为切入点。">好的文案,要以细节为切入点。</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140777.html" title="写文案没灵感、脑子空写不出,怎么办?">写文案没灵感、脑子空写不出,怎么办?</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140776.html" title="“在我眼里,你会发光”,OPPO微电影太好哭了!">“在我眼里,你会发光”,OPPO微电影太好哭了!</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140775.html" title="20句圣诞节热点文案,98%手工原创">20句圣诞节热点文案,98%手工原创</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140774.html" title="设计师,这样过圣诞?">设计师,这样过圣诞?</a></p> <p class="item-date">2023年1月9日</p> </div> </li> <li class="item"> <div class="item-content" style="margin-left: 0;"> <p class="item-title"><a href="https://www.youkehao.org.cn/article/140773.html" title="写文案如何才能一稿通过?">写文案如何才能一稿通过?</a></p> <p class="item-date">2023年1月9日</p> </div> </li> </ul> </div> </aside> </div> <div class="modal" id="login-modal"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">请登录</h4> </div> <div class="modal-body login-modal-body"> <p>您还未登录,请登录后再进行相关操作!</p> <div class="login-btn"> <a class="btn btn-login" href="https://www.youkehao.org.cn/lg">登 录</a> <a class="btn btn-register" href="https://www.youkehao.org.cn/zc">注 册</a> </div> </div> </div> </div> </div> </div> <footer class="footer"> <div class="container"> <div class="clearfix"> <div class="footer-col footer-col-copy"> <ul class="footer-nav hidden-xs"><li id="menu-item-223" class="menu-item menu-item-223"><a href="https://www.youkehao.org.cn/sample-page">用户协议</a></li> </ul> <div class="copyright"> <p>Copyright © 2022 <a href="https://www.youkehao.org.cn">优客号</a> 版权所有 <a href="https://beian.miit.gov.cn">湘ICP备14001203号</a></p> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?8cea8cea892f77b382d99b47229d96b3"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </div> </div> <div class="footer-col footer-col-sns"> <div class="footer-sns"> </div> </div> </div> </div> </footer> <div class="action" style="top:50%;"> <div class="a-box gotop" id="j-top" style="display: none;"></div> </div> <style>.footer{padding-bottom: 20px;}</style><script type='text/javascript'> /* <![CDATA[ */ var _wpcom_js = {"webp":"","ajaxurl":"https:\/\/www.youkehao.org.cn\/wp-admin\/admin-ajax.php","theme_url":"https:\/\/www.youkehao.org.cn\/wp-content\/themes\/justnews","slide_speed":"5000","lightbox":"1","video_height":"482","errors":{"require":"\u4e0d\u80fd\u4e3a\u7a7a","email":"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u7535\u5b50\u90ae\u7bb1","pls_enter":"\u8bf7\u8f93\u5165","password":"\u5bc6\u7801\u5fc5\u987b\u4e3a6~32\u4e2a\u5b57\u7b26","passcheck":"\u4e24\u6b21\u5bc6\u7801\u8f93\u5165\u4e0d\u4e00\u81f4","phone":"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u624b\u673a\u53f7\u7801","sms_code":"\u9a8c\u8bc1\u7801\u9519\u8bef","captcha_verify":"\u8bf7\u70b9\u51fb\u6309\u94ae\u8fdb\u884c\u9a8c\u8bc1","captcha_fail":"\u70b9\u51fb\u9a8c\u8bc1\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5","nonce":"\u968f\u673a\u6570\u6821\u9a8c\u5931\u8d25","req_error":"\u8bf7\u6c42\u5931\u8d25"}}; /* ]]> */ </script> <script type='text/javascript' src='https://www.youkehao.org.cn/wp-content/themes/justnews/js/main.js?ver=5.2.3'></script> <script type='text/javascript' src='https://www.youkehao.org.cn/wp-includes/js/comment-reply.min.js?ver=5.4.2'></script> <script type='text/javascript' src='https://www.youkehao.org.cn/wp-content/themes/justnews/js/wp-embed.js?ver=5.2.3'></script> <script>var $imageEl=document.querySelector('meta[property="og:image"]');window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":["mshare","tsina","weixin","qzone","sqq","douban","fbook","twi","bdhome","tqq","tieba","mail","youdao","print"],"bdPic":$imageEl?$imageEl.getAttribute('content'):"","bdStyle":"1","bdSize":"16"},"share":[{"tag" : "single", "bdSize" : 16}, {"tag" : "global","bdSize" : 16,bdPopupOffsetLeft:-227}],url:_wpcom_js.theme_url};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src=_wpcom_js.theme_url + '/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script> </body> </html><!-- Performance optimized by Redis Object Cache. Learn more: https://wprediscache.com Retrieved 1788 objects (327 KB) from Redis using PhpRedis (v5.3.4). -->