public Rect union( int x, int y ) { if (isEmpty()) { return set( x, y, x + 1, y + 1 ); } else { if (x < left) { left = x; } else if (x >= right) { right = x + 1; } if (y < top) { top = y; } else if (y >= bottom) { bottom = y + 1; } return this; } }
public synchronized void updateFog(Rect update){ for (Rect r : toUpdate.toArray(new Rect[0])){ if (!r.intersect(update).isEmpty()){ toUpdate.remove(r); toUpdate.add(r.union(update)); return; } } toUpdate.add(update); }
public synchronized void updateFog(Rect update){ for (Rect r : toUpdate.toArray(new Rect[0])){ if (!r.intersect(update).isEmpty()){ toUpdate.remove(r); toUpdate.add(r.union(update)); return; } } toUpdate.add(update); }
public Rect union( int x, int y ) { if (isEmpty()) { return set( x, y, x + 1, y + 1 ); } else { if (x < left) { left = x; } else if (x >= right) { right = x + 1; } if (y < top) { top = y; } else if (y >= bottom) { bottom = y + 1; } return this; } }
public synchronized void updateFog( int cell, int radius ){ Rect update = new Rect( (cell % mapWidth) - radius, (cell / mapWidth) - radius, (cell % mapWidth) - radius + 1 + 2*radius, (cell / mapWidth) - radius + 1 + 2*radius); update.left = Math.max(0, update.left); update.top = Math.max(0, update.top); update.right = Math.min(mapWidth, update.right); update.bottom = Math.min(mapHeight, update.bottom); if (update.isEmpty()) return; updateFog( update ); }
public Rect union( int x, int y ) { if (isEmpty()) { return set( x, y, x + 1, y + 1 ); } else { if (x < left) { left = x; } else if (x >= right) { right = x + 1; } if (y < top) { top = y; } else if (y >= bottom) { bottom = y + 1; } return this; } }
public synchronized void updateFog( int cell, int radius ){ Rect update = new Rect( (cell % mapWidth) - radius, (cell / mapWidth) - radius, (cell % mapWidth) - radius + 1 + 2*radius, (cell / mapWidth) - radius + 1 + 2*radius); update.left = Math.max(0, update.left); update.top = Math.max(0, update.top); update.right = Math.min(mapWidth, update.right); update.bottom = Math.min(mapHeight, update.bottom); if (update.isEmpty()) return; updateFog( update ); }
@Override public boolean act() { spend( TICK ); if (volume > 0) { if (area.isEmpty()) setupArea(); volume = 0; evolve(); int[] tmp = off; off = cur; cur = tmp; } else { area.setEmpty(); } return true; }
@Override public boolean act() { spend( TICK ); if (volume > 0) { if (area.isEmpty()) setupArea(); volume = 0; evolve(); int[] tmp = off; off = cur; cur = tmp; } else { area.setEmpty(); } return true; }
if (!updated.isEmpty()) { updateVertices(); if (buffer == null)
if (!updated.isEmpty()) { updateVertices(); if (buffer == null)
@Override protected void emit( int index ) { if (blob.volume <= 0) { return; } if (blob.area.isEmpty()) blob.setupArea(); int[] map = blob.cur; float size = DungeonTilemap.SIZE; int cell; for (int i = blob.area.left; i < blob.area.right; i++) { for (int j = blob.area.top; j < blob.area.bottom; j++) { cell = i + j*Dungeon.level.width(); if (cell < Dungeon.level.heroFOV.length && Dungeon.level.heroFOV[cell] && map[cell] > 0) { float x = (i + Random.Float()) * size; float y = (j + Random.Float()) * size; factory.emit(this, index, x, y); } } } } }
@Override protected void emit( int index ) { if (blob.volume <= 0) { return; } if (blob.area.isEmpty()) blob.setupArea(); int[] map = blob.cur; float size = DungeonTilemap.SIZE; int cell; for (int i = blob.area.left; i < blob.area.right; i++) { for (int j = blob.area.top; j < blob.area.bottom; j++) { cell = i + j*Dungeon.level.width(); if (cell < Dungeon.level.heroFOV.length && Dungeon.level.heroFOV[cell] && map[cell] > 0) { float x = (i + Random.Float()) * size; float y = (j + Random.Float()) * size; factory.emit(this, index, x, y); } } } } }
@Override public void draw() { super.draw(); NoosaScript script = NoosaScript.get(); texture.bind(); script.uModel.valueM4( matrix ); script.lighting( rm, gm, bm, am, ra, ga, ba, aa ); if (!updated.isEmpty()) { updateVertices(); } script.camera( camera ); script.drawQuadSet( quads, size ); } }