Java Code Examples for com.watabou.noosa.Game#elapsed()
The following examples show how to use
com.watabou.noosa.Game#elapsed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Emitter.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
@Override public void update() { if (on) { time += Game.elapsed; while (time > interval) { time -= interval; emit( count ); if (quantity > 0 && ++count >= quantity) { on = false; break; } } } else if (autoKill && countLiving() == 0) { kill(); } super.update(); }
Example 2
Source File: Flare.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
@Override public void update() { super.update(); if (duration > 0) { if ((lifespan -= Game.elapsed) > 0) { float p = 1 - lifespan / duration; // 0 -> 1 p = p < 0.25f ? p * 4 : (1 - p) * 1.333f; scale.set( p ); alpha( p ); } else { killAndErase(); } } }
Example 3
Source File: Fireball.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void update() { super.update(); if (y < heightLimit){ y = heightLimit; speed.set(Random.Float(-20, 20), 0); acc.set(0, 0); } if ((timeLeft -= Game.elapsed) <= 0) { kill(); } else { float p = timeLeft / LIFESPAN; scale.set( p ); alpha( p > 0.8f ? (1 - p) * 5f : p * 1.25f ); } }
Example 4
Source File: FloatingText.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void update() { super.update(); if (timeLeft > 0) { if ((timeLeft -= Game.elapsed) <= 0) { kill(); } else { float p = timeLeft / LIFESPAN; alpha( p > 0.5f ? 1 : p * 2 ); float yMove = (DISTANCE / LIFESPAN) * Game.elapsed; y -= yMove; for (RenderedText t : words){ t.y -= yMove; } } } }
Example 5
Source File: CavesLevel.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void update() { if (visible = (pos < Dungeon.level.heroFOV.length && Dungeon.level.heroFOV[pos])) { super.update(); if ((delay -= Game.elapsed) <= 0) { //pickaxe can remove the ore, should remove the sparkling too. if (Dungeon.level.map[pos] != Terrain.WALL_DECO){ kill(); return; } delay = Random.Float(); PointF p = DungeonTilemap.tileToWorld( pos ); ((Sparkle)recycle( Sparkle.class )).reset( p.x + Random.Float( DungeonTilemap.SIZE ), p.y + Random.Float( DungeonTilemap.SIZE ) ); } } }
Example 6
Source File: Toolbar.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
@Override public void update() { super.update(); if ((left -= Game.elapsed) <= 0) { visible = active = false; } else { float p = left / DURATION; scale.set( (float)Math.sqrt( p ) ); float offset = DISTANCE * p; x = dstX - offset; y = dstY - offset; } }
Example 7
Source File: Flare.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void update() { super.update(); if (duration > 0) { if ((lifespan -= Game.elapsed) > 0) { float p = 1 - lifespan / duration; // 0 -> 1 p = p < 0.25f ? p * 4 : (1 - p) * 1.333f; scale.set( p ); alpha( p ); } else { killAndErase(); } } }
Example 8
Source File: FloatingText.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override public void update() { super.update(); if (timeLeft > 0) { if ((timeLeft -= Game.elapsed) <= 0) { kill(); } else { float p = timeLeft / LIFESPAN; alpha( p > 0.5f ? 1 : p * 2 ); float yMove = (DISTANCE / LIFESPAN) * Game.elapsed; y -= yMove; for (RenderedText t : words){ t.y -= yMove; } } } }
Example 9
Source File: Emitter.java From PD-classes with GNU General Public License v3.0 | 6 votes |
@Override public void update() { if (on) { time += Game.elapsed; while (time > interval) { time -= interval; emit( count++ ); if (quantity > 0 && count >= quantity) { on = false; break; } } } else if (autoKill && countLiving() == 0) { kill(); } super.update(); }
Example 10
Source File: Flare.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void update() { super.update(); if (duration > 0) { if ((lifespan -= Game.elapsed) > 0) { float p = 1 - lifespan / duration; // 0 -> 1 p = p < 0.25f ? p * 4 : (1 - p) * 1.333f; scale.set( p ); alpha( p ); } else { killAndErase(); } } }
Example 11
Source File: AttackIndicator.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public synchronized void update() { super.update(); if (!bg.visible){ enable(false); if (delay > 0f) delay -= Game.elapsed; if (delay <= 0f) active = false; } else { delay = 0.75f; active = true; if (Dungeon.hero.isAlive()) { enable(Dungeon.hero.ready); } else { visible( false ); enable( false ); } } }
Example 12
Source File: EnragedFX.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void update() { super.update(); if ( ( phase += Game.elapsed ) < 1.0f ) { target.tint( 1.0f, 0.0f, 0.0f, phase * 0.2f ); } else { target.tint( 1.0f, 0.0f, 0.0f, ( 2.0f - phase ) * 0.2f ); } if( phase > 2.0f ) phase -= 2.0f; }
Example 13
Source File: PixelParticle.java From PD-classes with GNU General Public License v3.0 | 5 votes |
@Override public void update() { super.update(); if ((left -= Game.elapsed) <= 0) { kill(); } }
Example 14
Source File: BadgesScene.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void update() { super.update(); if (Random.Float() < Game.elapsed * 0.1) { BadgeBanner.highlight( icon, badge.image ); } }
Example 15
Source File: PixelScene.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void update() { super.update(); if ((time -= Game.elapsed) <= 0) { alpha( 0f ); parent.remove( this ); } else { alpha( time / FADE_TIME ); } }
Example 16
Source File: WndHardNotification.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void update() { super.update(); timeLeft -= Game.elapsed; if (timeLeft <= 0 ){ btnOkay.enable(true); btnOkay.text(btnMessage); } else { btnOkay.text(btnMessage + " (" + (int)Math.ceil(timeLeft) + ")"); } }
Example 17
Source File: DrainLife.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 4 votes |
@Override public void update() { super.update(); if ((life -= Game.elapsed) < 0) { killAndErase(); if (callback != null) { callback.call(); } } else { float alpha = life / DURATION; for (int i=0; i < length - 1; i++) { float sx = cx[i]; float sy = cy[i]; float ex = cx[i+1]; float ey = cy[i+1]; float x2 = (sx + ex) / 2 + Random.Float( -4, +4 ); float y2 = (sy + ey) / 2 + Random.Float( -4, +4 ); float dx = x2 - sx; float dy = y2 - sy; Image arc = arcsS[i]; arc.am = alpha; arc.angle = (float)(Math.atan2( dy, dx ) * A); arc.scale.x = (float)Math.sqrt( dx * dx + dy * dy ) / arc.width; dx = ex - x2; dy = ey - y2; arc = arcsE[i]; arc.am = alpha; arc.angle = (float)(Math.atan2( dy, dx ) * A); arc.scale.x = (float)Math.sqrt( dx * dx + dy * dy ) / arc.width; arc.x = x2 - arc.origin.x; arc.y = y2 - arc.origin.x; } } }
Example 18
Source File: ItemSprite.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void update() { super.update(); visible = (heap == null || heap.seen); if (dropInterval > 0 && (dropInterval -= Game.elapsed) <= 0) { speed.set( 0 ); acc.set( 0 ); place( heap.pos ); if (visible) { boolean water = Level.water[heap.pos]; if (water) { GameScene.ripple(heap.pos); } else { int cell = Dungeon.level.map[heap.pos]; water = (cell == Terrain.WELL || cell == Terrain.ALCHEMY); } if (!(heap.peek() instanceof Gold)) { Sample.INSTANCE.play(water ? Assets.SND_WATER : Assets.SND_STEP, 0.8f, 0.8f, 1.2f); } } } if (visible && glowing != null) { if (glowUp && (phase += Game.elapsed) > glowing.period) { glowUp = false; phase = glowing.period; } else if (!glowUp && (phase -= Game.elapsed) < 0) { glowUp = true; phase = 0; } float value = phase / glowing.period * 0.6f; rm = gm = bm = 1 - value; ra = glowing.red * value; ga = glowing.green * value; ba = glowing.blue * value; } }
Example 19
Source File: InterlevelScene.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public void update() { super.update(); waitingTime += Game.elapsed; float p = timeLeft / fadeTime; switch (phase) { case FADE_IN: message.alpha( 1 - p ); if ((timeLeft -= Game.elapsed) <= 0) { if (!thread.isAlive() && error == null) { phase = Phase.FADE_OUT; timeLeft = fadeTime; } else { phase = Phase.STATIC; } } break; case FADE_OUT: message.alpha( p ); if ((timeLeft -= Game.elapsed) <= 0) { Game.switchScene( GameScene.class ); thread = null; error = null; } break; case STATIC: if (error != null) { String errorMsg; if (error instanceof FileNotFoundException) errorMsg = Messages.get(this, "file_not_found"); else if (error instanceof IOException) errorMsg = Messages.get(this, "io_error"); else if (error.getMessage() != null && error.getMessage().equals("old save")) errorMsg = Messages.get(this, "io_error"); else throw new RuntimeException("fatal error occured while moving between floors. " + "Seed:" + Dungeon.seed + " depth:" + Dungeon.depth, error); add( new WndError( errorMsg ) { public void onBackPressed() { super.onBackPressed(); Game.switchScene( StartScene.class ); } } ); thread = null; error = null; } else if (thread != null && (int)waitingTime == 10){ waitingTime = 11f; String s = ""; for (StackTraceElement t : thread.getStackTrace()){ s += "\n"; s += t.toString(); } ShatteredPixelDungeon.reportException( new RuntimeException("waited more than 10 seconds on levelgen. " + "Seed:" + Dungeon.seed + " depth:" + Dungeon.depth + " trace:" + s) ); } break; } }
Example 20
Source File: BadgeBanner.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void update() { super.update(); time -= Game.elapsed; if (time >= 0) { switch (state) { case FADE_IN: float p = time / FADE_IN_TIME; scale.set( (1 + p) * DEFAULT_SCALE ); alpha( 1 - p ); break; case STATIC: break; case FADE_OUT: alpha( time / FADE_OUT_TIME ); break; } } else { switch (state) { case FADE_IN: time = STATIC_TIME; state = State.STATIC; scale.set( DEFAULT_SCALE ); alpha( 1 ); highlight( this, index ); break; case STATIC: time = FADE_OUT_TIME; state = State.FADE_OUT; break; case FADE_OUT: killAndErase(); break; } } }