Java Code Examples for org.newdawn.slick.Image

The following examples show how to use org.newdawn.slick.Image. These examples are extracted from open source projects. 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 Project: opsu-dance   Source File: Slider.java    License: GNU General Public License v3.0 7 votes vote down vote up
/**
 * Initializes the Slider data type with images and dimensions.
 * @param circleDiameter the circle diameter
 * @param beatmap the associated beatmap
 */
public static void init(float circleDiameter, Beatmap beatmap) {
	followRadius = circleDiameter / 2 * 3f;
	int diameterInt = (int) circleDiameter;

	// slider ball
	if (GameImage.SLIDER_BALL.hasBeatmapSkinImages() ||
	    (!GameImage.SLIDER_BALL.hasBeatmapSkinImage() && GameImage.SLIDER_BALL.getImages() != null))
		sliderBallImages = GameImage.SLIDER_BALL.getImages();
	else
		sliderBallImages = new Image[]{ GameImage.SLIDER_BALL.getImage() };
	for (int i = 0; i < sliderBallImages.length; i++)
		sliderBallImages[i] = sliderBallImages[i].getScaledCopy(diameterInt, diameterInt);

	GameImage.SLIDER_FOLLOWCIRCLE.setImage(GameImage.SLIDER_FOLLOWCIRCLE.getImage().getScaledCopy(diameterInt * 259 / 128, diameterInt * 259 / 128));
	GameImage.REVERSEARROW.setImage(GameImage.REVERSEARROW.getImage().getScaledCopy(diameterInt, diameterInt));
	GameImage.SLIDER_TICK.setImage(GameImage.SLIDER_TICK.getImage().getScaledCopy(diameterInt / 4, diameterInt / 4));

	sliderMultiplier = beatmap.sliderMultiplier;
	sliderTickRate = beatmap.sliderTickRate;
}
 
Example 2
Source Project: opsu   Source File: InputOverlayKey.java    License: GNU General Public License v3.0 7 votes vote down vote up
/**
 * Renders this key.
 * @param g the graphics context
 * @param x the x position
 * @param y the y position
 * @param baseImage the key image
 */
public void render(Graphics g, int x, int y, Image baseImage) {
	g.pushTransform();
	float scale = 1f;
	if (downtime > 0) {
		float progress = downtime / (float) ANIMATION_TIME;
		scale -= (1f - ACTIVE_SCALE) * progress;
		g.scale(scale, scale);
		x /= scale;
		y /= scale;
	}
	baseImage.drawCentered(x, y, down ? activeColor : Color.white);
	x -= Fonts.MEDIUMBOLD.getWidth(text) / 2;
	y -= Fonts.MEDIUMBOLD.getLineHeight() / 2;
	/*
	// shadow (TODO)
	g.pushTransform();
	g.scale(1.1f, 1.1f);
	float shadowx = x / 1.1f - Fonts.MEDIUMBOLD.getWidth(text) * 0.05f;
	float shadowy = y / 1.1f - Fonts.MEDIUMBOLD.getLineHeight() * 0.05f;
	Fonts.MEDIUMBOLD.drawString(shadowx, shadowy, text, Color.black);
	g.popTransform();
	*/
	Fonts.MEDIUMBOLD.drawString(x, y, text, Options.getSkin().getInputOverlayText());
	g.popTransform();
}
 
Example 3
Source Project: opsu-dance   Source File: Curve.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the curve in the range [0, t] (where the full range is [0, 1]) to the graphics context.
 * @param color the color filter
 * @param from index to draw from
 * @param to index to draw to (exclusive)
 */
public void draw(Color color, int from, int to) {
	if (curve == null)
		return;

	if (OPTION_FALLBACK_SLIDERS.state || SkinService.skin.getSliderStyle() == Skin.STYLE_PEPPYSLIDER || !mmsliderSupported) {
		// peppysliders
		Image hitCircle = GameImage.HITCIRCLE.getImage();
		Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
		for (int i = from; i < to; i++)
			hitCircleOverlay.drawCentered(curve[i].x, curve[i].y, Colors.WHITE_FADE);
		float a = fallbackSliderColor.a;
		fallbackSliderColor.a = color.a;
		for (int i = from; i < to; i++)
			hitCircle.drawCentered(curve[i].x, curve[i].y, fallbackSliderColor);
		fallbackSliderColor.a = a;
	} else {
		// mmsliders
		if (renderState == null)
			renderState = new CurveRenderState(hitObject, curve, false);
		renderState.draw(color, borderColor, from, to);
	}
}
 
Example 4
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	this.container = container;
	
	image1 = new Image("testdata/grass.png");
	image2 = new Image("testdata/rocks.png");
	
	fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
	shape = new Rectangle(336,236,128,128);
    poly = new Polygon();
	poly.addPoint(320,220);
	poly.addPoint(350,200);
	poly.addPoint(450,200);
	poly.addPoint(480,220);
	poly.addPoint(420,400);
	poly.addPoint(400,390);
}
 
Example 5
/** 
 * Create an underlying graphics context for the given image
 * 
 * @param image The image we want to render to
 * @return The graphics context created
 * @throws SlickException
 */
private static Graphics createGraphics(Image image) throws SlickException {
	init();
	
	if (fbo) {
		try {
			return new FBOGraphics(image);
		} catch (Exception e) {
			fbo = false;
			Log.warn("FBO failed in use, falling back to PBuffer");
		}
	}
	
	if (pbuffer) {
		if (pbufferRT) {
			return new PBufferGraphics(image);
		} else {
			return new PBufferUniqueGraphics(image);
		}
	}
	
	throw new SlickException("Failed to create offscreen buffer even though the card reports it's possible");
}
 
Example 6
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	Image image = new Image("testdata/particle.tga", true);
	system = new ParticleSystem(image);
	
	system.addEmitter(new FireEmitter(400,300,45));
	system.addEmitter(new FireEmitter(200,300,60));
	system.addEmitter(new FireEmitter(600,300,30));
	
	//system.setUsePoints(true);
}
 
Example 7
/**
 * Load line clear effect images.
 */
public static void loadLineClearEffectImages() {
	String skindir = NullpoMinoSlick.propConfig.getProperty("custom.skin.directory", "res");

	if(imgBreak == null) {
		imgBreak = new Image[BLOCK_BREAK_MAX][BLOCK_BREAK_SEGMENTS];

		for(int i = 0; i < BLOCK_BREAK_MAX; i++) {
			for(int j = 0; j < BLOCK_BREAK_SEGMENTS; j++) {
				imgBreak[i][j] = loadImage(skindir + "/graphics/break" + i + "_" + j + ".png");
			}
		}
	}
	if(imgPErase == null) {
		imgPErase = new Image[PERASE_MAX];

		for(int i = 0; i < imgPErase.length; i++) {
			imgPErase[i] = loadImage(skindir + "/graphics/perase" + i + ".png");
		}
	}
}
 
Example 8
Source Project: opsu   Source File: Slider.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initializes the Slider data type with images and dimensions.
 * @param container the game container
 * @param circleDiameter the circle diameter
 * @param beatmap the associated beatmap
 */
public static void init(GameContainer container, float circleDiameter, Beatmap beatmap) {
	containerWidth = container.getWidth();
	containerHeight = container.getHeight();

	diameter = circleDiameter * HitObject.getXMultiplier();  // convert from Osupixels (640x480)
	int diameterInt = (int) diameter;

	followRadius = diameter / 2 * 3f;

	// slider ball
	if (GameImage.SLIDER_BALL.hasBeatmapSkinImages() ||
	    (!GameImage.SLIDER_BALL.hasBeatmapSkinImage() && GameImage.SLIDER_BALL.getImages() != null))
		sliderBallImages = GameImage.SLIDER_BALL.getImages();
	else
		sliderBallImages = new Image[]{ GameImage.SLIDER_BALL.getImage() };
	for (int i = 0; i < sliderBallImages.length; i++)
		sliderBallImages[i] = sliderBallImages[i].getScaledCopy(diameterInt * 118 / 128, diameterInt * 118 / 128);

	GameImage.SLIDER_FOLLOWCIRCLE.setImage(GameImage.SLIDER_FOLLOWCIRCLE.getImage().getScaledCopy(diameterInt * 259 / 128, diameterInt * 259 / 128));
	GameImage.REVERSEARROW.setImage(GameImage.REVERSEARROW.getImage().getScaledCopy(diameterInt, diameterInt));
	GameImage.SLIDER_TICK.setImage(GameImage.SLIDER_TICK.getImage().getScaledCopy(diameterInt / 4, diameterInt / 4));

	sliderMultiplier = beatmap.sliderMultiplier;
	sliderTickRate = beatmap.sliderTickRate;
}
 
Example 9
Source Project: opsu   Source File: Curve.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the curve in the range [0, t] (where the full range is [0, 1]) to the graphics context.
 * @param color the color filter
 * @param t set the curve interval to [0, t]
 */
public void draw(Color color, float t) {
	if (curve == null)
		return;

	t = Utils.clamp(t, 0f, 1f);

	// peppysliders
	if (Options.getSkin().getSliderStyle() == Skin.STYLE_PEPPYSLIDER || !mmsliderSupported) {
		int drawUpTo = (int) (curve.length * t);
		Image hitCircle = GameImage.HITCIRCLE.getImage();
		Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
		for (int i = 0; i < drawUpTo; i++)
			hitCircleOverlay.drawCentered(curve[i].x, curve[i].y, Colors.WHITE_FADE);
		for (int i = 0; i < drawUpTo; i++)
			hitCircle.drawCentered(curve[i].x, curve[i].y, color);
	}

	// mmsliders
	else {
		if (renderState == null)
			renderState = new CurveRenderState(hitObject, curve);
		renderState.draw(color, borderColor, t);
	}
}
 
Example 10
Source Project: opsu   Source File: LegacyCurveRenderState.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Reads the first row of the slider gradient texture and upload it as
 * a 1D texture to OpenGL if it hasn't already been done.
 */
public void initGradient() {
	if (gradientTexture == 0) {
		Image slider = GameImage.SLIDER_GRADIENT_EXPERIMENTAL.getImage().getScaledCopy(1.0f / GameImage.getUIscale());
		staticState.gradientTexture = GL11.glGenTextures();
		ByteBuffer buff = BufferUtils.createByteBuffer(slider.getWidth() * 4);
		for (int i = 0; i < slider.getWidth(); ++i) {
			Color col = slider.getColor(i, 0);
			buff.put((byte) (255 * col.r));
			buff.put((byte) (255 * col.g));
			buff.put((byte) (255 * col.b));
			buff.put((byte) (255 * col.a));
		}
		buff.flip();
		GL11.glBindTexture(GL11.GL_TEXTURE_1D, gradientTexture);
		GL11.glTexImage1D(GL11.GL_TEXTURE_1D, 0, GL11.GL_RGBA, slider.getWidth(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buff);
		EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_1D);
	}
}
 
Example 11
Source Project: opsu   Source File: CurveRenderState.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Reads the first row of the slider gradient texture and upload it as
 * a 1D texture to OpenGL if it hasn't already been done.
 */
public void initGradient() {
	if (gradientTexture == 0) {
		Image slider = GameImage.SLIDER_GRADIENT.getImage().getScaledCopy(1.0f / GameImage.getUIscale());
		staticState.gradientTexture = GL11.glGenTextures();
		ByteBuffer buff = BufferUtils.createByteBuffer(slider.getWidth() * 4);
		for (int i = 0; i < slider.getWidth(); ++i) {
			Color col = slider.getColor(i, 0);
			buff.put((byte) (255 * col.r));
			buff.put((byte) (255 * col.g));
			buff.put((byte) (255 * col.b));
			buff.put((byte) (255 * col.a));
		}
		buff.flip();
		GL11.glBindTexture(GL11.GL_TEXTURE_1D, gradientTexture);
		GL11.glTexImage1D(GL11.GL_TEXTURE_1D, 0, GL11.GL_RGBA, slider.getWidth(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buff);
		ContextCapabilities capabilities = GLContext.getCapabilities();
		if (capabilities.OpenGL30) {
			GL30.glGenerateMipmap(GL11.GL_TEXTURE_1D);
		} else if (capabilities.GL_EXT_framebuffer_object) {
			EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_1D);
		} else {
			GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
		}
	}
}
 
Example 12
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
	super(container);

	area = shape;
	normalImage = image;
	currentImage = image;
	mouseOverImage = image;
	mouseDownImage = image;

	currentColor = normalColor;

	state = NORMAL;
	Input input = container.getInput();
	over = area.contains(input.getMouseX(), input.getMouseY());
	mouseDown = input.isMouseButtonDown(0);
	updateImage();
}
 
Example 13
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	image.draw(0,0);
	image.draw(500,0,200,100);
	scaleMe.draw(500,100,200,100);
	scaled.draw(400,500);
	Image flipped = scaled.getFlippedCopy(true, false);
	flipped.draw(520,500);
	Image flipped2 = flipped.getFlippedCopy(false, true);
	flipped2.draw(520,380);
	Image flipped3 = flipped2.getFlippedCopy(true, false);
	flipped3.draw(400,380);
	
	for (int i=0;i<3;i++) {
		subImage.draw(200+(i*30),300);
	}
	
	g.translate(500, 200);
	g.rotate(50, 50, rot);
	g.scale(0.3f,0.3f);
	image.draw();
	g.resetTransform();
}
 
Example 14
Source Project: opsu   Source File: UI.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a tab image and text centered at a location.
 * @param x the center x coordinate
 * @param y the center y coordinate
 * @param text the text to draw inside the tab
 * @param selected whether the tab is selected (white) or not (red)
 * @param isHover whether to include a hover effect (unselected only)
 */
public static void drawTab(float x, float y, String text, boolean selected, boolean isHover) {
	Image tabImage = GameImage.MENU_TAB.getImage();
	float tabTextX = x - (Fonts.MEDIUM.getWidth(text) / 2);
	float tabTextY = y - (tabImage.getHeight() / 2);
	Color filter, textColor;
	if (selected) {
		filter = Color.white;
		textColor = Color.black;
	} else {
		filter = (isHover) ? Colors.RED_HOVER : Color.red;
		textColor = Color.white;
	}
	tabImage.drawCentered(x, y, filter);
	Fonts.MEDIUM.drawString(tabTextX, tabTextY, text, textColor);
}
 
Example 15
Source Project: opsu   Source File: UI.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the volume bar on the middle right-hand side of the game container.
 * Only draws if the volume has recently been changed using with {@link #changeVolume(int)}.
 * @param g the graphics context
 */
public static void drawVolume(Graphics g) {
	if (volumeDisplay == -1)
		return;

	int width = container.getWidth(), height = container.getHeight();
	Image img = GameImage.VOLUME.getImage();

	// move image in/out
	float xOffset = 0;
	float ratio = (float) volumeDisplay / VOLUME_DISPLAY_TIME;
	if (ratio <= 0.1f)
		xOffset = img.getWidth() * (1 - (ratio * 10f));
	else if (ratio >= 0.9f)
		xOffset = img.getWidth() * (1 - ((1 - ratio) * 10f));

	img.drawCentered(width - img.getWidth() / 2f + xOffset, height / 2f);
	float barHeight = img.getHeight() * 0.9f;
	float volume = Options.getMasterVolume();
	g.setColor(Color.white);
	g.fillRoundRect(
			width - (img.getWidth() * 0.368f) + xOffset,
			(height / 2f) - (img.getHeight() * 0.47f) + (barHeight * (1 - volume)),
			img.getWidth() * 0.15f, barHeight * volume, 3
	);
}
 
Example 16
Source Project: opsu   Source File: MenuButton.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Set x and y radius of the button based on current scale factor
 * and expansion direction.
 */
private void setHoverRadius() {
	Image image = this.img;
	if (image == null)
		image = anim.getCurrentFrame();

	int xOffset = 0, yOffset = 0;
	float currentScale = scale.getValue();
	if (dir != Expand.CENTER) {
		// offset by difference between normal/scaled image dimensions
		xOffset = (int) ((currentScale - 1f) * image.getWidth());
		yOffset = (int) ((currentScale - 1f) * image.getHeight());
		if (dir == Expand.UP || dir == Expand.DOWN)
			xOffset = 0;    // no horizontal offset
		if (dir == Expand.RIGHT || dir == Expand.LEFT)
			yOffset = 0;    // no vertical offset
		if (dir == Expand.RIGHT || dir == Expand.DOWN_RIGHT || dir == Expand.UP_RIGHT)
			xOffset *= -1;  // flip x for right
		if (dir == Expand.DOWN ||  dir == Expand.DOWN_LEFT || dir == Expand.DOWN_RIGHT)
			yOffset *= -1;  // flip y for down
	}
	this.xRadius = ((image.getWidth() * currentScale) + xOffset) / 2f;
	this.yRadius = ((image.getHeight() * currentScale) + yOffset) / 2f;
}
 
Example 17
/**
 * Set the image to use for this sprite sheet image to use for this tileset
 * 
 * @param image
 *            The image to use for this tileset
 */
public void setTileSetImage(Image image) {
	tiles = new SpriteSheet(image, tileWidth, tileHeight, tileSpacing,
			tileMargin);
	tilesAcross = tiles.getHorizontalCount();
	tilesDown = tiles.getVerticalCount();

	if (tilesAcross <= 0) {
		tilesAcross = 1;
	}
	if (tilesDown <= 0) {
		tilesDown = 1;
	}

	lastGID = (tilesAcross * tilesDown) + firstGID - 1;
}
 
Example 18
Source Project: opsu-dance   Source File: SlickUtil.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void destroyImages(Image[] imgs) {
	if (imgs == null) {
		return;
	}
	for (Image i : imgs) {
		destroyImage(i);
	}
}
 
Example 19
/**
 * Create a new graphics context around a pbuffer
 * 
 * @param image The image we're rendering to
 * @throws SlickException Indicates a failure to use pbuffers
 */
public PBufferUniqueGraphics(Image image) throws SlickException {
	super(image.getTexture().getTextureWidth(), image.getTexture().getTextureHeight());
	this.image = image;
	
	Log.debug("Creating pbuffer(unique) "+image.getWidth()+"x"+image.getHeight());
	if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
		throw new SlickException("Your OpenGL card does not support PBuffers and hence can't handle the dynamic images required for this application.");
	}

	init();
}
 
Example 20
Source Project: opsu-dance   Source File: TextureData.java    License: GNU General Public License v3.0 5 votes vote down vote up
public TextureData(Image image)
{
	this.image = image;
	this.width = image.getWidth();
	this.height = image.getHeight();
	this.width2 = this.width / 2f;
	this.height2 = this.height / 2f;
	Texture text = image.getTexture();
	this.id = text.getTextureID();
	this.txtw = text.getWidth();
	this.txth = text.getHeight();
}
 
Example 21
/**
 * Create a new graphics context around a pbuffer
 * 
 * @param image The image we're rendering to
 * @throws SlickException Indicates a failure to use pbuffers
 */
public PBufferGraphics(Image image) throws SlickException {
	super(image.getTexture().getTextureWidth(), image.getTexture().getTextureHeight());
	this.image = image;
	
	Log.debug("Creating pbuffer(rtt) "+image.getWidth()+"x"+image.getHeight());
	if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
		throw new SlickException("Your OpenGL card does not support PBuffers and hence can't handle the dynamic images required for this application.");
	}
	if ((Pbuffer.getCapabilities() & Pbuffer.RENDER_TEXTURE_SUPPORTED) == 0) {
		throw new SlickException("Your OpenGL card does not support Render-To-Texture and hence can't handle the dynamic images required for this application.");
	}

	init();
}
 
Example 22
Source Project: opsu-dance   Source File: GameData.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the large size grade image scaled for song menu use.
 */
public Image getMenuImage() {
	if (menuImage != null)
		return menuImage;

	Image img = getSmallImage();
	if (!small.hasBeatmapSkinImage())  // save default image only
		this.menuImage = img;
	return img;
}
 
Example 23
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	image = new Image("testdata/logo.png");
	
	width = image.getWidth() / 3;
	height = image.getHeight() / 3;
	
	images = new Image[] {
			image.getSubImage(0, 0, width, height), image.getSubImage(width,0,width,height), image.getSubImage(width*2,0,width,height),
			image.getSubImage(0, height, width, height), image.getSubImage(width,height,width,height), image.getSubImage(width*2,height,width,height),
			image.getSubImage(0, height*2, width, height), image.getSubImage(width,height*2,width,height), image.getSubImage(width*2,height*2,width,height),
	};
	
	images[0].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[1].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[1].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[2].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[3].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[3].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	
	images[4].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[4].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[4].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[4].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[5].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[5].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	
	images[6].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[7].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[7].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[8].setColor(Image.TOP_LEFT, 0,1,1,1);
}
 
Example 24
Source Project: opsu-dance   Source File: Game.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void revalidate() {
	super.revalidate();

	// create offscreen graphics
	try {
		offscreen = new Image(width, height);
		gOffscreen = offscreen.getGraphics();
		gOffscreen.setBackground(Color.black);
	} catch (SlickException e) {
		Log.error("could not create offscreen graphics", e);
		bubNotifs.send(
			BUB_RED,
			"Exception while creating offscreen graphics. See logfile for details."
		);
	}

	// initialize music position bar location
	musicBarX = width * 0.01f;
	musicBarY = height * 0.05f;
	musicBarWidth = Math.max(width * 0.005f, 7);
	musicBarHeight = height * 0.9f;

	// initialize scoreboard star stream
	scoreboardStarStream = new StarStream(0, height * 2f / 3f, width / 4, 0, 0);
	scoreboardStarStream.setPositionSpread(height / 20f);
	scoreboardStarStream.setDirectionSpread(10f);
	scoreboardStarStream.setDurationSpread(700, 100);

	// create the associated GameData object
	gameObjectRenderer.gameData = data = new GameData();
}
 
Example 25
/**
 * Create a new located image
 * 
 * @param image The image to be drawn
 * @param x The x location at which the image should be drawn
 * @param y The y location at which the image should be drawn
 */
public LocatedImage(Image image, int x, int y) {
	this.image = image;
	this.x = x;
	this.y = y;
	this.width = image.getWidth();
	this.height = image.getHeight();
}
 
Example 26
Source Project: opsu-dance   Source File: ButtonMenu.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Initializes the menu state.
 */
public void revalidate(Image button, Image buttonL, Image buttonR) {
	float baseY = getBaseY();
	float offsetY = button.getHeight() * 1.25f;

	menuButtons = new MenuButton[buttons.length];
	for (int i = 0; i < buttons.length; i++) {
		MenuButton b = new MenuButton(button, buttonL, buttonR, width2, baseY + (i * offsetY));
		b.setText(String.format("%d. %s", i + 1, buttons[i].getText()), Fonts.XLARGE, Color.white);
		b.setHoverFade();
		menuButtons[i] = b;
	}
}
 
Example 27
Source Project: opsu-dance   Source File: MainMenu.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void drawMenuButton(
	Image img,
	int x,
	int y,
	int clipxtop,
	int clipxbot,
	Color col)
{
	col.bind();
	final Texture t = img.getTexture();
	t.bind(); 
	
	final int width = img.getWidth();
	final int height = img.getHeight();
	final float twidth = t.getWidth();
	final float theight = t.getHeight();
	y -= height / 2;
	
	final float texXtop = clipxtop > 0 ? (float) clipxtop / width * twidth : 0f;
	final float texXbot = clipxbot > 0 ? (float) clipxbot / width * twidth : 0f;

	GL11.glBegin(SGL.GL_QUADS); 
	GL11.glTexCoord2f(texXtop, 0);
	GL11.glVertex3i(x + clipxtop, y, 0);
	GL11.glTexCoord2f(twidth, 0);
	GL11.glVertex3i(x + width, y, 0);
	GL11.glTexCoord2f(twidth, theight);
	GL11.glVertex3i(x + width, y + height, 0);
	GL11.glTexCoord2f(texXbot, theight);
	GL11.glVertex3i(x + clipxbot, y + height, 0);
	GL11.glEnd(); 
}
 
Example 28
Source Project: opsu-dance   Source File: GameRanking.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void revalidate() {
	super.revalidate();

	// buttons
	Image retry = GameImage.PAUSE_RETRY.getImage();
	Image replay = GameImage.PAUSE_REPLAY.getImage();
	replayY = height * 0.985f - replay.getHeight() / 2f;
	retryY = replayY - (replay.getHeight() / 2f) - (retry.getHeight() / 1.975f);
	retryButton = new MenuButton(retry, width - (retry.getWidth() / 2f), retryY);
	replayButton = new MenuButton(replay, width - (replay.getWidth() / 2f), replayY);
	retryButton.setHoverFade();
	replayButton.setHoverFade();
}
 
Example 29
Source Project: opsu-dance   Source File: StarFountain.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Initializes the star fountain.
 * @param containerWidth the container width
 * @param containerHeight the container height
 */
public StarFountain(int containerWidth, int containerHeight) {
	Image img = GameImage.STAR2.getImage();
	float xOffset = containerWidth * 0.125f;
	this.xDirection = containerWidth / 2f - xOffset;
	this.yDirection = -containerHeight * 0.85f;
	this.left = new StarStream(xOffset - img.getWidth() / 2f, containerHeight, 0, yDirection, 0);
	this.right = new StarStream(containerWidth - xOffset - img.getWidth() / 2f, containerHeight, 0, yDirection, 0);
	left.setScaleSpread(1.1f, 0.2f);
	right.setScaleSpread(1.1f, 0.2f);
}
 
Example 30
Source Project: opsu-dance   Source File: MenuButton.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new button from an Image.
 * @param img the image
 * @param x the center x coordinate
 * @param y the center y coordinate
 */
public MenuButton(Image img, float x, float y) {
	this.img = img;
	this.x = x;
	this.y = y;
	this.xRadius = img.getWidth() / 2f;
	this.yRadius = img.getHeight() / 2f;
}