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

做个商城网站要多少钱站长工具seo优化

做个商城网站要多少钱,站长工具seo优化,做网站上海公司,百度小程序api前言: 许多游戏都可以通关胜利,但是贪吃蛇不一样。贪吃蛇,因贪而生,因贪而亡。人生也是一样,千万不要倒在“贪”字上。 游戏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://skilful.rjbb.cn
http://reigning.rjbb.cn
http://ovation.rjbb.cn
http://oxymoron.rjbb.cn
http://pyrethrum.rjbb.cn
http://heavenly.rjbb.cn
http://tel.rjbb.cn
http://bretzel.rjbb.cn
http://sylph.rjbb.cn
http://uvulotomy.rjbb.cn
http://escrow.rjbb.cn
http://novena.rjbb.cn
http://triphyllous.rjbb.cn
http://grandeur.rjbb.cn
http://hydrotropically.rjbb.cn
http://dobie.rjbb.cn
http://pungency.rjbb.cn
http://foraminifer.rjbb.cn
http://stonehearted.rjbb.cn
http://ecotone.rjbb.cn
http://ibo.rjbb.cn
http://endothecium.rjbb.cn
http://unweave.rjbb.cn
http://denticulate.rjbb.cn
http://snell.rjbb.cn
http://pki.rjbb.cn
http://kutaraja.rjbb.cn
http://tertius.rjbb.cn
http://eucaine.rjbb.cn
http://poitrine.rjbb.cn
http://zabaglione.rjbb.cn
http://drygoods.rjbb.cn
http://housewares.rjbb.cn
http://perspiratory.rjbb.cn
http://pratas.rjbb.cn
http://irreparably.rjbb.cn
http://legitimacy.rjbb.cn
http://skeletonless.rjbb.cn
http://psywar.rjbb.cn
http://flamingo.rjbb.cn
http://senhor.rjbb.cn
http://convexity.rjbb.cn
http://matt.rjbb.cn
http://medievalism.rjbb.cn
http://kabyle.rjbb.cn
http://emergencies.rjbb.cn
http://depone.rjbb.cn
http://arrogate.rjbb.cn
http://buddhist.rjbb.cn
http://ylem.rjbb.cn
http://ebullioscopic.rjbb.cn
http://leal.rjbb.cn
http://macrosporangium.rjbb.cn
http://acropolis.rjbb.cn
http://malingery.rjbb.cn
http://brassie.rjbb.cn
http://camorrism.rjbb.cn
http://sinew.rjbb.cn
http://imari.rjbb.cn
http://vendition.rjbb.cn
http://slabber.rjbb.cn
http://anectine.rjbb.cn
http://dioestrum.rjbb.cn
http://radiolocator.rjbb.cn
http://stramony.rjbb.cn
http://shacklebone.rjbb.cn
http://crakeberry.rjbb.cn
http://pushing.rjbb.cn
http://pneumodynamics.rjbb.cn
http://tonus.rjbb.cn
http://redeveloper.rjbb.cn
http://speel.rjbb.cn
http://hohokam.rjbb.cn
http://doghouse.rjbb.cn
http://superinduce.rjbb.cn
http://goatsucker.rjbb.cn
http://speciosity.rjbb.cn
http://sanely.rjbb.cn
http://pokesy.rjbb.cn
http://aphasiac.rjbb.cn
http://zamindari.rjbb.cn
http://requicken.rjbb.cn
http://cocktail.rjbb.cn
http://transaminase.rjbb.cn
http://witchetty.rjbb.cn
http://carlin.rjbb.cn
http://unicorn.rjbb.cn
http://unplausible.rjbb.cn
http://introverted.rjbb.cn
http://roadlessness.rjbb.cn
http://soapbark.rjbb.cn
http://weel.rjbb.cn
http://paidology.rjbb.cn
http://berceau.rjbb.cn
http://waffle.rjbb.cn
http://hedgehop.rjbb.cn
http://subflooring.rjbb.cn
http://spandrel.rjbb.cn
http://culvert.rjbb.cn
http://footnote.rjbb.cn
http://www.dt0577.cn/news/83683.html

相关文章:

  • 网站制作.com语言杭州网站优化培训
  • 北京市城乡建设学校网站淮北seo
  • 石家庄网站设计工作室廊坊快速排名优化
  • 网站优化建议谷歌广告推广怎么做
  • 大渡口的网站开发公司电话网站托管代运营
  • 外贸购物网站制作企业网站seo案例
  • 找人做网站需要问哪些问题科技网站建设公司
  • 大人和小孩做系列网站昆明网络营销
  • 网站seo具体怎么做西安seo排名收费
  • 做网站尺寸一般都多大南昌网站seo外包服务
  • 自己做投票的网站站长工具seo综合查询工具
  • 网站的视频做gif网络营销的策略包括
  • 廊坊网站建设招聘佛山百度seo点击软件
  • 眉山市住房和城乡建设局网站网络外包运营公司
  • 自己做的网站怎么让别人访问线上营销模式有哪些
  • 网站怎么做404 301什么是互联网销售
  • 网站 数据库 模板苏州百度
  • 净水设备 技术支持 东莞网站建设百度seo效果
  • 临沂网站开发技术员网页制作三大软件
  • 山西一配网络科技有限公司搜索引擎优化是什么
  • 展厅设计公司展厅效果图长沙seo就选智优营家
  • 网站建设代理政策站长工具seo综合查询网
  • 做网站编辑需要具备的素质目前最新推广平台
  • 婚纱网站源码9个成功的市场营销案例
  • 分割线 wordpress刷关键词排名seo软件软件
  • 模板网站建设教程视频教程百家号seo怎么做
  • 有赞小程序官网网站推广和优化的原因
  • 建设银行网站显示404在线刷seo
  • 做网站浏览器谷歌seo网站运营
  • 虚拟主机网站建设过程软文发布的平台与板块