com.watabou.noosa.Camera Java Examples
The following examples show how to use
com.watabou.noosa.Camera.
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: WandOfLightning.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override protected void onZap( Ballistica bolt ) { //lightning deals less damage per-target, the more targets that are hit. float multipler = 0.4f + (0.6f/affected.size()); //if the main target is in water, all affected take full damage if (Dungeon.level.water[bolt.collisionPos]) multipler = 1f; for (Char ch : affected){ processSoulMark(ch, chargesPerCast()); ch.damage(Math.round(damageRoll() * multipler), this); if (ch == Dungeon.hero) Camera.main.shake( 2, 0.3f ); ch.sprite.centerEmitter().burst( SparkParticle.FACTORY, 3 ); ch.sprite.flash(); } if (!curUser.isAlive()) { Dungeon.fail( getClass() ); GLog.n(Messages.get(this, "ondeath")); } }
Example #2
Source File: Potential.java From remixed-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public int defenceProc(Armor armor, Char attacker, Char defender, int damage) { int level = Math.max( 0, armor.level() ); if (Dungeon.level.adjacent( attacker.getPos(), defender.getPos() ) && Random.Int( level + 7 ) >= 6) { int dmg = Random.IntRange( 1, damage ); attacker.damage( dmg, LightningTrap.LIGHTNING ); dmg = Random.IntRange( 1, dmg ); defender.damage( dmg, LightningTrap.LIGHTNING ); checkOwner( defender ); if (defender == Dungeon.hero) { Camera.main.shake( 2, 0.3f ); } int[] points = {attacker.getPos(), defender.getPos()}; attacker.getSprite().getParent().add( new Lightning( points, 2, null ) ); } return damage; }
Example #3
Source File: Potential.java From pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public int proc( Armor armor, Char attacker, Char defender, int damage) { int level = Math.max( 0, armor.effectiveLevel() ); if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 7 ) >= 6) { int dmg = Random.IntRange( 1, damage ); attacker.damage( dmg, LightningTrap.LIGHTNING ); dmg = Random.IntRange( 1, dmg ); defender.damage( dmg, LightningTrap.LIGHTNING ); checkOwner( defender ); if (defender == Dungeon.hero) { Camera.main.shake( 2, 0.3f ); } int[] points = {attacker.pos, defender.pos}; attacker.sprite.parent.add( new Lightning( points, 2, null ) ); } return damage; }
Example #4
Source File: HeroSelectScene.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
private void setSelectedHero(HeroClass cl){ GamesInProgress.selectedClass = cl; background.texture( cl.splashArt() ); background.visible = true; background.hardlight(1.5f,1.5f,1.5f); prompt.visible = false; startBtn.visible = true; startBtn.text(Messages.titleCase(cl.title())); startBtn.textColor(Window.TITLE_COLOR); startBtn.setSize(startBtn.reqWidth() + 8, 21); startBtn.setPos((Camera.main.width - startBtn.width())/2f, startBtn.top()); PixelScene.align(startBtn); infoButton.visible = true; infoButton.setPos(startBtn.right(), startBtn.top()); challengeButton.visible = true; challengeButton.setPos(startBtn.left()-challengeButton.width(), startBtn.top()); }
Example #5
Source File: ScrollPane.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
private void scroll( PointF current ){ Camera c = content.camera; c.shift( PointF.diff( lastPos, current ).invScale( c.zoom ) ); if (c.scroll.x + width > content.width()) { c.scroll.x = content.width() - width; } if (c.scroll.x < 0) { c.scroll.x = 0; } if (c.scroll.y + height > content.height()) { c.scroll.y = content.height() - height; } if (c.scroll.y < 0) { c.scroll.y = 0; } thumb.y = y + height * c.scroll.y / content.height(); lastPos.set( current ); }
Example #6
Source File: NewDM300.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void move(int step) { super.move(step); Camera.main.shake( supercharged ? 3 : 1, 0.25f ); if (Dungeon.level.map[step] == Terrain.INACTIVE_TRAP && state == HUNTING) { //don't gain energy from cells that are energized if (NewCavesBossLevel.PylonEnergy.volumeAt(pos, NewCavesBossLevel.PylonEnergy.class) > 0){ return; } if (Dungeon.level.heroFOV[step]) { if (buff(Barrier.class) == null) { GLog.w(Messages.get(this, "shield")); } Sample.INSTANCE.play(Assets.Sounds.LIGHTNING); sprite.emitter().start(SparkParticle.STATIC, 0.05f, 20); } Buff.affect(this, Barrier.class).setShield( 30 + (HT - HP)/10); } }
Example #7
Source File: Chasm.java From pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public static void heroLand() { Hero hero = Dungeon.hero; hero.sprite.burst( hero.sprite.blood(), 10 ); Camera.main.shake( 4, 0.2f ); Buff.prolong( hero, Cripple.class, Cripple.DURATION ); hero.damage( Random.IntRange( hero.HT / 3, hero.HT / 2 ), new Hero.Doom() { @Override public void onDeath() { Badges.validateDeathFromFalling(); Dungeon.fail( Utils.format( ResultDescriptions.FALL, Dungeon.depth ) ); GLog.n( "You fell to death..." ); } } ); }
Example #8
Source File: Toolbar.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public void reset( Item item, int cell, float endX, float endY ) { view( item ); active = visible = true; PointF tile = DungeonTerrainTilemap.raisedTileCenterToWorld(cell); Point screen = Camera.main.cameraToScreen(tile.x, tile.y); PointF start = camera().screenToCamera(screen.x, screen.y); x = this.startX = start.x - ItemSprite.SIZE / 2; y = this.startY = start.y - ItemSprite.SIZE / 2; this.endX = endX - ItemSprite.SIZE / 2; this.endY = endY - ItemSprite.SIZE / 2; left = DURATION; scale.set( startScale = Camera.main.zoom / camera().zoom ); }
Example #9
Source File: Potential.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public int proc( Armor armor, Char attacker, Char defender, int damage) { int level = Math.max( 0, armor.level ); if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 7 ) >= 6) { int dmg = Random.IntRange( 1, damage ); attacker.damage( dmg, LightningTrap.LIGHTNING ); dmg = Random.IntRange( 1, dmg ); dmg = Random.IntRange( 1, dmg ); defender.damage( dmg, LightningTrap.LIGHTNING ); checkOwner( defender ); if (defender == Dungeon.hero) { Camera.main.shake( 2, 0.3f ); } attacker.sprite.parent.add( new Lightning( attacker.pos, defender.pos, null ) ); } return damage; }
Example #10
Source File: SandalsOfNature.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void execute( Hero hero, String action ) { super.execute(hero, action); if (action.equals(AC_FEED)){ GameScene.selectItem(itemSelector, mode, inventoryTitle); } else if (action.equals(AC_ROOT) && level > 0){ if (!isEquipped( hero )) GLog.i("You need to equip them to do that."); else if (charge == 0) GLog.i("They have no energy right now."); else { Buff.prolong(hero, Roots.class, 5); Buff.affect(hero, Earthroot.Armor.class).level(charge); CellEmitter.bottom(hero.pos).start(EarthParticle.FACTORY, 0.05f, 8); Camera.main.shake(1, 0.4f); charge = 0; updateQuickslot(); } } }
Example #11
Source File: Chasm.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public static void heroLand() { Hero hero = Dungeon.hero; hero.sprite.burst( hero.sprite.blood(), 10 ); Camera.main.shake( 4, 0.2f ); Buff.prolong( hero, Cripple.class, Cripple.DURATION ); hero.damage( Random.IntRange( hero.HP / 3, hero.HT / 2 ), new Hero.Doom() { @Override public void onDeath() { Badges.validateDeathFromFalling(); Dungeon.fail( ResultDescriptions.FALL ); GLog.n( "You fell to death..." ); } } ); }
Example #12
Source File: AboutScene.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private Text createText(String text, Text upper) { Text multiline = createMultiline( text, GuiProperties.regularFontSize() ); multiline.maxWidth(Camera.main.width * 5 / 6); add( multiline ); if(upper!=null){ placeBellow(multiline, upper); } return multiline; }
Example #13
Source File: PixelScene.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private static void viewportSizeChanged() { float minWidth, minHeight; if (RemixedDungeon.landscape()) { minWidth = MIN_WIDTH_L; minHeight = MIN_HEIGHT_L; } else { minWidth = MIN_WIDTH_P; minHeight = MIN_HEIGHT_P; } defaultZoom = 20; while ((Game.width() / defaultZoom < minWidth || Game.height() / defaultZoom < minHeight) && defaultZoom > 1) { defaultZoom-=0.01; } WndHelper.update(Game.width() / defaultZoom, Game.height() / defaultZoom); minZoom = 1; maxZoom = defaultZoom * 2; Camera.reset(new PixelCamera(defaultZoom)); float uiZoom = (float) Preferences.INSTANCE.getDouble(Preferences.KEY_UI_ZOOM, defaultZoom); uiCamera = Camera.createFullscreen(uiZoom); Camera.add(uiCamera); }
Example #14
Source File: Window.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public void destroy() { super.destroy(); Camera.remove( camera ); Game.instance.getInputProcessor().removeKeyListener(this); }
Example #15
Source File: DM300.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void move( int step ) { super.move( step ); if (level().map[step] == Terrain.INACTIVE_TRAP && hp() < ht()) { heal(Random.Int( 1, ht() - hp() ), this, true); getSprite().emitter().burst( ElmoParticle.FACTORY, 5 ); if (CharUtils.isVisible(this) && Dungeon.hero.isAlive()) { GLog.n(Game.getVar(R.string.DM300_Info1)); } } int cell = step + Level.NEIGHBOURS8[Random.Int( Level.NEIGHBOURS8.length )]; if (CharUtils.isVisible(this)) { CellEmitter.get( cell ).start( Speck.factory( Speck.ROCK ), 0.07f, 10 ); Camera.main.shake( 3, 0.7f ); Sample.INSTANCE.play( Assets.SND_ROCKS ); if (level().water[cell]) { GameScene.ripple( cell ); } else if (level().map[cell] == Terrain.EMPTY) { level().set( cell, Terrain.EMPTY_DECO ); GameScene.updateMap( cell ); } } Char ch = Actor.findChar( cell ); if (ch != null && ch != this) { Buff.prolong( ch, Paralysis.class, 2 ); } }
Example #16
Source File: SurfaceScene.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void destroy() { Badges.saveGlobal(); Camera.remove( viewport ); super.destroy(); }
Example #17
Source File: Goo.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public int attackProc( Char enemy, int damage ) { damage = super.attackProc( enemy, damage ); if (Random.Int( 3 ) == 0) { Buff.affect( enemy, Ooze.class ).set( Ooze.DURATION ); enemy.sprite.burst( 0x000000, 5 ); } if (pumpedUp > 0) { Camera.main.shake( 3, 0.2f ); } return damage; }
Example #18
Source File: Window.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void destroy() { super.destroy(); Camera.remove( camera ); Keys.event.remove( this ); }
Example #19
Source File: ScrollPane.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public ScrollPane( Component content ) { super(); this.content = content; addToBack( content ); width = content.width(); height = content.height(); content.camera = new Camera( 0, 0, 1, 1, PixelScene.defaultZoom ); Camera.add( content.camera ); }
Example #20
Source File: Earthroot.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void activate() { Char ch = Actor.findChar(pos); if (ch == Dungeon.hero) { Buff.affect( ch, Armor.class ).level = ch.HT; } if (Dungeon.visible[pos]) { CellEmitter.bottom( pos ).start( EarthParticle.FACTORY, 0.05f, 8 ); Camera.main.shake( 1, 0.4f ); } }
Example #21
Source File: CavesBossLevel.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void pressHero(int cell, Hero hero) { super.pressHero( cell, hero ); if (!enteredArena && outsideEntranceRoom( cell ) && hero == Dungeon.hero) { enteredArena = true; int pos; do { pos = Random.Int(getLength()); } while ( !passable[pos] || !outsideEntranceRoom(pos ) || Dungeon.visible[pos]); spawnBoss(pos); set( arenaDoor, Terrain.WALL ); GameScene.updateMap( arenaDoor ); Dungeon.observe(); CellEmitter.get( arenaDoor ).start( Speck.factory( Speck.ROCK ), 0.07f, 10 ); Camera.main.shake( 3, 0.7f ); Sample.INSTANCE.play( Assets.SND_ROCKS ); } }
Example #22
Source File: RottingFistSprite.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void onComplete( Animation anim ) { super.onComplete( anim ); if (anim == attack) { speed.set( 0 ); acc.set( 0 ); place( ch.pos ); Camera.main.shake( 4, 0.2f ); } }
Example #23
Source File: DangerIndicator.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onClick() { if (Dungeon.hero.visibleEnemies() > 0) { Mob target = Dungeon.hero.visibleEnemy(enemyIndex++); HealthIndicator.instance.target(target == HealthIndicator.instance.target() ? null : target); if (Dungeon.hero.curAction == null && target != null && target.sprite != null) { Camera.main.target = null; Camera.main.focusOn(target.sprite); } } }
Example #24
Source File: CameraScrollTweener.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public CameraScrollTweener( Camera camera, PointF pos, float time ) { super( camera, time ); this.camera = camera; start = camera.scroll; end = pos; }
Example #25
Source File: FistSprite.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void onComplete( Animation anim ) { super.onComplete( anim ); if (anim == attack) { Camera.main.shake( 4, 0.2f ); } else if (anim == zap) { idle(); } }
Example #26
Source File: SurfaceScene.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public void destroy() { Badges.saveGlobal(); Camera.remove( viewport ); super.destroy(); }
Example #27
Source File: WandOfLightning.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
private void hit( Char ch, int damage ) { if (damage < 1) { return; } if (ch == Dungeon.hero) { Camera.main.shake( 2, 0.3f ); } affected.add( ch ); ch.damage( Level.water[ch.pos] && !ch.flying ? (int)(damage * 2) : damage, LightningTrap.LIGHTNING ); ch.sprite.centerEmitter().burst( SparkParticle.FACTORY, 3 ); ch.sprite.flash(); points[nPoints++] = ch.pos; HashSet<Char> ns = new HashSet<Char>(); for (int i=0; i < Level.NEIGHBOURS8.length; i++) { Char n = Actor.findChar( ch.pos + Level.NEIGHBOURS8[i] ); if (n != null && !affected.contains( n )) { ns.add( n ); } } if (ns.size() > 0) { hit( Random.element( ns ), Random.Int( damage / 2, damage ) ); } }
Example #28
Source File: HeroSprite.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void move( int from, int to ) { super.move( from, to ); if (ch.flying) { play( fly ); } Camera.main.target = this; }
Example #29
Source File: Earthroot.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public void effect(int pos, Presser ch) { if (ch instanceof Char) { Char chr = (Char)ch; Armor buff = Buff.affect(chr, Armor.class); buff.level = chr.ht(); } if (Dungeon.visible[pos]) { CellEmitter.bottom(pos).start(EarthParticle.FACTORY, 0.05f, 8); Camera.main.shake(1, 0.4f); } }
Example #30
Source File: CameraScrollTweener.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
public CameraScrollTweener( Camera camera, PointF pos, float time ) { super( camera, time ); this.camera = camera; start = camera.scroll; end = pos; }