예제 #1
0
 private Layer redraw(final int z) {
   final ArrayList<Sprite.Part> parts = new ArrayList<Sprite.Part>();
   Sprite.Drawer drw =
       new Sprite.Drawer() {
         public void addpart(Sprite.Part p) {
           if (p.z == z) parts.add(p);
         }
       };
   for (Sprite spr : sprites.values()) {
     if (spr != null) spr.setup(drw, Coord.z, Coord.z);
   }
   Collections.sort(parts, Sprite.partcmp);
   Coord ul = new Coord(0, 0);
   Coord lr = new Coord(0, 0);
   for (Sprite.Part part : parts) {
     if (part.ul.x < ul.x) ul.x = part.ul.x;
     if (part.ul.y < ul.y) ul.y = part.ul.y;
     if (part.lr.x > lr.x) lr.x = part.lr.x;
     if (part.lr.y > lr.y) lr.y = part.lr.y;
   }
   BufferedImage buf = TexI.mkbuf(lr.add(ul.inv()).add(1, 1));
   Graphics g = buf.getGraphics();
   /*
   g.setColor(java.awt.Color.RED);
   g.fillRect(0, 0, buf.getWidth(), buf.getHeight());
   */
   for (Sprite.Part part : parts) {
     part.cc = part.cc.add(ul.inv());
     part.draw(buf, g);
   }
   g.dispose();
   return (new Layer(buf, ul.inv()));
 }
예제 #2
0
 public synchronized boolean checkhit(Coord c) {
   if (base.get() == null) return (false);
   for (Sprite spr : sprites.values()) {
     if (spr == null) continue;
     if (spr.checkhit(c)) return (true);
   }
   return (false);
 }
예제 #3
0
 private synchronized Object[] stateid(Object... extra) {
   Object[] ret = new Object[layers.size() + extra.length];
   for (int i = 0; i < layers.size(); i++) {
     Sprite spr = sprites.get(layers.get(i));
     if (spr == null) ret[i] = null;
     else ret[i] = spr.stateid();
   }
   for (int i = 0; i < extra.length; i++) ret[i + layers.size()] = extra[i];
   return (ArrayIdentity.intern(ret));
 }
예제 #4
0
 public synchronized void ctick(int dt) {
   for (Map.Entry<Indir<Resource>, Sprite> e : sprites.entrySet()) {
     Indir<Resource> r = e.getKey();
     Sprite spr = e.getValue();
     if (spr != null) {
       int ldt = dt;
       if (delays.get(r) != null) {
         ldt += delays.get(r);
         delays.remove(r);
       }
       spr.tick(ldt);
     } else {
       delays.put(r, delays.get(r) + dt);
     }
   }
 }
예제 #5
0
 public void ctick(int dt) {
   if (spr == null) {
     delay += dt;
   } else {
     spr.tick(delay + dt);
     delay = 0;
   }
 }
예제 #6
0
 public void setup(RenderList rl) {
   try {
     init();
   } catch (Loading e) {
     return;
   }
   spr.setup(rl);
 }
 public void ctick(int dt) {
   int dt2 = dt + initdelay;
   initdelay = 0;
   for (GAttrib a : attr.values()) {
     if (a instanceof Drawable) a.ctick(dt2);
     else a.ctick(dt);
   }
   for (Iterator<Overlay> i = ols.iterator(); i.hasNext(); ) {
     Overlay ol = i.next();
     if (ol.spr == null) {
       if (((getattr(Drawable.class) == null) || (getneg() != null)) && (ol.res.get() != null))
         ol.spr = Sprite.create(this, ol.res.get(), ol.sdt);
     } else {
       boolean done = ol.spr.tick(dt);
       if ((!ol.delign || (ol.spr instanceof Overlay.CDel)) && done) i.remove();
     }
   }
 }
예제 #8
0
 public synchronized void setup(Sprite.Drawer drw, final Coord cc, final Coord off) {
   if (base.get() == null) return;
   if (loading) {
     loading = false;
     for (Indir<Resource> r : layers) {
       if (sprites.get(r) == null) {
         if (r.get() == null) loading = true;
         else sprites.put(r, Sprite.create(gob, r.get(), null));
       }
     }
   }
   /* XXX: Fix this to construct parts dynamically depending on
    * which layers exist. */
   Sprite.Part me;
   me = makepart(0);
   me.setup(cc, off);
   drw.addpart(me);
   me = makepart(-10);
   me.setup(cc, off);
   drw.addpart(me);
 }
예제 #9
0
 public void dispose() {
   if (spr != null) spr.dispose();
 }
예제 #10
0
 public void init() {
   if (spr != null) return;
   spr = Sprite.create(gob, res.get(), sdt.clone());
 }
예제 #11
0
 public void tick(int dt) {
   spr.tick(dt);
 }
예제 #12
0
 private SpriteEqu(ED ed) {
   super(ed);
   this.spr = Sprite.create(eqowner, ed.res.res.get(), ed.res.sdt.clone());
 }
예제 #13
0
 public Sprite create(Owner owner, Resource res, Message sdt) {
   return (Sprite.create(owner, this.res.get(), sdt));
 }