slick2d

OpenGL (LWJGL+Slick-Util) - Text doesn't display properly

允我心安 提交于 2019-12-25 14:47:08
问题 I'm trying to develop a game using OpenGL through LWJGL and Slick-Util (still not fully sure how they all relate to each other). I've figured out how to get the TrueTypeFonts to work . The problem is, that as soon as I got the fonts to work, the other aspects of my game (loading bar and map) don't display now at all. Any idea what the problem is? Here is the class for my game. package manager; import java.awt.Font; import java.io.InputStream; import org.lwjgl.LWJGLException; import org.lwjgl

Parse XML File within Jar

[亡魂溺海] 提交于 2019-12-25 00:16:08
问题 I am having troubles loading an XML file within my java game. Here is where the file is located, (from Eclipse): I have been doing research, and apparently to use the xml file in a JAR file, I need to call DocumentBuilder.parse(InputStream) The problem is when I try to get the InputStream using getResourceAsStream("res/xml/items.xml") it always returns null. How could I make it not return null? I don't want to put my res folder inside of my "src" folder, but is there some setting in Eclipse

Java slick2d moving an object every x seconds

Deadly 提交于 2019-12-24 22:19:45
问题 I am currently working on a 2d game in which a player sprite pushes other sprites around on the screen. My current code (within subclass): //x and y being the co-ords i want this object to move to (e.g 50 pixels right of its starting point etc.) public Boolean move(float x, float y, int delta) { this.setx(x); } How do i make the object move say 50 pixels every 1 second? or alternatively every x frames. I've tried using delta but that results in smooth motion which is much harder to control

Multi-tile objects on tiled map

六月ゝ 毕业季﹏ 提交于 2019-12-24 09:20:25
问题 I'm trying to write rts-like-tile-based game using Tiled and slick2d. I don't know how to handle a multi-tile objects, like buildings, how to create, keep and e.g. move them. 回答1: One solution would be to create a layer in tiled where the tiles are used as "markers" for your game code. These "markers" are never drawn. Instead, when you initialize your game, go through the the tiled map and every time a corresponding marker is found add a "new Building()" to some kind of EntityManager class.

Finding if my mouse is inside a rectangle in Java

笑着哭i 提交于 2019-12-24 04:56:33
问题 I'm starting to develop a game and I need to be able to see if my mouse is inside a rectangle, I've tried using .contains for a rectangle but i can't seem to get it to work, i'll paste my code below, any help would be greatly appreciated! :) public boolean isMouseOver(GameContainer gc){ r = new Rectangle(getX(), getY(),getWidth(),getHeight()); Input input = gc.getInput(); xpos = input.getMouseX(); ypos = input.getMouseY(); return r.contains(xpos, ypos); } This is the method i'm trying to use,

How to install Slick2d?

半城伤御伤魂 提交于 2019-12-24 04:55:09
问题 Hi I'm trying to create a game using the LWJGL library and the Slick2D game library however when I attempt to run it I get an error. Here is my code: package test; import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; public class SetupClass extends BasicGame { public SetupClass(String title) { super(title); // TODO Auto-generated constructor stub }

Maven assembly plugin redownloading dependencies in jenkins

☆樱花仙子☆ 提交于 2019-12-23 12:17:48
问题 For some reason, maven seems to be attempting to download my project's dependencies every time I try to build it with Jenkins. There are a few problems. The first one is it shouldn't be doing this at all, and the other problem is it's not even trying to download them from the correct repo, which means it has to wait for every one of them to time out. I can run mvn clean package myself and it builds it in ~4 seconds because all of the dependencies are in my local .m2 repo. Jenkins is installed

Slick TextField not working

你。 提交于 2019-12-22 09:18:01
问题 I have a problem when using Slick2D's TextField. When using Slick's 'BasicGame' the TextField works fine - I am able to click on it, type words, and System.out.println the text fields contents. However, when using the same code on a 'BasicGameState', the TextField is un-clickable and doesn't respond to any input. So: Working code: package Help; import java.awt.Font; import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer; import

More Efficient Way of making multiple objects

夙愿已清 提交于 2019-12-21 23:24:41
问题 I am trying to make a memory game with Java. The game is basically going to be some squares in a grid that is 4x4 at the moment just for testing purposes. I have created my Square class, and programmed what i want them to do in that class, and then created a square object in another Class that handles the "Normal Mode" of the game. Now since i have a 4x4 grid of squares I need to make 16 different Squares (Or at least that's what i'm thinking at the moment). I also need to draw the Squares in

Slick2D vs Straight LWJGL

拥有回忆 提交于 2019-12-20 16:18:34
问题 I've been delving into game programming with Slick2D, and I've began to wonder if in the long run, knowing LWJGL would be more helpful. On one hand, Slick2D is fast and simple, but it seems LWJGL is more adaptable in the sense that it has both 2D and 3D capabilities. For someone who is intermediate in java, and wants to make games, would it be worth the additional effort to learn LWJGL right off the bat? 回答1: I don't think the two are really related. I mean, I know Slick is built on top of