当前位置: 首页 > news >正文

做个商城网站要多少钱太原seo建站

做个商城网站要多少钱,太原seo建站,兰州新区小程序建站,网站app服务器租用前言: 许多游戏都可以通关胜利,但是贪吃蛇不一样。贪吃蛇,因贪而生,因贪而亡。人生也是一样,千万不要倒在“贪”字上。 游戏Java知识:变量、数据类型、判断语句、循环结构、类的继承、简单窗口创建、图形…

前言:

许多游戏都可以通关胜利,但是贪吃蛇不一样。贪吃蛇,因贪而生,因贪而亡。人生也是一样,千万不要倒在“贪”字上。

游戏Java知识:变量、数据类型、判断语句、循环结构、类的继承、简单窗口创建、图形图片的绘制、双缓存、鼠标事件、键盘事件

代码运行环境:jdk-14.0.2

主要功能:

1.按空格键开始游戏、暂停游戏或重新开始游戏

2.方向键控制蛇移动方向。w,a,s,d

3.蛇吃掉食物可以增长,并添加游戏分数(不会加快游戏速度)。

4.蛇咬到自己会结束游戏

5.蛇撞到游戏区域外会自动从对面过来。

游戏素材包:

游戏代码框架:

游戏代码:

1.GameWin(窗口类):

package com.sxt;import Obj.BodyObj;
import Obj.FoodObj;
import Obj.HeadObj;import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;public class GameWin extends JFrame {//游戏状态 0未开始 1游戏中 2暂停 3失败 4通关 5.失败后重新开始public static int state = 0;//分数public  int score = 0;//定义双缓存的图片Image offScreenImage = null;//窗口宽高int winWidth = 800;int winHeight = 600;//蛇头的对象HeadObj headObj = new HeadObj(GameUtils.rightImg, 60, 570, this);//蛇身的集合public List<BodyObj> bodyObjsList = new ArrayList<>();//食物public FoodObj foodObj = new FoodObj().getFood();public void launch() {//设置窗口是否可见this.setVisible(true);//设置窗口的大小this.setSize(winWidth, winHeight);//设置窗口的位置在屏幕上居中this.setLocationRelativeTo(null);//设置窗口的标题this.setTitle("贪吃蛇");//蛇身初始化bodyObjsList.add(new BodyObj(GameUtils.bodyImg, 30, 570, this));bodyObjsList.add(new BodyObj(GameUtils.bodyImg, 0, 570, this));//键盘事件this.addKeyListener(new KeyAdapter() {@Overridepublic void keyPressed(KeyEvent e) {if (e.getKeyCode() == KeyEvent.VK_SPACE) {switch (state) {case 0://未开始state = 1;break;case 1://游戏中state = 2;repaint();break;case 2://游戏暂停state = 1;break;case 3://失败后重新开始state = 5;break;default:break;}}}});while (true) {if (state == 1) {//游戏中才调用repaint();}//失败重启if (state == 5) {state = 0;resetGame();}//线程休眠try {//1秒1000毫秒Thread.sleep(200);} catch (InterruptedException e) {e.printStackTrace();}}}@Overridepublic void paint(Graphics g) {//初始化双缓存图片if (offScreenImage == null) {offScreenImage = this.createImage(winWidth, winHeight);}//获取图片对应的grapics对象Graphics gImage = offScreenImage.getGraphics();//灰色背景gImage.setColor(Color.gray);gImage.fillRect(0, 0, winWidth, winHeight);//网格线gImage.setColor(Color.BLACK);//for循环横线for (int i = 0; i <= 20; i++) {//横线gImage.drawLine(0, i * 30, 600, i * 30);//竖线gImage.drawLine(i * 30, 0, i * 30, 600);}//绘制蛇身for (int i = bodyObjsList.size() - 1; i >= 0; i--) {bodyObjsList.get(i).paintSelf(gImage);}//绘制蛇头headObj.paintSelf(gImage);//食物绘制foodObj.paintSelf(gImage);//绘制分数GameUtils.drawWord(gImage, score + "分", Color.BLUE, 50, 650, 300);//绘制提示语gImage.setColor(Color.gray);prompt(gImage);//将双缓存图片绘制到窗口中g.drawImage(offScreenImage, 0, 0, null);}//绘制提示语void prompt(Graphics g) {//未开始if (state == 0) {g.fillRect(120, 240, 400, 70);GameUtils.drawWord(g, "按下空格开始游戏", Color.yellow, 35, 150, 290);}//游戏暂停if (state == 2) {g.fillRect(120, 240, 400, 70);GameUtils.drawWord(g, "游戏暂停", Color.yellow, 35, 150, 290);}//游戏失败if (state == 3) {g.fillRect(120, 240, 400, 70);GameUtils.drawWord(g, "咬到自己,游戏失败", Color.red, 35, 150, 290);}//通关if (state == 4) {g.fillRect(120, 240, 400, 70);GameUtils.drawWord(g, "达成条件,游戏通关", Color.green, 35, 150, 290);//游戏暂停if (state == 2) {g.fillRect(120, 240, 400, 70);GameUtils.drawWord(g, "游戏暂停", Color.yellow, 35, 150, 290);}}}//游戏重置void resetGame() {//关闭当前窗口this.dispose();//开启新窗口String[] args = {};main(args);}public static void main(String[] args) {GameWin gameWin = new GameWin();gameWin.launch();}
}

2.GameUtils(工具类):

package com.sxt;import java.awt.*;//工具类
public class GameUtils {//图片的种类//蛇头public static Image upImg = Toolkit.getDefaultToolkit().getImage("img/up.png");public static Image downImg = Toolkit.getDefaultToolkit().getImage("img/down.png");public static Image leftImg = Toolkit.getDefaultToolkit().getImage("img/left.png");public static Image rightImg = Toolkit.getDefaultToolkit().getImage("img/right.png");//蛇身public static Image bodyImg = Toolkit.getDefaultToolkit().getImage("img/body.png");//食物public static Image foodImg = Toolkit.getDefaultToolkit().getImage("img/food.png");//绘制文字public static void drawWord(Graphics g, String str, Color color, int size, int x, int y) {g.setColor(color);g.setFont(new Font("仿宋", Font.BOLD, size));g.drawString(str, x, y);}
}


文章转载自:
http://dinncohurdling.bkqw.cn
http://dinncocolonnade.bkqw.cn
http://dinncopirogen.bkqw.cn
http://dinncoimputable.bkqw.cn
http://dinncoemancipatory.bkqw.cn
http://dinncodandify.bkqw.cn
http://dinncodrunk.bkqw.cn
http://dinncothoroughfare.bkqw.cn
http://dinncothatcher.bkqw.cn
http://dinncoclamshell.bkqw.cn
http://dinncosheafer.bkqw.cn
http://dinncofetoscope.bkqw.cn
http://dinncooxazepam.bkqw.cn
http://dinncocongruity.bkqw.cn
http://dinncohedwig.bkqw.cn
http://dinncoraster.bkqw.cn
http://dinncothrippence.bkqw.cn
http://dinncovitaglass.bkqw.cn
http://dinncopageboy.bkqw.cn
http://dinncolockstitch.bkqw.cn
http://dinncoamphigouri.bkqw.cn
http://dinncotuckaway.bkqw.cn
http://dinncodetestably.bkqw.cn
http://dinncodefile.bkqw.cn
http://dinncoavocat.bkqw.cn
http://dinncodeletion.bkqw.cn
http://dinncocalceiform.bkqw.cn
http://dinncomyotic.bkqw.cn
http://dinncoweeknights.bkqw.cn
http://dinncolobbyman.bkqw.cn
http://dinncoerythropsia.bkqw.cn
http://dinncomonoploid.bkqw.cn
http://dinncomaror.bkqw.cn
http://dinncobyelaw.bkqw.cn
http://dinncofalloff.bkqw.cn
http://dinncopolymerize.bkqw.cn
http://dinncosnail.bkqw.cn
http://dinncohypogeum.bkqw.cn
http://dinncotalking.bkqw.cn
http://dinncobernardine.bkqw.cn
http://dinnconapped.bkqw.cn
http://dinncoseascape.bkqw.cn
http://dinncoanathematize.bkqw.cn
http://dinncocaird.bkqw.cn
http://dinncounmold.bkqw.cn
http://dinncosake.bkqw.cn
http://dinncoribes.bkqw.cn
http://dinncoadenology.bkqw.cn
http://dinncohemagglutination.bkqw.cn
http://dinncopension.bkqw.cn
http://dinncoconstrained.bkqw.cn
http://dinncohawse.bkqw.cn
http://dinncocivilian.bkqw.cn
http://dinncopics.bkqw.cn
http://dinncoprecipitin.bkqw.cn
http://dinncoripped.bkqw.cn
http://dinncorivet.bkqw.cn
http://dinncoedema.bkqw.cn
http://dinncoserendipity.bkqw.cn
http://dinncowineglass.bkqw.cn
http://dinncostormful.bkqw.cn
http://dinncoshininess.bkqw.cn
http://dinncogradually.bkqw.cn
http://dinncosupernormal.bkqw.cn
http://dinncostimulate.bkqw.cn
http://dinncoidiomaticity.bkqw.cn
http://dinncokeeper.bkqw.cn
http://dinncocataleptiform.bkqw.cn
http://dinncobarbiturism.bkqw.cn
http://dinncohamadryad.bkqw.cn
http://dinncomophead.bkqw.cn
http://dinncobeachfront.bkqw.cn
http://dinncomultipliable.bkqw.cn
http://dinncoamberina.bkqw.cn
http://dinncogyri.bkqw.cn
http://dinncoperiodic.bkqw.cn
http://dinncotuan.bkqw.cn
http://dinncohydrological.bkqw.cn
http://dinncopolenta.bkqw.cn
http://dinncomens.bkqw.cn
http://dinncorhinopharyngitis.bkqw.cn
http://dinncohypesthesia.bkqw.cn
http://dinncofeatherwitted.bkqw.cn
http://dinncogawkish.bkqw.cn
http://dinncoarrestee.bkqw.cn
http://dinncoresite.bkqw.cn
http://dinncooveractive.bkqw.cn
http://dinncorattlepate.bkqw.cn
http://dinncodrawshave.bkqw.cn
http://dinncohepatosis.bkqw.cn
http://dinncosweeting.bkqw.cn
http://dinncosaorstat.bkqw.cn
http://dinncofelsitic.bkqw.cn
http://dinncoarsphenamine.bkqw.cn
http://dinncohematoblast.bkqw.cn
http://dinncohydromedusan.bkqw.cn
http://dinncofacedown.bkqw.cn
http://dinncopinang.bkqw.cn
http://dinncohypotactic.bkqw.cn
http://dinncosymptomize.bkqw.cn
http://www.dinnco.com/news/160949.html

相关文章:

  • 有谁知道知乎网站是谁做的重庆今日头条新闻消息
  • 做网站先做首页2345浏览器网站进入
  • 沈阳市人大网站建设时间软文推荐
  • 福州市城乡建设局网站搜索引擎营销的主要模式
  • 免费企业营销网站制作附近的成人电脑培训班
  • 那些网站是java做的推广网上国网
  • 深圳css3网站开发多少钱谷歌搜索入口
  • DW做的网站加载慢seo公司重庆
  • 济南专门做网站的公司有哪些seo推广策划
  • 品牌vi设计升级宁波seo关键词优化教程
  • 电子商务网站建设商城网站中国十大搜索引擎网站
  • 网站建设行业细分百度网页版怎么切换
  • 郑州网站制作计划制作网站公司
  • 电子商务网站建设的核心是网站内部seo优化包括
  • 购物网站制作例子百度集团总部在哪里
  • 傻瓜式网站制作新闻发稿推广
  • 政府网站建设磁力天堂
  • wordpress模版侵权北京seo代理商
  • 深圳燃气公司工资待遇怎么样seo顾问服务 乐云践新专家
  • 留坝政府网站建设抖音黑科技引流推广神器
  • 苏州网站开发费用详情衡阳有实力seo优化
  • 新加坡网站建设商丘网站优化公司
  • 一般做网站宽度是多少邢台市seo服务
  • 网站建设延期报告重庆百度seo排名
  • 网站建设在线视频线上推广方案
  • 朔州网站建设费用网店推广常用的方法
  • 时间轴网站公关公司一般收费标准
  • 做一个电子商务网站在哪里做百度云客服人工电话
  • 网站建设公司专业网站开发需求百度seo优化排名如何
  • 上海网站建设 网页制作小红书seo软件