Java游戏开发中怎样才能获得更快的FPS?

 pt0


场景图1、角色图100 FPS 20 - 25

pt1


场景图1、角色图1000 FPS 13 - 17

pt2

 

场景图1、角色图100 FPS 25 - 35

bs1

场景图1、角色图1000 FPS 3 - 6

bs2

 

场景图1、角色图100 FPS 115 - 125

j1

场景图1、角色图1000 FPS 55 - 70

j2

 

简单应用:

 

package test1; import java.awt.Color; import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics; 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 * @email:ceponline@yahoo.com.cn * @version 0.1 */ public class Sample extends Frame implements Runnable{ /** * */ private static final long serialVersionUID = 1L; private SimpleIntBufferImage simple1 = new SimpleIntBufferImage("back.gif"); private SimpleIntBufferImage simple2 = new SimpleIntBufferImage( "idle0_0.png"); private int width = 480; private int height = 360; public Sample() { super("自制SimpleIntBufferImage示例"); this.setBackground(Color.black); simple1.convertToXor(); simple1.convertToXor(); this.setPreferredSize(new Dimension(width, height)); this.requestFocus(); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); this.pack(); this.setResizable(false); this.setLocationRelativeTo(null); this.setIgnoreRepaint(true); Thread thread = new Thread(this); thread.start(); } public void run() { for(;;){ repaint(); try { Thread.sleep(20L); } catch (InterruptedException e) { } } } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { simple1.copyImage(simple2,15,50); g.drawImage(simple1.getBufferedImage(), 0, 0, null); } public static void main(String[] args) { Sample frm = new Sample(); frm.setVisible(true); } }

 

效果如下:

copy

 

 

 

 

 

posted on 2009-04-03 20:03 cping 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/cping1982/archive/2009/04/03/2257933.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值