Java Code Examples for com.watabou.noosa.Game#height()

The following examples show how to use com.watabou.noosa.Game#height() . 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: ShatteredPixelDungeon.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void resize( int width, int height ) {
	if (width == 0 || height == 0){
		return;
	}

	if (scene instanceof PixelScene &&
			(height != Game.height || width != Game.width)) {
		PixelScene.noFade = true;
		((PixelScene) scene).saveWindows();
	}

	super.resize( width, height );

	updateDisplaySize();

}
 
Example 2
Source File: PixelScene.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public PixelCamera( float zoom ) {
	super(
			(int)(Game.width - Math.ceil( Game.width / zoom ) * zoom) / 2,
			(int)(Game.height - Math.ceil( Game.height / zoom ) * zoom) / 2,
			(int)Math.ceil( Game.width / zoom ),
			(int)Math.ceil( Game.height / zoom ), zoom );
	fullScreen = true;
}
 
Example 3
Source File: PixelScene.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
PixelCamera(float zoom) {
	super(
			(int) (Game.width() - Math.ceil(Game.width() / zoom) * zoom) / 2,
			(int) (Game.height() - Math.ceil(Game.height() / zoom)* zoom) / 2,
			(int) Math.ceil(Game.width() / zoom),
			(int) Math.ceil(Game.height() / zoom),
			zoom);
}
 
Example 4
Source File: Window.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void resize( int w, int h ) {
	this.width = w;
	this.height = h;
	
	chrome.size(
		width + chrome.marginHor(),
		height + chrome.marginVer() );
	
	camera.resize( (int)chrome.width, (int)chrome.height );
	camera.x = (int)(Game.width - camera.screenWidth()) / 2;
	camera.y = (int)(Game.height - camera.screenHeight()) / 2;
	camera.y += yOffset * camera.zoom;

	shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height );
}
 
Example 5
Source File: PixelScene.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public PixelCamera( float zoom ) {
	super(
		(int)(Game.width - Math.ceil( Game.width / zoom ) * zoom) / 2,
		(int)(Game.height - Math.ceil( Game.height / zoom ) * zoom) / 2,
		(int)Math.ceil( Game.width / zoom ),
		(int)Math.ceil( Game.height / zoom ), zoom );
	fullScreen = true;
}
 
Example 6
Source File: InputHandler.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean mouseMoved(int screenX, int screenY) {
	screenX /= (Game.dispWidth / (float)Game.width);
	screenY /= (Game.dispHeight / (float)Game.height);
	pointerHoverPos.x = screenX;
	pointerHoverPos.y = screenY;
	return true;
}
 
Example 7
Source File: InputHandler.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public synchronized boolean touchDragged(int screenX, int screenY, int pointer) {
	screenX /= (Game.dispWidth / (float)Game.width);
	screenY /= (Game.dispHeight / (float)Game.height);
	PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, true));
	return true;
}
 
Example 8
Source File: InputHandler.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public synchronized boolean touchDown(int screenX, int screenY, int pointer, int button) {
	screenX /= (Game.dispWidth / (float)Game.width);
	screenY /= (Game.dispHeight / (float)Game.height);
	PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, true));
	return true;
}
 
Example 9
Source File: Window.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void resize( int w, int h ) {
	this.width = w;
	this.height = h;
	
	chrome.size( 
		width + chrome.marginHor(),
		height + chrome.marginVer() );
	
	camera.resize( (int)chrome.width, (int)chrome.height );
	camera.x = (int)(Game.width - camera.screenWidth()) / 2;
	camera.y = (int)(Game.height - camera.screenHeight()) / 2;
	
	shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height );
}
 
Example 10
Source File: PixelScene.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public PixelCamera( float zoom ) {
	super( 
		(int)(Game.width - Math.ceil( Game.width / zoom ) * zoom) / 2, 
		(int)(Game.height - Math.ceil( Game.height / zoom ) * zoom) / 2, 
		(int)Math.ceil( Game.width / zoom ), 
		(int)Math.ceil( Game.height / zoom ), zoom );
}
 
Example 11
Source File: Window.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void resize( int w, int h ) {
	this.width = w;
	this.height = h;
	
	chrome.size( 
		width + chrome.marginHor(),
		height + chrome.marginVer() );
	
	camera.resize( (int)chrome.width, (int)chrome.height );
	camera.x = (int)(Game.width() - camera.screenWidth()) / 2;
	camera.y = (int)(Game.height() - camera.screenHeight()) / 2;
}
 
Example 12
Source File: Window.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public void resize( int w, int h ) {
	this.width = w;
	this.height = h;
	
	chrome.size( 
		width + chrome.marginHor(),
		height + chrome.marginVer() );
	
	camera.resize( (int)chrome.width, (int)chrome.height );
	camera.x = (int)(Game.width - camera.screenWidth()) / 2;
	camera.y = (int)(Game.height - camera.screenHeight()) / 2;
	
	shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height );
}
 
Example 13
Source File: PixelScene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public PixelCamera( float zoom ) {
	super( 
		(int)(Game.width - Math.ceil( Game.width / zoom ) * zoom) / 2, 
		(int)(Game.height - Math.ceil( Game.height / zoom ) * zoom) / 2, 
		(int)Math.ceil( Game.width / zoom ), 
		(int)Math.ceil( Game.height / zoom ), zoom );
}
 
Example 14
Source File: PixelScene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	
	super.create();
	
	GameScene.scene = null;
	
	float minWidth, minHeight;
	if (YetAnotherPixelDungeon.landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}
	
	defaultZoom = (int)Math.ceil( Game.density * 2.5 );
	while ((
		Game.width / defaultZoom < minWidth || 
		Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
		
		defaultZoom--;
	}
		
	if (YetAnotherPixelDungeon.scaleUp()) {
		while (
			Game.width / (defaultZoom + 1) >= minWidth && 
			Game.height / (defaultZoom + 1) >= minHeight) {
			
			defaultZoom++;
		}	
	}
	minZoom = 1;
	maxZoom = defaultZoom * 2;	
	
	Camera.reset( new PixelCamera( defaultZoom ) );
	
	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );
	
	if (font1x == null) {
		
		// 3x5 (6)
		font1x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL );
		font1x.baseLine = 6;
		font1x.tracking = -1;
		
		// 5x8 (10)
		font15x = Font.colorMarked( 
				BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL );
		font15x.baseLine = 9;
		font15x.tracking = -1;
		
		// 6x10 (12)
		font2x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL );
		font2x.baseLine = 11;
		font2x.tracking = -1;
		
		// 7x12 (15)
		font25x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL );
		font25x.baseLine = 13;
		font25x.tracking = -1;
		
		// 9x15 (18)
		font3x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL );
		font3x.baseLine = 17;
		font3x.tracking = -2;
	}
}
 
Example 15
Source File: PixelScene.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	
	super.create();
	
	GameScene.scene = null;
	
	float minWidth, minHeight;
	if (PixelDungeon.landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}
	
	defaultZoom = (int)Math.ceil( Game.density * 2.5 );
	while ((
		Game.width / defaultZoom < minWidth || 
		Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
		
		defaultZoom--;
	}
		
	if (PixelDungeon.scaleUp()) {
		while (
			Game.width / (defaultZoom + 1) >= minWidth && 
			Game.height / (defaultZoom + 1) >= minHeight) {
			
			defaultZoom++;
		}	
	}
	minZoom = 1;
	maxZoom = defaultZoom * 2;	
	
	Camera.reset( new PixelCamera( defaultZoom ) );
	
	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );
	
	if (font1x == null) {
		
		// 3x5 (6)
		font1x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL );
		font1x.baseLine = 6;
		font1x.tracking = -1;
		
		// 5x8 (10)
		font15x = Font.colorMarked( 
				BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL );
		font15x.baseLine = 9;
		font15x.tracking = -1;
		
		// 6x10 (12)
		font2x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL );
		font2x.baseLine = 11;
		font2x.tracking = -1;
		
		// 7x12 (15)
		font25x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL );
		font25x.baseLine = 13;
		font25x.tracking = -1;
		
		// 9x15 (18)
		font3x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL );
		font3x.baseLine = 17;
		font3x.tracking = -2;
	}
}
 
Example 16
Source File: SPDSettings.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public static boolean landscape() {
	return Game.width > Game.height;
}
 
Example 17
Source File: AndroidPlatformSupport.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public void updateDisplaySize(){
	if (SPDSettings.landscape() != null) {
		AndroidGame.instance.setRequestedOrientation( SPDSettings.landscape() ?
				ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
				ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
	}
	
	if (AndroidGame.view.getMeasuredWidth() == 0 || AndroidGame.view.getMeasuredHeight() == 0)
		return;
	
	Game.dispWidth = AndroidGame.view.getMeasuredWidth();
	Game.dispHeight = AndroidGame.view.getMeasuredHeight();

	boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
			|| !AndroidGame.instance.isInMultiWindowMode();

	if (fullscreen && SPDSettings.landscape() != null
			&& (Game.dispWidth >= Game.dispHeight) != SPDSettings.landscape()){
		int tmp = Game.dispWidth;
		Game.dispWidth = Game.dispHeight;
		Game.dispHeight = tmp;
	}
	
	float dispRatio = Game.dispWidth / (float)Game.dispHeight;
	
	float renderWidth = dispRatio > 1 ? PixelScene.MIN_WIDTH_L : PixelScene.MIN_WIDTH_P;
	float renderHeight = dispRatio > 1 ? PixelScene.MIN_HEIGHT_L : PixelScene.MIN_HEIGHT_P;
	
	//force power saver in this case as all devices must run at at least 2x scale.
	if (Game.dispWidth < renderWidth*2 || Game.dispHeight < renderHeight*2)
		SPDSettings.put( SPDSettings.KEY_POWER_SAVER, true );
	
	if (SPDSettings.powerSaver() && fullscreen){
		
		int maxZoom = (int)Math.min(Game.dispWidth/renderWidth, Game.dispHeight/renderHeight);
		
		renderWidth *= Math.max( 2, Math.round(1f + maxZoom*0.4f));
		renderHeight *= Math.max( 2, Math.round(1f + maxZoom*0.4f));
		
		if (dispRatio > renderWidth / renderHeight){
			renderWidth = renderHeight * dispRatio;
		} else {
			renderHeight = renderWidth / dispRatio;
		}
		
		final int finalW = Math.round(renderWidth);
		final int finalH = Math.round(renderHeight);
		if (finalW != Game.width || finalH != Game.height){
			
			AndroidGame.instance.runOnUiThread(new Runnable() {
				@Override
				public void run() {
					AndroidGame.view.getHolder().setFixedSize(finalW, finalH);
				}
			});
			
		}
	} else {
		AndroidGame.instance.runOnUiThread(new Runnable() {
			@Override
			public void run() {
				AndroidGame.view.getHolder().setSizeFromLayout();
			}
		});
	}
}
 
Example 18
Source File: PixelScene.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {

	super.create();

	GameScene.scene = null;

	float minWidth, minHeight;
	if (landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}

	maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight);
	maxScreenZoom = (int)Math.min(Game.dispWidth/minWidth, Game.dispHeight/minHeight);
	defaultZoom = SPDSettings.scale();

	if (defaultZoom < Math.ceil( Game.density * 2 ) || defaultZoom > maxDefaultZoom){
		defaultZoom = (int)Math.ceil( Game.density * 2.5 );
		while ((
			Game.width / defaultZoom < minWidth ||
			Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
			defaultZoom--;
		}
	}

	minZoom = 1;
	maxZoom = defaultZoom * 2;

	Camera.reset( new PixelCamera( defaultZoom ) );

	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );

	if (pixelFont == null) {

		// 3x5 (6)
		pixelFont = Font.colorMarked(
			BitmapCache.get( Assets.Fonts.PIXELFONT), 0x00000000, BitmapText.Font.LATIN_FULL );
		pixelFont.baseLine = 6;
		pixelFont.tracking = -1;
		
	}
	
	//set up the texture size which rendered text will use for any new glyphs.
	int renderedTextPageSize;
	if (defaultZoom <= 3){
		renderedTextPageSize = 256;
	} else if (defaultZoom <= 8){
		renderedTextPageSize = 512;
	} else {
		renderedTextPageSize = 1024;
	}
	//asian languages have many more unique characters, so increase texture size to anticipate that
	if (Messages.lang() == Languages.KOREAN ||
			Messages.lang() == Languages.CHINESE ||
			Messages.lang() == Languages.JAPANESE){
		renderedTextPageSize *= 2;
	}
	Game.platform.setupFontGenerators(renderedTextPageSize, SPDSettings.systemFont());
	
}
 
Example 19
Source File: PixelScene.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	
	super.create();
	
	GameScene.scene = null;

	float minWidth, minHeight;
	if (ShatteredPixelDungeon.landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}

	defaultZoom = (int)Math.ceil( Game.density * 2.5 );
	while ((
		Game.width / defaultZoom < minWidth ||
		Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
		
		defaultZoom--;
	}
		
	while (
			Game.width / (defaultZoom + 1) >= minWidth &&
			Game.height / (defaultZoom + 1) >= minHeight) {
		defaultZoom++;
	}

	minZoom = 1;
	maxZoom = defaultZoom * 2;
		
	
	Camera.reset( new PixelCamera( defaultZoom ) );
	
	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );
	
	if (font1x == null) {
		
		// 3x5 (6)
		font1x = Font.colorMarked(
			BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL );
		font1x.baseLine = 6;
		font1x.tracking = -1;
		
		// 5x8 (10)
		font15x = Font.colorMarked(
				BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL );
		font15x.baseLine = 9;
		font15x.tracking = -1;
		
		// 6x10 (12)
		font2x = Font.colorMarked(
			BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL );
		font2x.baseLine = 11;
		font2x.tracking = -1;
		
		// 7x12 (15)
		font25x = Font.colorMarked(
			BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL );
		font25x.baseLine = 13;
		font25x.tracking = -1;
		
		// 9x15 (18)
		font3x = Font.colorMarked(
			BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL );
		font3x.baseLine = 17;
		font3x.tracking = -2;
	}
}
 
Example 20
Source File: Ads.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private static boolean isSmallScreen() {
    return (Game.width() < 400 || Game.height() < 400);
}