org.newdawn.slick.Graphics Java Examples

The following examples show how to use org.newdawn.slick.Graphics. 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: slick2d-maven   Author: nguillaumin   File: ShapeTest.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.setColor(Color.green);
    
    for(int i=0;i<shapes.size();i++) {
        g.fill((Shape)shapes.get(i));
    }
    g.fill(randomShape);
    g.setColor(Color.black);
    g.setAntiAlias(true);
    g.draw(randomShape);
    g.setAntiAlias(false);
    
    g.setColor(Color.white);
    g.drawString("keys", 10, 300);
    g.drawString("wasd - move rectangle", 10, 315);
    g.drawString("WASD - resize rectangle", 10, 330);
    g.drawString("tgfh - move rounded rectangle", 10, 345);
    g.drawString("TGFH - resize rounded rectangle", 10, 360);
    g.drawString("ry - resize corner radius on rounded rectangle", 10, 375);
    g.drawString("ikjl - move ellipse", 10, 390);
    g.drawString("IKJL - resize ellipse", 10, 405);
    g.drawString("Arrows - move circle", 10, 420);
    g.drawString("Page Up/Page Down - resize circle", 10, 435);
    g.drawString("numpad 8546 - move polygon", 10, 450);
}
 
Example #2
Source Project: slick2d-maven   Author: nguillaumin   File: SlickCallableTest.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) throws SlickException {
	g.scale(2,2);
	g.fillRect(0, 0, 800, 600, back, 0, 0);
	g.resetTransform();
	
	g.drawImage(image,100,100);
	image.draw(100,200,80,200);
	
	font.drawString(100,200,"Text Drawn before the callable");
	
	SlickCallable callable = new SlickCallable() {
		protected void performGLOperations() throws SlickException {
			renderGL();
		}
	};
	callable.call();
	
	homer.draw(450,250,80,200);
	font.drawString(150,300,"Text Drawn after the callable");
}
 
Example #3
Source Project: opsu   Author: itdelatrisu   File: UI.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a scroll bar.
 * @param g the graphics context
 * @param position the position in the virtual area
 * @param totalLength the total length of the virtual area
 * @param lengthShown the length of the virtual area shown
 * @param unitBaseX the base x coordinate
 * @param unitBaseY the base y coordinate
 * @param unitWidth the width of a unit
 * @param scrollAreaHeight the height of the scroll area
 * @param bgColor the scroll bar area background color (null if none)
 * @param scrollbarColor the scroll bar color
 * @param right whether or not to place the scroll bar on the right side of the unit
 */
public static void drawScrollbar(
		Graphics g, float position, float totalLength, float lengthShown,
		float unitBaseX, float unitBaseY, float unitWidth, float scrollAreaHeight,
		Color bgColor, Color scrollbarColor, boolean right
) {
	float scrollbarWidth = container.getWidth() * 0.00347f;
	float scrollbarHeight = scrollAreaHeight * lengthShown / totalLength;
	float offsetY = (scrollAreaHeight - scrollbarHeight) * (position / (totalLength - lengthShown));
	float scrollbarX = unitBaseX + unitWidth - ((right) ? scrollbarWidth : 0);
	if (bgColor != null) {
		g.setColor(bgColor);
		g.fillRect(scrollbarX, unitBaseY, scrollbarWidth, scrollAreaHeight);
	}
	g.setColor(scrollbarColor);
	g.fillRect(scrollbarX, unitBaseY + offsetY, scrollbarWidth, scrollbarHeight);
}
 
Example #4
Source Project: slick2d-maven   Author: nguillaumin   File: GraphicsFactory.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** 
 * 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 #5
Source Project: opsu-dance   Author: yugecin   File: BubNotifState.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void render(Graphics g)
{
	if (bubbles.isEmpty()) {
		return;
	}
	synchronized (this.bubbles) {
		ListIterator<Notification> iter = bubbles.listIterator();
		addAnimationTime += renderDelta;
		if (addAnimationTime > IN_TIME) {
			finishAddAnimation();
		}
		boolean animateUp = false;
		do {
			Notification next = iter.next();
			if (animateUp && addAnimationTime < IN_TIME) {
				float progress = addAnimationTime * 2f / IN_TIME;
				progress = OUT_QUAD.calc(clamp(progress, 0f, 1f));
				next.y = next.baseY - (int) (addAnimationHeight * progress);
			}
			if (next.render(g, mouseX, mouseY, renderDelta)) {
				iter.remove();
			}
			animateUp = true;
		} while (iter.hasNext());
	}
}
 
Example #6
Source Project: slick2d-maven   Author: nguillaumin   File: ImageOutTest.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.drawString("T - TGA Snapshot", 10,50);
	g.drawString("J - JPG Snapshot", 10,70);
	g.drawString("P - PNG Snapshot", 10,90);

	g.setDrawMode(Graphics.MODE_ADD);
	g.drawImage(copy, 200, 300);
	g.setDrawMode(Graphics.MODE_NORMAL);
	
	g.drawString(message, 10,400);
	g.drawRect(200,0,400,300);
	g.translate(400, 250);
	fire.render();
	this.g = g;
}
 
Example #7
Source Project: opsu   Author: itdelatrisu   File: GamePauseMenu.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g)
		throws SlickException {
	// get background image
	GameImage bg = (gameState.getPlayState() == Game.PlayState.LOSE) ?
			GameImage.FAIL_BACKGROUND : GameImage.PAUSE_OVERLAY;

	// don't draw default background if button skinned and background unskinned
	boolean buttonsSkinned =
		GameImage.PAUSE_CONTINUE.hasBeatmapSkinImage() ||
		GameImage.PAUSE_RETRY.hasBeatmapSkinImage() ||
		GameImage.PAUSE_BACK.hasBeatmapSkinImage();
	if (!buttonsSkinned || bg.hasBeatmapSkinImage())
		bg.getImage().drawCentered(container.getWidth() / 2, container.getHeight() / 2);
	else
		g.setBackground(Color.black);

	// draw buttons
	if (gameState.getPlayState() != Game.PlayState.LOSE)
		continueButton.draw();
	retryButton.draw();
	backButton.draw();

	UI.draw(g);
}
 
Example #8
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 #9
Source Project: opsu-dance   Author: yugecin   File: ButtonMenu.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(Graphics g) {
	// 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;
	final float multX = width2 - Fonts.LARGE.getWidth(multString) / 2f;
	Fonts.LARGE.drawString(multX, 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.render(g);
}
 
Example #10
Source Project: slick2d-maven   Author: nguillaumin   File: FontTest.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) {
	font.drawString(80, 5, "A Font Example", Color.red);
	font.drawString(100, 32, "We - AV - Here is a more complete line that hopefully");
	font.drawString(100, 36 + font.getHeight("We Here is a more complete line that hopefully"), 
			             "will show some kerning.");
	
	font2.drawString(80, 85, "A Font Example", Color.red);
	font2.drawString(100, 132, "We - AV - Here is a more complete line that hopefully");
	font2.drawString(100, 136 + font2.getHeight("We - Here is a more complete line that hopefully"), 
			             "will show some kerning.");
	image.draw(100,400);
	
	String testStr = "Testing Font";
	font2.drawString(100, 300, testStr);
	g.setColor(Color.white);
	g.drawRect(100,300+font2.getYOffset(testStr),font2.getWidth(testStr),font2.getHeight(testStr)-font2.getYOffset(testStr));
	font.drawString(500, 300, testStr);
	g.setColor(Color.white);
	g.drawRect(500,300+font.getYOffset(testStr),font.getWidth(testStr),font.getHeight(testStr)-font.getYOffset(testStr));
}
 
Example #11
Source Project: opsu-dance   Author: yugecin   File: UI.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a scroll bar.
 * @param g the graphics context
 * @param position the position in the virtual area
 * @param totalLength the total length of the virtual area
 * @param lengthShown the length of the virtual area shown
 * @param unitBaseX the base x coordinate
 * @param unitBaseY the base y coordinate
 * @param unitWidth the width of a unit
 * @param scrollAreaHeight the height of the scroll area
 * @param bgColor the scroll bar area background color (null if none)
 * @param scrollbarColor the scroll bar color
 * @param right whether or not to place the scroll bar on the right side of the unit
 */
public static void drawScrollbar(
		Graphics g, float position, float totalLength, float lengthShown,
		float unitBaseX, float unitBaseY, float unitWidth, float scrollAreaHeight,
		Color bgColor, Color scrollbarColor, boolean right
) {
	float scrollbarWidth = width * 0.00347f;
	float scrollbarHeight = scrollAreaHeight * lengthShown / totalLength;
	float offsetY = (scrollAreaHeight - scrollbarHeight) * (position / (totalLength - lengthShown));
	float scrollbarX = unitBaseX + unitWidth - ((right) ? scrollbarWidth : 0);
	if (bgColor != null) {
		g.setColor(bgColor);
		g.fillRect(scrollbarX, unitBaseY, scrollbarWidth, scrollAreaHeight);
	}
	g.setColor(scrollbarColor);
	g.fillRect(scrollbarX, unitBaseY + offsetY, scrollbarWidth, scrollbarHeight);
}
 
Example #12
Source Project: slick2d-maven   Author: nguillaumin   File: AnimationTest.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.drawString("Space to restart() animation", 100, 50);
	g.drawString("Til Limited animation: "+start, 100, 500);
	g.drawString("Hold 1 to move the manually animated", 100, 70);
	g.drawString("PingPong Frame:"+pingPong.getFrame(), 600, 70);
	
	g.scale(-1,1);
	animation.draw(-100,100);
	animation.draw(-200,100,36*4,65*4);
	if (start < 0) {
		limited.draw(-400,100,36*4,65*4);
	}
	manual.draw(-600,100,36*4,65*4);
	pingPong.draw(-700,100,36*2,65*2);
}
 
Example #13
Source Project: nullpomino   Author: nullpomino   File: StateConfigMainMenu.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void renderImpl(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
	// Background
	g.drawImage(ResourceHolderSlick.imgMenu, 0, 0);

	// Menu
	NormalFontSlick.printFontGrid(1, 1, "OPTIONS", NormalFontSlick.COLOR_ORANGE);

	NormalFontSlick.printFontGrid(1, 3 + cursor, "b", NormalFontSlick.COLOR_RED);

	NormalFontSlick.printFontGrid(2, 3, "[GENERAL OPTIONS]", (cursor == 0));
	NormalFontSlick.printFontGrid(2, 4, "[RULE SELECT]:" + (player + 1) + "P", (cursor == 1));
	NormalFontSlick.printFontGrid(2, 5, "[GAME TUNING]:" + (player + 1) + "P", (cursor == 2));
	NormalFontSlick.printFontGrid(2, 6, "[AI SETTING]:" + (player + 1) + "P", (cursor == 3));
	NormalFontSlick.printFontGrid(2, 7, "[KEYBOARD SETTING]:" + (player + 1) + "P", (cursor == 4));
	NormalFontSlick.printFontGrid(2, 8, "[KEYBOARD NAVIGATION SETTING]:" + (player + 1) + "P", (cursor == 5));
	NormalFontSlick.printFontGrid(2, 9, "[KEYBOARD RESET]:" + (player + 1) + "P", (cursor == 6));
	NormalFontSlick.printFontGrid(2, 10, "[JOYSTICK SETTING]:" + (player + 1) + "P", (cursor == 7));

	NormalFontSlick.printTTFFont(16, 432, NullpoMinoSlick.getUIText(UI_TEXT[cursor]));
}
 
Example #14
Source Project: opsu   Author: itdelatrisu   File: ButtonMenu.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the title and buttons to the graphics context.
 * @param container the game container
 * @param game the game
 * @param g the graphics context
 */
public void draw(GameContainer container, StateBasedGame game, Graphics g) {
	// draw title
	if (actualTitle != null) {
		float marginX = container.getWidth() * 0.015f, marginY = container.getHeight() * 0.01f;
		int lineHeight = Fonts.LARGE.getLineHeight();
		for (int i = 0, size = actualTitle.size(); i < size; i++)
			Fonts.LARGE.drawString(marginX, marginY + (i * lineHeight), actualTitle.get(i), Color.white);
	}

	// draw buttons
	for (int i = 0; i < buttons.length; i++)
		menuButtons[i].draw(buttons[i].getColor());

	UI.draw(g);
}
 
Example #15
Source Project: slick2d-maven   Author: nguillaumin   File: ImageReadTest.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) {
	this.g = g;
	
	image.draw(100,100);
	g.setColor(Color.white);
	g.drawString("Move mouse over test image", 200, 20);
	g.setColor(read[0]);
	g.drawString(read[0].toString(), 100,300);
	g.setColor(read[1]);
	g.drawString(read[1].toString(), 150,320);
	g.setColor(read[2]);
	g.drawString(read[2].toString(), 200,340);
	g.setColor(read[3]);
	g.drawString(read[3].toString(), 250,360);
	if (read[4] != null) {
		g.setColor(read[4]);
		g.drawString("On image: "+read[4].toString(), 100,250);
	}
	if (read[5] != null) {
		g.setColor(Color.white);
		g.drawString("On screen: "+read[5].toString(), 100,270);
	}
}
 
Example #16
Source Project: nullpomino   Author: nullpomino   File: StateConfigJoystickMain.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void renderImpl(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
	// Menu
	g.drawImage(ResourceHolderSlick.imgMenu, 0, 0);

	NormalFontSlick.printFontGrid(1, 1, "JOYSTICK SETTING (" + (player+1) + "P)", NormalFontSlick.COLOR_ORANGE);

	NormalFontSlick.printFontGrid(1, 3 + cursor, "b", NormalFontSlick.COLOR_RED);

	NormalFontSlick.printFontGrid(2, 3, "[BUTTON SETTING]", (cursor == 0));
	NormalFontSlick.printFontGrid(2, 4, "[INPUT TEST]", (cursor == 1));
	NormalFontSlick.printFontGrid(2, 5, "JOYSTICK NUMBER:" + ((joyUseNumber == -1) ? "NOTHING" : String.valueOf(joyUseNumber)), (cursor == 2));
	NormalFontSlick.printFontGrid(2, 6, "JOYSTICK BORDER:" + joyBorder, (cursor == 3));
	NormalFontSlick.printFontGrid(2, 7, "IGNORE AXIS:" + GeneralUtil.getONorOFF(joyIgnoreAxis), (cursor == 4));
	NormalFontSlick.printFontGrid(2, 8, "IGNORE POV:" + GeneralUtil.getONorOFF(joyIgnorePOV), (cursor == 5));
	NormalFontSlick.printFontGrid(2, 9, "JOYSTICK METHOD:" + JOYSTICK_METHOD_STRINGS[joyMethod], (cursor == 6));

	if(cursor < UI_TEXT.length) NormalFontSlick.printTTFFont(16, 432, NullpoMinoSlick.getUIText(UI_TEXT[cursor]));
}
 
Example #17
Source Project: opsu-dance   Author: yugecin   File: StoryboardMover.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void render(Graphics g) {
	g.setColor(renderColor);
	for (float t = 0; t <= 1f; t += StoryboardMover.CALC_DRAW_INTERVAL) {
		float[] p = getPointAt(t);
		RenderUtils.fillCenteredRect(g, p[0], p[1], 1);
	}
}
 
Example #18
Source Project: opsu-dance   Author: yugecin   File: StoryboardMoveImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void render(Graphics g) {
	g.setColor(Color.red);
	int y = 200;
	for (StoryboardMover mover : movers) {
		mover.render(g);
		String text = mover.toString();
		Fonts.SMALL.drawString(screenWidth - Fonts.SMALL.getWidth(text) - 30, y, text);
		int dif = y;
		y += Fonts.SMALL.getLineHeight() * 1.1f;
		dif = y - dif;
		RenderUtils.fillCenteredRect(g, screenWidth - 20, y - dif / 2, 5);
	}
	movablePointCollectionRenderer.render(g);
}
 
Example #19
Source Project: opsu-dance   Author: yugecin   File: MoveStoryboard.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onRender(Graphics g) {
	btnAddLinear.render(g);
	btnAddQuadratic.render(g);
	btnAddCubic.render(g);
	btnAnimLin.render(g);
	btnAnimMid.render(g);
	btnAnimCub.render(g);
	if (moves[objectIndex] != null && objectIndex > 0 && trackPosition >= gameObjects[objectIndex - 1].getEndTime() && trackPosition < gameObjects[objectIndex].getTime()) {
		moves[objectIndex].render(g);
	}
}
 
Example #20
Source Project: opsu-dance   Author: yugecin   File: RenderUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void drawDottedLine(Graphics g, float fromX, float fromY, float toX, float toY, int dotAmount, int dotRadius) {
	float dx = (toX - fromX) / (dotAmount - 1);
	float dy = (toY - fromY) / (dotAmount - 1);
	for (; dotAmount > 0; dotAmount--) {
		fillCenteredRect(g, fromX, fromY, dotRadius);
		fromX += dx;
		fromY += dy;
	}
}
 
Example #21
Source Project: slick2d-maven   Author: nguillaumin   File: ScalableTest.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {
	g.setColor(new Color(0.4f,0.6f,0.8f));
	g.fillRect(0,0, 1024,568);
	g.setColor(Color.white);
	g.drawRect(5,5, 1024-10,568-10);
	
	g.setColor(Color.white);
	g.drawString(container.getInput().getMouseX()+","+container.getInput().getMouseY(), 10, 400);
	g.setColor(Color.red);
	g.fillOval(container.getInput().getMouseX()-10,container.getInput().getMouseY()-10,20,20);
}
 
Example #22
Source Project: opsu-dance   Author: yugecin   File: MovablePointCollectionRenderer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void renderWithDottedLines(Graphics g, Color lineColor, Vec2f start, Vec2f end) {
	g.setColor(lineColor);
	Vec2f lastPoint = start;
	for (Vec2f point : this) {
		if (lastPoint == null) {
			continue;
		}
		RenderUtils.drawDottedLine(g, lastPoint.x, lastPoint.y, point.x, point.y, 20, 0);
		lastPoint = point;
	}
	if (lastPoint != null && end != null) {
		RenderUtils.drawDottedLine(g, lastPoint.x, lastPoint.y, end.x, end.y, 20, 0);
	}
	render(g);
}
 
Example #23
Source Project: opsu-dance   Author: yugecin   File: MultiBeatmapNode.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
void draw(Graphics g, Node focusNode, Node selectedNode)
{
	final boolean isFocused = focusNode == this;

	Color textColor = SkinService.skin.getSongSelectInactiveTextColor();

	final Color buttonColor;
	if (isFocused) {
		buttonColor = Color.white;
		textColor = SkinService.skin.getSongSelectActiveTextColor();
	} else if (this.beatmaps[0].beatmapSet.isPlayed()) {
		buttonColor = BUTTON_ORANGE;
	} else {
		buttonColor = BUTTON_PINK;
	}
	final float oldalpha = buttonColor.a;
	buttonColor.a = 0.9f;
	super.drawButton(buttonColor, selectedNode == this);
	buttonColor.a = oldalpha;

	float cx = x + Node.cx;

	final Beatmap bm = this.beatmaps[0];

	// draw text
	if (OPTION_SHOW_UNICODE.state) {
		Fonts.loadGlyphs(titlefont, bm.titleUnicode);
		Fonts.loadGlyphs(artistfont, bm.artistUnicode);
	}
	titlefont.drawString(cx, y + titleYoffset, bm.getTitle(), textColor);
	final String author = bm.getArtist() + " // " + bm.creator;
	artistfont.drawString(cx, y + authorYoffset, author, textColor);
}
 
Example #24
Source Project: opsu-dance   Author: yugecin   File: NodeList.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void render(Graphics g)
{
	this.starStream.draw();
	for (int idx = this.firstIdxToDraw; idx < this.size; idx++) {
		final Node node = this.nodes[idx];
		if (node.y >= footerY) {
			break;
		}
		node.draw(g, this.focusNode, this.selectedNode);
	}

	final float scrollerY =
		this.scrolling.positionNorm * (this.scrollBarHeight - this.scrollerHeight);
	final float scrollerEnd = scrollerY + this.scrollerHeight;
	glDisable(GL_TEXTURE_2D);
	glPushMatrix();
	glTranslatef(width - 8f, this.scrollBarTopY, 0f);
	glColor4f(0f, 0f, 0f, .3f);
	glBegin(GL_QUADS);
	glVertex2f(0f, 0f);
	glVertex2f(8f, 0f);
	glVertex2f(8f, this.scrollBarHeight);
	glVertex2f(0f, this.scrollBarHeight);
	glColor3f(1f, 1f, 1f);
	glVertex2f(0f, scrollerY);
	glVertex2f(8f, scrollerY);
	glVertex2f(8f, scrollerEnd);
	glVertex2f(0f, scrollerEnd);
	glEnd();
	glPopMatrix();
}
 
Example #25
Source Project: opsu   Author: itdelatrisu   File: NotificationManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the notifications sent from {@link #sendNotification(String, Color)}.
 * @param g the graphics context
 */
private void drawNotifications(Graphics g) {
	int mouseX = input.getMouseX(), mouseY = input.getMouseY();
	synchronized (notifications) {
		for (BubbleNotification n : notifications) {
			if (!n.isFinished())
				n.draw(g, n.contains(mouseX, mouseY));
		}
	}
}
 
Example #26
Source Project: opsu   Author: itdelatrisu   File: Splash.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g)
		throws SlickException {
	g.setBackground(Color.black);
	GameImage.MENU_LOGO.getImage().drawCentered(container.getWidth() / 2, container.getHeight() / 2);
	UI.drawLoadingProgress(g, Options.isLoadVerbose() ? 1f : progressAlpha.getValue());
}
 
Example #27
Source Project: slick2d-maven   Author: nguillaumin   File: TileMapTest.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) {
	map.render(10, 10, 4,4,15,15);
	
	g.scale(0.35f,0.35f);
	map.render(1400, 0);
	g.resetTransform();
	
	g.drawString("map name: " + mapName, 10, 500);
	g.drawString("monster difficulty: " + monsterDifficulty, 10, 550);
	
	g.drawString("non existing map property: " + nonExistingMapProperty, 10, 525);
	g.drawString("non existing layer property: " + nonExistingLayerProperty, 10, 575);
}
 
Example #28
Source Project: slick2d-maven   Author: nguillaumin   File: SavedStateTest.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) {
	name.render(container, g);
	age.render(container, g);
	
	container.getDefaultFont().drawString(100, 300, "Stored Name: "+nameValue);
	container.getDefaultFont().drawString(100, 350, "Stored Age: "+ageValue);
	container.getDefaultFont().drawString(200, 500, message);
}
 
Example #29
Source Project: slick2d-maven   Author: nguillaumin   File: ParticleTest.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) {
	for (int i=0;i<100;i++) {
		g.translate(1,1);
		system.render();
	}
	g.resetTransform();
	g.drawString("Press space to toggle blending mode", 200, 500);
	g.drawString("Particle Count: "+(system.getParticleCount()*100), 200, 520);
}
 
Example #30
Source Project: opsu-dance   Author: yugecin   File: ButtonMenu.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void render(Graphics g) {
	super.render(g);

	g.setBackground(Color.black);
	if (menuState == null) {
		return;
	}
	menuState.render(g);
}