Java Code Examples for org.newdawn.slick.util.Log#info()

The following examples show how to use org.newdawn.slick.util.Log#info() . 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: GameContainer.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialise the GL context
 */
protected void initGL() {
	Log.info("Starting display "+width+"x"+height);
	GL.initDisplay(width, height);
	
	if (input == null) {
		input = new Input(height);
	}
	input.init(height);
	// no need to remove listeners?
	//input.removeAllListeners();
	if (game instanceof InputListener) {
		input.removeListener((InputListener) game);
		input.addListener((InputListener) game);
	}

	if (graphics != null) {
		graphics.setDimensions(getWidth(), getHeight());
	}
	lastGame = game;
}
 
Example 2
Source File: GameContainer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Initialise the GL context
 */
protected void initGL() {
	Log.info("Starting display "+width+"x"+height);
	GL.initDisplay(width, height);
	
	if (input == null) {
		input = new Input(height);
	}
	input.init(height);
	// no need to remove listeners?
	//input.removeAllListeners();
	if (game instanceof InputListener) {
		input.removeListener((InputListener) game);
		input.addListener((InputListener) game);
	}

	if (graphics != null) {
		graphics.setDimensions(getWidth(), getHeight());
	}
	lastGame = game;
}
 
Example 3
Source File: CursorLoader.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get a cursor based on a set of image data
 * 
 * @param buf The image data (stored in RGBA) to load the cursor from
 * @param x The x-coordinate of the cursor hotspot (left -> right)
 * @param y The y-coordinate of the cursor hotspot (bottom -> top)
 * @param width The width of the image data provided
 * @param height The height of the image data provided
 * @return The create cursor
 * @throws IOException Indicates a failure to load the image
 * @throws LWJGLException Indicates a failure to create the hardware cursor
 */
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
	for (int i=0;i<buf.limit();i+=4) {
		byte red = buf.get(i);
		byte green = buf.get(i+1);
		byte blue = buf.get(i+2);
		byte alpha = buf.get(i+3);
		
		buf.put(i+2, red);
		buf.put(i+1, green);
		buf.put(i, blue);
		buf.put(i+3, alpha);
	}
	
	try {
		int yspot = height - y - 1;
		if (yspot < 0) {
			yspot = 0;
		}
		return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
	} catch (Throwable e) {
		Log.info("Chances are you cursor is too small for this platform");
		throw new LWJGLException(e);
	}
}
 
Example 4
Source File: CursorLoader.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get a cursor based on a set of image data
 * 
 * @param imageData The data from which the cursor can read it's contents
 * @param x The x-coordinate of the cursor hotspot (left -> right)
 * @param y The y-coordinate of the cursor hotspot (bottom -> top)
 * @return The create cursor
 * @throws IOException Indicates a failure to load the image
 * @throws LWJGLException Indicates a failure to create the hardware cursor
 */
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
	ByteBuffer buf = imageData.getImageBufferData();
	for (int i=0;i<buf.limit();i+=4) {
		byte red = buf.get(i);
		byte green = buf.get(i+1);
		byte blue = buf.get(i+2);
		byte alpha = buf.get(i+3);
		
		buf.put(i+2, red);
		buf.put(i+1, green);
		buf.put(i, blue);
		buf.put(i+3, alpha);
	}
	
	try {
		int yspot = imageData.getHeight() - y - 1;
		if (yspot < 0) {
			yspot = 0;
		}
		return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
	} catch (Throwable e) {
		Log.info("Chances are you cursor is too small for this platform");
		throw new LWJGLException(e);
	}
}
 
Example 5
Source File: GraphicsFactory.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Initialise offscreen rendering by checking what buffers are supported
 * by the card
 * 
 * @throws SlickException Indicates no buffers are supported
 */
private static void init() throws SlickException {
	init = true;
	
	if (fbo) {
		fbo = GLContext.getCapabilities().GL_EXT_framebuffer_object;
	}
	pbuffer = (Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) != 0;
	pbufferRT = (Pbuffer.getCapabilities() & Pbuffer.RENDER_TEXTURE_SUPPORTED) != 0;
	
	if (!fbo && !pbuffer && !pbufferRT) {
		throw new SlickException("Your OpenGL card does not support offscreen buffers and hence can't handle the dynamic images required for this application.");
	}
	
	Log.info("Offscreen Buffers FBO="+fbo+" PBUFFER="+pbuffer+" PBUFFERRT="+pbufferRT);
}
 
Example 6
Source File: Environment.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
public Environment()
{
	if (Entrypoint.isJarRunning) {
		this.gitHash = null;
	} else {
		this.gitHash = this.findGitHash();
		Log.info("rev: " + this.gitHash);
	}
}
 
Example 7
Source File: DisplayContainer.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
private void postInitGL() throws Exception
{
	GL.initDisplay(width, height);
	GL.enterOrtho(width, height);

	this.glReady = true;
	this.glVersion = glGetString(GL_VERSION);
	this.glVendor = glGetString(GL_VENDOR);

	graphics = new Graphics(width, height);
	graphics.setAntiAlias(false);

	Keyboard.enableRepeatEvents(true);

	Log.info("GL ready");

	GameImage.onResolutionChanged();
	Fonts.init();

	if (volumeControl == null) {
		volumeControl = new VolumeControl();
	}

	destroyImages();
	reinit();
	VolumeControl.createProgram();

	barNotifs.onResolutionChanged(width, height);
	bubNotifs.onResolutionChanged(width, height);
	fpsDisplay.onResolutionChanged(width, height);
	for (ResolutionChangedListener l : this.resolutionChangedListeners) {
		l.onResolutionChanged(width, height);
	}
}
 
Example 8
Source File: GameContainer.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get the build number of slick 
 * 
 * @return The build number of slick
 */
public static int getBuildVersion() {
	try {
		Properties props = new Properties();
		props.load(ResourceLoader.getResourceAsStream("version"));
		
		int build = Integer.parseInt(props.getProperty("build"));
		Log.info("Slick Build #"+build);
		
		return build;
	} catch (Exception e) {
		Log.info("Unable to determine Slick build number");
		return -1;
	}
}
 
Example 9
Source File: AppletGameContainer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see java.applet.Applet#destroy()
 */
public void destroy() {
   if (displayParent != null) {
      remove(displayParent);
   }
   super.destroy();
   
   Log.info("Clear up");
}
 
Example 10
Source File: GameContainer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the build number of slick 
 * 
 * @return The build number of slick
 */
public static int getBuildVersion() {
	try {
		Properties props = new Properties();
		props.load(ResourceLoader.getResourceAsStream("version"));
		
		int build = Integer.parseInt(props.getProperty("build"));
		Log.info("Slick Build #"+build);
		
		return build;
	} catch (Exception e) {
		Log.error("Unable to determine Slick build number");
		return -1;
	}
}
 
Example 11
Source File: CursorLoader.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get a cursor based on a image reference on the classpath
 * 
 * @param ref The reference to the image to be loaded
 * @param x The x-coordinate of the cursor hotspot (left -> right)
 * @param y The y-coordinate of the cursor hotspot (bottom -> top)
 * @return The create cursor
 * @throws IOException Indicates a failure to load the image
 * @throws LWJGLException Indicates a failure to create the hardware cursor
 */
public Cursor getCursor(String ref,int x,int y) throws IOException, LWJGLException {
	LoadableImageData imageData = null;
	
	imageData = ImageDataFactory.getImageDataFor(ref);
	imageData.configureEdging(false);
	
	ByteBuffer buf = imageData.loadImage(ResourceLoader.getResourceAsStream(ref), true, true, null);
	for (int i=0;i<buf.limit();i+=4) {
		byte red = buf.get(i);
		byte green = buf.get(i+1);
		byte blue = buf.get(i+2);
		byte alpha = buf.get(i+3);
		
		buf.put(i+2, red);
		buf.put(i+1, green);
		buf.put(i, blue);
		buf.put(i+3, alpha);
	}
	
	try {
		int yspot = imageData.getHeight() - y - 1;
		if (yspot < 0) {
			yspot = 0;
		}
		
		return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
	} catch (Throwable e) {
		Log.info("Chances are you cursor is too small for this platform");
		throw new LWJGLException(e);
	}
}
 
Example 12
Source File: SavedState.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Quick test to see if running through Java webstart
 * 
 * @return True if jws running
 */
private boolean isWebstartAvailable() {
	try {
		Class.forName("javax.jnlp.ServiceManager");
		// this causes to go and see if the service is available
		ServiceManager.lookup("javax.jnlp.PersistenceService");
		Log.info("Webstart detected using Muffins");
	} catch (Exception e) {
		Log.info("Using Local File System");
		return false;
	}
	return true;
}
 
Example 13
Source File: Scroller.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	// load the sprites and tiles, note that underneath the texture
	// will be shared between the sprite sheet and tilemap
	SpriteSheet sheet = new SpriteSheet("testdata/scroller/sprites.png",32,32);
	// load the tilemap created the TileD tool 
	map = new TiledMap("testdata/scroller/map.tmx");
	
	// build a collision map based on tile properties in the TileD map
	blocked = new boolean[map.getWidth()][map.getHeight()];
	for (int x=0;x<map.getWidth();x++) {
		for (int y=0;y<map.getHeight();y++) {
			int tileID = map.getTileId(x, y, 0);
			String value = map.getTileProperty(tileID, "blocked", "false");
			if ("true".equals(value)) {
				blocked[x][y] = true;
			}
		}
	}
	
	// caculate some layout values for rendering the tilemap. How many tiles
	// do we need to render to fill the screen in each dimension and how far is
	// it from the centre of the screen
	widthInTiles = container.getWidth() / TILE_SIZE;
	heightInTiles = container.getHeight() / TILE_SIZE;
	topOffsetInTiles = heightInTiles / 2;
	leftOffsetInTiles = widthInTiles / 2;
	
	// create the player sprite based on a set of sprites from the sheet loaded
	// above (tank tracks moving)
	player = new Animation();
	for (int frame=0;frame<7;frame++) {
		player.addFrame(sheet.getSprite(frame,1), 150);
	}
	player.setAutoUpdate(false);

	// update the vector of movement based on the initial angle
	updateMovementVector();
	
	Log.info("Window Dimensions in Tiles: "+widthInTiles+"x"+heightInTiles);
}
 
Example 14
Source File: LoadingList.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Remove a resource from the list that has been loaded for
 * other reasons.
 * 
 * @param resource The resource to remove
 */
public void remove(DeferredResource resource) {
	Log.info("Early loading of deferred resource due to req: "+resource.getDescription());
	total--;
	deferred.remove(resource);
}