org.newdawn.slick.Color Java Examples

The following examples show how to use org.newdawn.slick.Color. 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: nullpomino   Author: nullpomino   File: RendererSlick.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static Color getMeterColorAsColor(int meterColor) {
	switch(meterColor) {
	case GameEngine.METER_COLOR_PINK:		return new Color(255,  0,255);
	case GameEngine.METER_COLOR_PURPLE:		return new Color(128,  0,255);
	case GameEngine.METER_COLOR_DARKBLUE:	return new Color(  0,  0,128);
	case GameEngine.METER_COLOR_BLUE:		return Color.blue;
	case GameEngine.METER_COLOR_CYAN:		return Color.cyan;
	case GameEngine.METER_COLOR_DARKGREEN:	return new Color(  0,128,  0);
	case GameEngine.METER_COLOR_GREEN:		return Color.green;
	case GameEngine.METER_COLOR_YELLOW:		return Color.yellow;
	case GameEngine.METER_COLOR_ORANGE:		return Color.orange;
	case GameEngine.METER_COLOR_RED:		return Color.red;
	}
	
	return Color.white;
}
 
Example #2
Source Project: slick2d-maven   Author: nguillaumin   File: GradientTest.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	
	g.rotate(400, 300, ang);
	g.fill(rect, gradient);
	g.fill(round, gradient);
	g.fill(poly, gradient2);
	g.fill(center, gradient4);

	g.setAntiAlias(true);
	g.setLineWidth(10);
	g.draw(round2, gradient2);
	g.setLineWidth(2);
	g.draw(poly, gradient);
	g.setAntiAlias(false);
	
	g.fill(center, gradient4);
	g.setAntiAlias(true);
	g.setColor(Color.black);
	g.draw(center);
	g.setAntiAlias(false);
}
 
Example #3
Source Project: slick2d-maven   Author: nguillaumin   File: BlobbyTransition.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.state.transition.Transition#preRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void preRender(StateBasedGame game, GameContainer container,
		Graphics g) throws SlickException {
	prev.render(container, game, g);
	
	MaskUtil.defineMask();
	for (int i=0;i<blobs.size();i++) {
		((Blob) blobs.get(i)).render(g);
	}
	MaskUtil.finishDefineMask();

	MaskUtil.drawOnMask();
	if (background != null) {
		Color c = g.getColor();
		g.setColor(background);
		g.fillRect(0,0,container.getWidth(),container.getHeight());
		g.setColor(c);
	}
}
 
Example #4
Source Project: FEMultiPlayer-V2   Author: eliatlarge   File: Grid.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Can seize.
 *
 * @param u the u
 * @return true, if successful
 */
public boolean canSeize(Unit u) {
	//check if lord
	if(!u.getTheClass().name.equals("Lord"))
		return false;
	Color c = u.getPartyColor();
	if(c.equals(Party.TEAM_BLUE) 
			&& u.getXCoord() == redThroneX
			&& u.getYCoord() == redThroneY) {
		return true;
	} else if (c.equals(Party.TEAM_RED)
			&& u.getXCoord() == blueThroneX
			&& u.getYCoord() == blueThroneY){
		return true;
	}
	return false;
}
 
Example #5
Source Project: slick2d-maven   Author: nguillaumin   File: TestState1.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.state.BasicGameState#keyReleased(int, char)
 */
public void keyReleased(int key, char c) {
	
	if (key == Input.KEY_2) {
		GameState target = game.getState(TestState2.ID);
		
		final long start = System.currentTimeMillis();
		CrossStateTransition t = new CrossStateTransition(target) {				
			public boolean isComplete() {
				return (System.currentTimeMillis() - start) > 2000;
			}

			public void init(GameState firstState, GameState secondState) {
			}
		};
		
		game.enterState(TestState2.ID, t, new EmptyTransition());
	}
	if (key == Input.KEY_3) {
		game.enterState(TestState3.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
	}
}
 
Example #6
Source Project: opsu   Author: itdelatrisu   File: Beatmap.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the {@link #combo} field formatted as a string,
 * or null if the field is null or the default combo.
 */
public String comboToString() {
	if (combo == null)
		return null;

	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < combo.length; i++) {
		Color c = combo[i];
		sb.append(c.getRed());
		sb.append(',');
		sb.append(c.getGreen());
		sb.append(',');
		sb.append(c.getBlue());
		sb.append('|');
	}
	if (sb.length() > 0)
		sb.setLength(sb.length() - 1);
	return sb.toString();
}
 
Example #7
Source Project: FEMultiplayer   Author: chudooder   File: OverworldFightTransition.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void render() {
	float delta = Game.getDeltaSeconds();
	// Render fight stage (with transparency)
	Renderer.drawRectangle(0, 0, Game.getWindowWidth(), Game.getWindowHeight(), 0.0f, 
			new Color(0.0f, 0.0f, 0.0f, Math.min(1.0f, timer*5)));
	Renderer.setColor(new Color(1f, 1f, 1f, fightAlpha));
	if(timer > 0.4) fightAlpha += 6*delta;
	to.render();
	Renderer.setColor(null);
	// Render terrain zoom thing
	Color triColor = new Color(1.0f, 1.0f, 1.0f, triAlpha);
	for(int i=0; i<3; i++) {
		Renderer.drawTriangle(x[0], y[0], x[i], y[i], x[i+1], y[i+1], 0.0f, triColor);
		Renderer.drawTriangle(x[4], y[4], x[i+4], y[i+4], x[i+5], y[i+5], 0.0f, triColor);
	}
	if(timer > 0.3333) {
		triAlpha -= 3*delta;
	} else {
		for(int i=0; i<8; i++) {
			x[i] += dx[i]*delta;
			y[i] += dy[i]*delta;
		}
	}
	timer += delta;
	if(timer > LENGTH) done();
}
 
Example #8
Source Project: slick2d-maven   Author: nguillaumin   File: TestUtils.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Game loop render
 */
public void render() {
	Color.white.bind();
	texture.bind(); // or GL11.glBind(texture.getTextureID());
	
	GL11.glBegin(GL11.GL_QUADS);
		GL11.glTexCoord2f(0,0);
		GL11.glVertex2f(100,100);
		GL11.glTexCoord2f(1,0);
		GL11.glVertex2f(100+texture.getTextureWidth(),100);
		GL11.glTexCoord2f(1,1);
		GL11.glVertex2f(100+texture.getTextureWidth(),100+texture.getTextureHeight());
		GL11.glTexCoord2f(0,1);
		GL11.glVertex2f(100,100+texture.getTextureHeight());
	GL11.glEnd();
	
	font.drawString(150, 300, "HELLO LWJGL WORLD", Color.yellow);
}
 
Example #9
Source Project: slick2d-maven   Author: nguillaumin   File: ImageBufferEndianTest.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";
   
   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);
   
   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);
   
   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
 
Example #10
Source Project: opsu-dance   Author: yugecin   File: CursorColorManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void setComboColors(Color[] colors)
{
	if (colors.length == 0) {
		comboCols = new Color[] { Color.white };
		comboColors = new int[] { -1 };
	} else {
		comboCols = colors;
		comboColors = new int[colors.length];
		int i = colors.length;
		do {
			--i;
			comboColors[i] = col(colors[i]);
		} while (i > 0);
	}

	for (CursorColor impl : impls) {
		impl.onComboColorsChanged();
	}
}
 
Example #11
Source Project: slick2d-maven   Author: nguillaumin   File: RotateTransition.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void postRender(StateBasedGame game, GameContainer container, Graphics g) throws SlickException {
	g.translate(container.getWidth()/2, container.getHeight()/2);
	g.scale(scale,scale);
	g.rotate(0, 0, ang);
	g.translate(-container.getWidth()/2, -container.getHeight()/2);
	if (background != null) {
		Color c = g.getColor();
		g.setColor(background);
		g.fillRect(0,0,container.getWidth(),container.getHeight());
		g.setColor(c);
	}
	prev.render(container, game, g);
	g.translate(container.getWidth()/2, container.getHeight()/2);
	g.rotate(0, 0, -ang);
	g.scale(1/scale,1/scale);
	g.translate(-container.getWidth()/2, -container.getHeight()/2);
}
 
Example #12
Source Project: FEMultiplayer   Author: chudooder   File: Renderer.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void drawRectangle(float x0, float y0, float x1, float y1,
		float depth, Color c0, Color c1, Color c2, Color c3) {
	glDisable(GL_TEXTURE_2D);
	glBegin(GL_QUADS);
	c0 = c0.multiply(color);
	c1 = c1.multiply(color);
	c2 = c2.multiply(color);
	c3 = c3.multiply(color);
	glColor4f(c0.r, c0.g, c0.b, c0.a);
	glVertex3f(x0, y0, depth);
	glColor4f(c1.r, c1.g, c1.b, c1.a);
	glVertex3f(x1, y0, depth);
	glColor4f(c2.r, c2.g, c2.b, c2.a);
	glVertex3f(x1, y1, depth);
	glColor4f(c3.r, c3.g, c3.b, c3.a);
	glVertex3f(x0, y1, depth);
	glEnd();
	glEnable(GL_TEXTURE_2D);
	if(clip != null && !clip.persistent) clip.destroy();
}
 
Example #13
Source Project: opsu-dance   Author: yugecin   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 #14
Source Project: opsu   Author: itdelatrisu   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: FEMultiplayer   Author: chudooder   File: LoadStage.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void render(){
	int width = (int) (percent * 436);
	glClear(GL_COLOR_BUFFER_BIT |
	        GL_DEPTH_BUFFER_BIT |
	        GL_STENCIL_BUFFER_BIT);
	glClearDepth(1.0f);
	Renderer.drawString("default_med", "FE: Multiplayer is loading...", 22, 262, 0);
	String percentText = (int)(percent * 100) + "%";
	int pwidth = FEResources.getBitmapFont("default_med").getStringWidth(percentText);
	Renderer.drawString("default_med", percentText, 458 - pwidth, 263, 0);
	Renderer.drawRectangle(20, 280, 460, 300, 0, Color.gray);
	Renderer.drawRectangle(22, 282, 22+width, 298, 0, Color.blue.darker());
	Display.update();
}
 
Example #16
Source Project: FEMultiPlayer-V2   Author: eliatlarge   File: ConfirmationMessage.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void render(){
	Renderer.drawRectangle(0, 0, 480, 320, renderDepth, new Color(0,0,0,0.5f));
	Renderer.drawBorderedRectangle(x, y, x+100, y+40, renderDepth,
			FightStage.NEUTRAL, FightStage.BORDER_LIGHT, FightStage.BORDER_DARK);
	Renderer.drawString("default_med", "Are you sure?", x+2, y+2, renderDepth);
	if(yesHover) 
		Renderer.setColor(Color.green);
	Renderer.drawString("default_med", "YES", x+5, y+20, renderDepth);
	if(!yesHover) 
		Renderer.setColor(Color.green);
	else 
		Renderer.setColor(null);
	Renderer.drawString("default_med", "NO", x+55, y+20, renderDepth);
	Renderer.setColor(null);
}
 
Example #17
Source Project: FEMultiplayer   Author: chudooder   File: FightOverworldTransition.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void render() {
	float delta = Game.getDeltaSeconds();
	// Reverse the scaling of the fight stage
	Renderer.pushMatrix();
	Renderer.scale(0.5f, 0.5f);
	// Render overworld stage (with transparency)
	Renderer.drawRectangle(0, 0, Game.getWindowWidth(), Game.getWindowHeight(), 0.0f, 
			new Color(0.0f, 0.0f, 0.0f, Math.min(1.0f, timer*5)));
	Renderer.setColor(new Color(1f, 1f, 1f, fightAlpha));
	if(timer > 0.4) fightAlpha += 6*delta;
	to.render();
	Renderer.setColor(null);
	Renderer.popMatrix();
	// Render terrain zoom thing
	Color triColor = new Color(1.0f, 1.0f, 1.0f, triAlpha);
	for(int i=0; i<3; i++) {
		Renderer.drawTriangle(x[0], y[0], x[i], y[i], x[i+1], y[i+1], 0.0f, triColor);
		Renderer.drawTriangle(x[4], y[4], x[i+4], y[i+4], x[i+5], y[i+5], 0.0f, triColor);
	}
	if(timer < 0.3333) {
		triAlpha += 0.7f * 3 * delta;
	} else {
		for(int i=0; i<8; i++) {
			x[i] += dx[i]*delta;
			y[i] += dy[i]*delta;
		}
	}
	timer += delta;
	if(timer > LENGTH) done();
}
 
Example #18
Source Project: opsu   Author: itdelatrisu   File: Circle.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 * @param hitObject the associated HitObject
 * @param game the associated Game object
 * @param data the associated GameData object
 * @param color the color of this circle
 * @param comboEnd true if this is the last hit object in the combo
 */
public Circle(HitObject hitObject, Game game, GameData data, Color color, boolean comboEnd) {
	this.hitObject = hitObject;
	this.game = game;
	this.data = data;
	this.color = color;
	this.comboEnd = comboEnd;
	updatePosition();
}
 
Example #19
Source Project: slick2d-maven   Author: nguillaumin   File: TestState1.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see org.newdawn.slick.state.BasicGameState#render(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, StateBasedGame game, Graphics g) {
	g.setFont(font);
	g.setColor(Color.white);
	g.drawString("State Based Game Test", 100, 100);
	g.drawString("Numbers 1-3 will switch between states.", 150, 300);
	g.setColor(Color.red);
	g.drawString("This is State 1", 200, 50);
}
 
Example #20
Source Project: opsu   Author: itdelatrisu   File: ButtonMenu.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void click(GameContainer container, StateBasedGame game) {
	SoundController.playSound(SoundEffect.MENUHIT);
	try {
		Desktop.getDesktop().browse(OpsuConstants.REPOSITORY_URI);
	} catch (Exception e) {
		UI.getNotificationManager().sendNotification("The web page could not be opened.", Color.red);
	}
	game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition());
}
 
Example #21
Source Project: opsu-dance   Author: yugecin   File: GameObjectRenderer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void renderHitCircle(float x, float y, Color color, int comboNumber, float comboNumberAlpha) {
	renderHitCircleOnly(x, y, color);
	boolean overlayAboveNumber = SkinService.skin.isHitCircleOverlayAboveNumber();
	if (!overlayAboveNumber) {
		renderHitCircleOverlayOnly(x, y, Colors.WHITE_FADE);
	}
	renderComboNumberOnly(x, y, comboNumber, comboNumberAlpha);
	if (overlayAboveNumber) {
		renderHitCircleOverlayOnly(x, y, Colors.WHITE_FADE);
	}
}
 
Example #22
Source Project: FEMultiPlayer-V2   Author: eliatlarge   File: OptionsStage.java    License: GNU General Public License v3.0 5 votes vote down vote up
/** Return a color to use for this object */
protected Color getColor(final boolean columnSelected) {
	final boolean rowSelected = currentOptionIndex >= 0 && options[currentOptionIndex] == this;
	
	return (columnSelected ?
			(rowSelected ? new Color(90,200,90) : new Color(67, 150, 67)) :
			(rowSelected ? Color.white : new Color(192, 192, 192))
	);
}
 
Example #23
Source Project: opsu-dance   Author: yugecin   File: Node.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void drawButton(Color color, boolean isSelected)
{
	color = this.mixBackgroundColor(color, isSelected);
	glColor4f(color.r, color.g, color.b, color.a);
	glEnable(GL_TEXTURE_2D);
	glPushMatrix();
	glTranslatef(x, y, 0f);
	simpleTexturedQuadTopLeft(button);
	glPopMatrix();
}
 
Example #24
Source Project: opsu-dance   Author: yugecin   File: StoryboardOverlay.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRender(Graphics g) {
	if (!OPTION_DANCE_ENABLE_SB.state || hide) {
		return;
	}
	int lh = Fonts.SMALL.getLineHeight();
	Fonts.SMALL.drawString(10, height - 50 + lh, "save position: ctrl+s, load position: ctrl+l", Color.cyan);
	Fonts.SMALL.drawString(10, height - 50, "speed: C " + (speed / 10f) + " V", Color.cyan);
	Fonts.SMALL.drawString(10, height - 50 - lh, "Menu: N", Color.cyan);
	Fonts.SMALL.drawString(10, height - 50 - lh * 2, "HIDE: H", Color.cyan);
	Fonts.SMALL.drawString(10, height - 50 - lh * 3, "obj: J " + index + " K", Color.cyan);
	g.setColor(Color.red);
	if (index < optionsMap.length && optionsMap[index] != null) {
		int i = 0;
		for (Object o : optionsMap[index].entrySet()) {
			Map.Entry<Option, String> option = (Map.Entry<Option, String>) o;
			Fonts.SMALL.drawString(10, 50 + i * lh, option.getKey().name, Color.cyan);
			Fonts.SMALL.drawString(width / 5, 50 + i * lh, option.getKey().getValueString(), Color.cyan);
			g.fillRect(0, 50 + i * lh + lh / 4, 10, 10);
			i++;
		}
	}
	if (gameObjects.length > 0) {
		int start = gameObjects[0].getTime();
		int end = gameObjects[gameObjects.length - 1].getEndTime();
		float curtime = (float) (MusicController.getPosition() - start) / (end - start);
		g.fillRect(curtime * width, height - 10f, 10f, 10f);
	}
}
 
Example #25
Source Project: opsu-dance   Author: yugecin   File: CursorColorManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
static int col(Color color)
{
	return
		(color.getRedByte() << 16) |
		(color.getGreenByte() << 8) |
		(color.getBlueByte());
}
 
Example #26
Source Project: FEMultiplayer   Author: chudooder   File: TeamNameInput.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void render(){
	Renderer.drawRectangle(0, 0, 480, 320, renderDepth, new Color(0,0,0,0.5f));
	Renderer.drawBorderedRectangle(x-10, y-20, x+width+10, y+height +5, renderDepth,
			FightStage.NEUTRAL, FightStage.BORDER_LIGHT, FightStage.BORDER_DARK);
	Renderer.drawString("default_med", "Team Name:", x, y-15, renderDepth);
	BitmapFont font = FEResources.getBitmapFont("default_med");
	Renderer.drawRectangle(x, y, x+width, y+height, renderDepth, FOCUSED);
	float linepos = x + font.getStringWidth(input.substring(0, cursorPos)) + 2;
	Renderer.drawRectangle(linepos, y+1, linepos+1, y+height-1, renderDepth-0.02f, CURSOR);
	Renderer.drawString("default_med", input.toString(), x+2, y+5, renderDepth-0.01f);
}
 
Example #27
Source Project: slick2d-maven   Author: nguillaumin   File: NonGeometricData.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get an attribute value converted to a color. isColor should first be checked
 * 
 * @param attribute The attribute whose value should be interpreted as a color
 * @return The color based on the attribute
 */
public Color getAsColor(String attribute) {
	if (!isColor(attribute)) {
		throw new RuntimeException("Attribute "+attribute+" is not specified as a color:"+getAttribute(attribute));
	}
	
	int col = Integer.parseInt(getAttribute(attribute).substring(1), 16);
	
	return new Color(col);
}
 
Example #28
Source Project: opsu   Author: itdelatrisu   File: ButtonMenu.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void draw(GameContainer container, StateBasedGame game, Graphics g) {
	int width = container.getWidth();
	int height = container.getHeight();

	// score multiplier (TODO: fade in color changes)
	float mult = GameMod.getScoreMultiplier();
	String multString = String.format("Score Multiplier: %.2fx", mult);
	Color multColor = (mult == 1f) ? Color.white : (mult > 1f) ? Color.green : Color.red;
	float multY = Fonts.LARGE.getLineHeight() * 2 + height * 0.06f;
	Fonts.LARGE.drawString(
			(width - Fonts.LARGE.getWidth(multString)) / 2f,
			multY, multString, multColor);

	// category text
	for (GameMod.Category category : GameMod.Category.values()) {
		Fonts.LARGE.drawString(category.getX(),
				category.getY() - Fonts.LARGE.getLineHeight() / 2f,
				category.getName(), category.getColor());
	}

	// buttons
	for (GameMod mod : GameMod.values())
		mod.draw();

	super.draw(container, game, g);
}
 
Example #29
Source Project: slick2d-maven   Author: nguillaumin   File: SoundURLTest.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.setColor(Color.white);
	g.drawString("The OGG loop is now streaming from the file, woot.",100,60);
	g.drawString("Press space for sound effect (OGG)",100,100);
	g.drawString("Press P to pause/resume music (XM)",100,130);
	g.drawString("Press E to pause/resume engine sound (WAV)",100,190);
	g.drawString("Press enter for charlie (WAV)",100,160);
	g.drawString("Press C to change music",100,210);
	g.drawString("Press B to burp (AIF)",100,240);
	g.drawString("Press + or - to change volume of music", 100, 270);
	g.setColor(Color.blue);
	g.drawString("Music Volume Level: " + volume / 10.0f, 150, 300);
}
 
Example #30
Source Project: FEMultiplayer   Author: chudooder   File: FEMultiplayer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void connect(String nickname, String ip) {
	getLocalPlayer().setName(nickname);
	client = new Client(ip, 21255);
	if(client.isOpen()) {
		lobby = new ClientLobbyStage(client.getSession());
		setCurrentStage(lobby);
		client.start();
	} else {
		currentStage.addEntity(new Notification(
				180, 120, "default_med", "ERROR: Could not connect to the server!", 5f, new Color(255, 100, 100), 0f));
	}
}