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 File: GraphicsFactory.java    From slick2d-maven with 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 #2
Source File: ImageReadTest.java    From slick2d-maven with 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 #3
Source File: StateConfigJoystickMain.java    From nullpomino with 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 #4
Source File: ShapeTest.java    From slick2d-maven with 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 #5
Source File: UI.java    From opsu with 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 #6
Source File: SlickCallableTest.java    From slick2d-maven with 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 #7
Source File: ButtonMenu.java    From opsu with 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 #8
Source File: StateConfigMainMenu.java    From nullpomino with 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 #9
Source File: AnimationTest.java    From slick2d-maven with 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 #10
Source File: UI.java    From opsu-dance with 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 #11
Source File: BubNotifState.java    From opsu-dance with 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 #12
Source File: FontTest.java    From slick2d-maven with 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 #13
Source File: ImageOutTest.java    From slick2d-maven with 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 #14
Source File: ButtonMenu.java    From opsu-dance with 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 #15
Source File: GamePauseMenu.java    From opsu with 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 #16
Source File: GradientTest.java    From slick2d-maven with 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 #17
Source File: UI.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the global UI components: cursor, FPS, volume bar, tooltips, bar notifications.
 * @param g the graphics context
 */
public static void draw(Graphics g) {
	notificationManager.draw(g);
	drawVolume(g);
	drawFPS();
	cursor.draw();
	drawTooltip(g);
}
 
Example #18
Source File: StateConfigJoystickTest.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
	if(!container.hasFocus()) {
		if(!NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep();
		return;
	}

	ResourceHolderSlick.imgMenu.draw(0, 0);

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

	if(joyNumber < 0) {
		NormalFontSlick.printFontGrid(1, 3, "NO JOYSTICK", NormalFontSlick.COLOR_RED);
	} else if(frame >= KEYACCEPTFRAME) {
		NormalFontSlick.printFontGrid(1, 3, "JOYSTICK NUMBER:" + joyNumber, NormalFontSlick.COLOR_RED);

		NormalFontSlick.printFontGrid(1, 5, "LAST PRESSED BUTTON:" + ((lastPressButton == -1) ? "NONE" : String.valueOf(lastPressButton)));

		Controller controller = ControllerManager.controllers.get(joyNumber);

		NormalFontSlick.printFontGrid(1, 7, "AXIS X:" + controller.getXAxisValue());
		NormalFontSlick.printFontGrid(1, 8, "AXIS Y:" + controller.getYAxisValue());

		NormalFontSlick.printFontGrid(1, 10, "POV X:" + controller.getPovX());
		NormalFontSlick.printFontGrid(1, 11, "POV Y:" + controller.getPovY());
	}

	if(frame >= KEYACCEPTFRAME) {
		NormalFontSlick.printFontGrid(1, 23, "ENTER/BACKSPACE: EXIT", NormalFontSlick.COLOR_GREEN);
	}

	// FPS
	NullpoMinoSlick.drawFPS(container);
	// Observer
	NullpoMinoSlick.drawObserverClient();
	if(!NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep();
}
 
Example #19
Source File: SimpleDiagramRenderer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Render the diagram to the given graphics context
 * 
 * @param g The graphics context to which we should render the diagram
 */
public void render(Graphics g) {
	// last list generation
	if (list == -1) {
		list = GL.glGenLists(1);
		GL.glNewList(list, SGL.GL_COMPILE);
			render(g, diagram);
		GL.glEndList();
	}
	
	GL.glCallList(list);
	
	TextureImpl.bindNone();
}
 
Example #20
Source File: PolygonTest.java    From slick2d-maven with 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 {
	if (in) {
		g.setColor(Color.red);
		g.fill(poly);
	}
	g.setColor(Color.yellow);
	g.fillOval(poly.getCenterX()-3, poly.getCenterY()-3, 6, 6);
	g.setColor(Color.white);
	g.draw(poly);
}
 
Example #21
Source File: Scroller.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Draw a single tank to the game
 *  
 * @param g The graphics context on which we're drawing
 * @param xpos The x coordinate in tiles the tank is at
 * @param ypos The y coordinate in tiles the tank is at
 * @param rot The rotation of the tank
 */
public void drawTank(Graphics g, float xpos, float ypos, float rot) {
	// work out the centre of the tank in rendering coordinates and then
	// spit onto the screen
	int cx = (int) (xpos * 32);
	int cy = (int) (ypos * 32);
	g.rotate(cx,cy,rot);
	player.draw(cx-16,cy-16);
	g.rotate(cx,cy,-rot);
}
 
Example #22
Source File: UserSelectOverlay.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/** Renders the user selection menu. */
private void renderUserSelect(Graphics g, float alpha) {
	COLOR_WHITE.a = alpha;

	// title
	String title = "User Select";
	Fonts.XLARGE.drawString(
		x + (width - Fonts.XLARGE.getWidth(title)) / 2,
		(int) (y + titleY - scrolling.getPosition()),
		title, COLOR_WHITE
	);

	// users
	int cx = (int) (x + usersStartX);
	int cy = (int) (y + -scrolling.getPosition() + usersStartY);
	for (UserButton button : userButtons) {
		button.setPosition(cx, cy);
		if (cy < height)
			button.draw(g, alpha);
		cy += UserButton.getHeight() + usersPaddingY;
	}

	// scrollbar
	int scrollbarWidth = 10, scrollbarHeight = 45;
	float scrollbarX = x + width - scrollbarWidth;
	float scrollbarY = y + (scrolling.getPosition() / maxScrollOffset) * (height - scrollbarHeight);
	g.setColor(COLOR_WHITE);
	g.fillRect(scrollbarX, scrollbarY, scrollbarWidth, scrollbarHeight);
}
 
Example #23
Source File: EasedFadeOutTransition.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void postRender(StateBasedGame game, GameContainer container, Graphics g) {
	Color old = g.getColor();
	g.setColor(color);
	g.fillRect(0, 0, container.getWidth() * 2, container.getHeight() * 2);
	g.setColor(old);
}
 
Example #24
Source File: ButtonMenu.java    From opsu-dance with 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);
}
 
Example #25
Source File: PackedSheetTest.java    From slick2d-maven with 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) {
	rocket.draw((int) r,100);
	runner.draw(250,250);
	g.scale(1.2f,1.2f);
	runner.draw(250,250);
	g.scale(1.2f,1.2f);
	runner.draw(250,250);
	g.resetTransform();
	
	g.rotate(670, 470, ang);
	sheet.getSprite("floppy").draw(600,400);
}
 
Example #26
Source File: ParticleTest.java    From slick2d-maven with 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 #27
Source File: SavedStateTest.java    From slick2d-maven with 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 #28
Source File: FadeInTransition.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 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) {
	Color old = g.getColor();
	g.setColor(color);
	
	g.fillRect(0, 0, container.getWidth()*2, container.getHeight()*2);
	g.setColor(old);
}
 
Example #29
Source File: TileMapTest.java    From slick2d-maven with 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 #30
Source File: TestState2.java    From slick2d-maven with 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.green);
	g.drawString("This is State 2", 200, 50);
	
	g.rotate(400,300,ang);
	g.drawImage(image,400-(image.getWidth()/2),300-(image.getHeight()/2));
}