Java版吃豆游戏及源码 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-15
Java版吃豆游戏及源码时间:2011-08-18这是一个吃豆游戏的Java实现,具体代码较多请下载文件。 下载地址:http://download.csdn.net/source/396925 package org.loon.test;import java.awt.Color;import java.awt.Event;import java.awt.Frame;import java.awt.Graphics;import java.awt.Image;import java.awt.Insets;import java.awt.MediaTracker;import java.awt.Panel;import java.awt.Toolkit;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.awt.image.BufferedImage;import java.awt.image.VolatileImage;/** * * <p>* Title: LoonFramework* </p>* <p>* Description:* </p>* <p>* Copyright: Copyright (c) 2008* </p>* <p>* Company: LoonFramework* </p>* <p>* License: [url]http://www.apache.org/licenses/LICENSE-2.0 [/url]* </p>* * @author chenpeng* @email:ceponline@yahoo.com.cn* @version 0.1*/class Timer implements Runnable { Pacgame ap; int duration; private Thread myThread; private boolean loopf = true; private long tickCount; public Timer(Pacgame ap, int duration) { this.ap = ap; this.duration = duration; } public Timer(Pacgame ap) { this(ap, 16); } public void on() { myThread = new Thread(this); myThread.start(); } public void off() { loopf = false; } public void run() { loopf = true; tickCount = System.currentTimeMillis(); while (loopf) { try { Thread.sleep(duration); } catch (Exception e) { e.printStackTrace(); } ap.notifyFrame (); } } public int frames() { long nowTick = System.currentTimeMillis(); int frame = (int) (nowTick - tickCount) / duration; if (frame <= 0) { frame = 1; tickCount = nowTick; } else if (frame > 5) { frame = 5; tickCount = nowTick; } else { tickCount += frame * duration; } return frame; }}public class Pacgame extends Panel implements Runnable { /** *//** * */ private static final long serialVersionUID = 1L; private static int WIDTH = 256; private static int HEIGHT = 224; Thread thread; //构造一个双缓冲的、可变的image VolatileImage offImage; Image bg, bg0; CGloader loader; MazeManager mzmanager; MapManager emanager; SpriteManager spmanager, chipmanager; MonsterSprite redmon, ao, pink, monster; PacSprite pac; AttractManager |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于Java版吃豆游戏及源码 - 编程入门网的所有评论