📄 .#merg13725cvs
字号:
/* * Comp.java * * Created on 2007年12月18日, 下午12:27 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package graphics;import SBGameCore.*;import java.awt.Image;import java.awt.Dimension;import java.awt.*;/** * * @author wusir */public class Comp { GraphicsPanel a; int px,py;//new position int opx,opy;//old position int w,h;//the height and the wide int vx,vy;//the speed int face; int num; public boolean active = false; Image img = null; /** Creates a new instance of Comp */ public Comp() { } public boolean active(){ return active; } public void set_pos(int x,int y){ px = opx = x; py = opy = y; } public void set_speed(int x,int y){ vx = x; vy = y; } public void set_size(int x,int y){ w = x; h = y; } public void set_draw_rectangles(Rectangle o,Rectangle n){ int sh = a.window_size.height; int x = px - w/2; int y = (sh - py) - h/2; int ox = opx - w/2; int oy = (sh - opy) - h/2; o.reshape(ox,oy,w,h); n.reshape(x,y,w,h); } public void active(boolean s){ active = s; } public boolean collision(Comp c){ int dpx = Math.abs(px - c.px); int dpy = Math.abs(py - c.py); if((dpx < (Math.max(w/2,c.w/2)+1) && (dpy < Math.max(h/2,c.h/2)+1))) return true; return false; } public void draw(){ //set the size set_draw_rectangles(a.paint_area,a.new_area); //set the huanchong Graphics bg = a.buffer.getGraphics(); bg.clipRect(a.paint_area.x,a.paint_area.y,w,h); bg.drawImage(a.backdrop,0,0,a); bg.dispose(); //fullfill the area a.buf_g.fillRect(a.new_area.x,a.new_area.y,w,h); //use the new area a.paint_area.add(a.new_area); //print to the screen Graphics g = a.getGraphics(); g.clipRect(a.paint_area.x,a.paint_area.y,a.paint_area.width,a.paint_area.height); g.drawImage(a.buffer,0,0,a); g.dispose(); } //the object's erase public void erase(){ set_draw_rectangles(a.paint_area,a.new_area); a.paint_area.add(a.new_area); Graphics bg = a.buffer.getGraphics(); bg.clipRect(a.paint_area.x,a.paint_area.y,a.paint_area.width,a.paint_area.height); bg.drawImage(a.backdrop,0,0,a); bg.dispose(); Graphics g = a.getGraphics(); g.clipRect(a.paint_area.x,a.paint_area.y,a.paint_area.width,a.paint_area.height); g.drawImage(a.buffer,0,0,a); g.dispose(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -