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

网站色彩搭配原则建设网站火车票预订

网站色彩搭配原则,建设网站火车票预订,鄞州区建设网站,ui设计是什么软件做的Java版AVG游戏开发入门[0]——游戏模式转换中的事件交互 示例程序下载地址#xff1a;http://download.csdn.net/source/999273#xff08;源码在jar内#xff09; AVG#xff0c;即Adventure Game#xff0c;可以直译为[冒险游戏]。但是通常情况下我们说AVG是指[文字冒险… Java版AVG游戏开发入门[0]——游戏模式转换中的事件交互    示例程序下载地址http://download.csdn.net/source/999273源码在jar内    AVG即Adventure Game可以直译为[冒险游戏]。但是通常情况下我们说AVG是指[文字冒险游戏]也有人更直白的解释成自己选择路线和结局的电子小说与硬砍硬杀的RPG或者揉破键盘的ACT不同AVG多以解谜或文字游戏等脑力攻关推动剧情发展。现在日本流行的ADV可以看作是AVG英文全称的不同缩写方式大体上讲AVG ADV。    由于商业化需要现代主流的AVG往往是GalGame也就是少女游戏或称少女恋爱游戏但GalGame ! AVG只是下属分支中的一环罢了AVG包含GalGame但GalGame并不能完全代表AVG/ADV。另外关于GalGame的详细介绍在若木民喜《只有神才知道的世界》中演绎的相当生动有兴趣的可以自己去看看~         就技术角度而言AVG开发可以算得所有游戏类型中最容易的。一款简单AVG游戏的制作难度甚至在贪食蛇、俄罗斯方块之下。由于实现的简易性导致AVG的开发重心往往着重于策划及美工程序员的作用则微乎其微。同时也正因AVG开发的门坎约等于0所以此类型的同人游戏之多即可堪称世界之冠。另外AVG开发工具普及的也促进了AVG的量产化。利用工具即始是小说作者、漫画家等非软件专业出身的人士往往也能轻易制作出顶级的AVG大作。顺便一提目前我所见过最好的AVG制作工具是鬼子的livemaker采用类似思维导图的方式构造整个游戏很多轻小说作者乃至网络漫画家用它制作自己作品的宣传游戏。但就技术角度上说livemaker的开发依旧没什么难度......    由于AVG的大泛滥通常仅有文字、图片及语音的AVG往往无法满足用户需求H除外-_-。我们每每可在AVG游戏类型后发现个号比如《樱花大战》是AVGSLG《生化危机》是AVGACT。所以客观上说AVG开发仅仅能进行字图的交互是不够的还要解决多模块组件的协调问题。    在Java桌面应用开发中,我们都知道绘图是极为简单的有Image、Graphics两个对象就可以Paint一个图形即使图形对象再多最后它们也必须统一在一个Paint中所以Java中不存在图像的交互问题。   但问题在于图像的显示可以统一但是触发图像变化的事件却是很难统一的。比如现在有需求如下在AVG模式中触发键盘事件上、下、左、右时为控制画面的前进、后退切换模式到SLG模式后设定上、下、左、右是光标移动那么如果我要在程序中实现就必须记录当前模式而后根据不同模式调用事件再反馈到图形上。如果只有几个事件的区别我们当然可以很容易用分支来实现问题是随着游戏规模的加大这些分支将成几何倍数增多单纯的分支判定到最后只能忙于应付落个费力不讨好。   其实在这时我们大可以使用一些技巧来轻松解决问题。   示例如下     首先我们构造一个接口命名为IControl继承鼠标及键盘监听并在其中设定两个抽象方法       package org.loon.simple.avg; import java.awt.Graphics; import java.awt.event.KeyListener; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; /** * Copyright 2008 - 2009 * * Licensed under the Apache License, Version 2.0 (the License); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * project loonframework * author chenpeng * emailceponlineyahoo.com.cn * version 0.1 */ public interface IControl extends MouseListener, MouseMotionListener, KeyListener { public abstract void draw(final Graphics g); public abstract IControl invoke(); }       而后再构造一个接口命名为IAVG同样继承鼠标及键盘监听并在其中设定三个抽象方法用以操作IControl接口     package org.loon.simple.avg; import java.awt.Graphics; import java.awt.event.KeyListener; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; /** * Copyright 2008 - 2009 * * Licensed under the Apache License, Version 2.0 (the License); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * project loonframework * author chenpeng * emailceponlineyahoo.com.cn * version 0.1 */ public interface IAVG extends MouseListener, MouseMotionListener, KeyListener { public abstract void draw(final Graphics g); public abstract IControl getControl(); public abstract void setControl(final IControl control); }       再后制作一个显示图像用组件命名为AVGCanva继承自Canvas。        package org.loon.simple.avg; import java.awt.Canvas; import java.awt.Graphics; /** * Copyright 2008 - 2009 * * Licensed under the Apache License, Version 2.0 (the License); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * project loonframework * author chenpeng * emailceponlineyahoo.com.cn * version 0.1 */ public class AVGCanvas extends Canvas { /** * */ private static final long serialVersionUID 1982278682597393958L; private boolean start; private IAVG avg; public AVGCanvas(IAVG handler) { this.avg handler; this.start false; this.addKeyListener(handler); this.addMouseListener(handler); this.addMouseMotionListener(handler); } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { if (this.start) { this.avg.draw(g); } } public void startPaint() { this.start true; } public void endPaint() { this.start false; } }        这段代码中的paint方法中并没有现成的方法而是调用了IAVG接口的draw。紧接着我们再设定一个AVGFrame用以加载AVGCanvas。       package org.loon.simple.avg; import java.awt.Color; import java.awt.Dimension; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; /** * Copyright 2008 - 2009 * * Licensed under the Apache License, Version 2.0 (the License); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * project loonframework * author chenpeng * emailceponlineyahoo.com.cn * version 0.1 */ public class AVGFrame extends Frame implements Runnable { /** * */ private static final long serialVersionUID 198284399945549558L; private IAVG avg; private AVGCanvas canvas; private boolean fps; private String titleName; private Thread mainLoop; public AVGFrame(String titleName, int width, int height) { this(new AVG(), titleName, width, height); } public AVGFrame(IAVG avg, String titleName, int width, int height) { super(titleName); Lib.WIDTH width; Lib.HEIGHT height; this.avg avg; this.titleName titleName; this.addKeyListener(avg); this.setPreferredSize(new Dimension(width 5, height 25)); this.initCanvas(Lib.WIDTH, Lib.HEIGHT); this.pack(); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); this.setResizable(false); this.setLocationRelativeTo(null); this.setVisible(true); } public void run() { gameLoop(); } /** * 开始循环窗体图像 * */ private synchronized void gameLoop() { canvas.startPaint(); long second 0L; int moveCount 0; // 循环绘制 for (;;) { long start System.currentTimeMillis(); this.paintScreen(); long end System.currentTimeMillis(); long time end - start; long sleepTime 20L - time; if (sleepTime 0L) sleepTime 0L; try { Thread.sleep(sleepTime); } catch (InterruptedException e) { e.printStackTrace(); } if (this.fps) { moveCount; second System.currentTimeMillis() - start; if (second 1000L) { this.setTitle(new StringBuilder(titleName).append( FPS:) .append(moveCount).toString()); moveCount 0; second 0L; } } } } /** * 启动游戏循环 * */ public void mainLoop() { this.mainLoop new Thread(this); this.mainLoop.start(); } /** * 初始化背景帆布 * * param width * param height */ private void initCanvas(final int width, final int height) { canvas new AVGCanvas(avg); canvas.setBackground(Color.black); canvas.setPreferredSize(new Dimension(width, height)); this.add(canvas); } public IAVG getAVG() { return this.avg; } protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); } public synchronized void paintScreen() { canvas.repaint(); } public boolean isShowFPS() { return fps; } public void setShowFPS(boolean fps) { this.fps fps; } public Thread getMainLoop() { return mainLoop; } public String getTitleName() { return titleName; } }     我们可以看到在本例鼠标键盘事件及图像绘制完全通过接口方式实现。此时只要让不同组件统一实现IControl接口便可以轻松转换事件及图像的绘制。也正是我们都再熟悉不过的MVC模式中通过Event导致Controller改变Model及View的基本原理。      下一回我们将具体讲解一个AVG游戏实现的基本流程。     示例代码界面如下图                       、      示例程序下载地址http://download.csdn.net/source/999273源码在jar内   posted on 2009-02-08 10:06 cping 阅读(...) 评论(...) 编辑 收藏 转载于:https://www.cnblogs.com/cping1982/archive/2009/02/08/2257949.html
http://www.pierceye.com/news/590613/

相关文章:

  • 专门做淘宝代运营的网站支付建设网站的费用什么科目
  • 天津企业设计网站建设建个网站做外贸
  • 申请永久网站空间wordpress论坛采集
  • 网站如何做竞价佛山新网站建设机构
  • 网站建设费可以一次性冲费用吗学校门户网站作用
  • 手机上怎么制作网站音乐网站如何建立
  • 新乡企业网站建设公司寮步东莞网站建设
  • wordpress中国网站排名如何加入广告联盟赚钱
  • 济宁网站建设培训学校wordpress导入表单
  • 做农产品交易网站阿里云已备案域名购买
  • 免费建站网站一级大录像不卡谁给我一个企业邮箱认证
  • 中国做网站东台做网站公司
  • 建设数据库网站需要哪些设备wordpress多功能主题 cosy
  • 苏州市郭巷建设局网站一家专门做鞋子的网站
  • 光明网站建设网站建设成果
  • 商业网站建设举例宝塔做两个网站6
  • 网站优化排名分享隐迅推前端开发入门培训
  • 曲周县建设局网站东莞保安公司电话
  • 合肥商城网站建设多少钱wordpress页面代码怎么改
  • 前期做网站宣传费用怎样做账企业网站建设的劣势
  • 网站建设企业哪家好做网站三大主流框架
  • 网站托管服务方案珲春建设局网站
  • 开发网站公司收入重庆多功能网站建设
  • 河北手机网站建设上海网站seo招聘
  • 厦门市建设局思明建设分局官方网站在谷歌上做外贸网站有用吗
  • 网站开发手机自适应直接在原备案号下增加新网站
  • 公司网站建设安全的风险网络工程师app
  • 网站app封装怎么做电商网页
  • 网站文章做排名wordpress菜单文本
  • 建站哪家好社区个人网站模板 免费