Tag Info

Hot answers tagged

4

If you use an algorithm like Bresenham, where the two lines can be different, depending on their start- and end-position, you then have to either: Plot both lines and use the result of both plots for your LoS calculation. Plot only one line (for example always from Player to Enemy) and use this one LoS calculation for both entities.


3

Short answer: no. Long answer: Game Maker's performance are really bad. If you are a good programmer, you will find yourself hitting the performance wall more than once or pay for the YYC (Yoyo COmpiler) which unlocks decent performances at a price. Libraries like libGDX, slick2D, LWJGL or any other will beat GameMaker by a lot. Object oriented patterns in ...


3

This logic goes in your update function rather than your render function. The easiest way to prevent this is with an if statement surrounding your stage interaction code. If (overlay not active) Stage.handleinput() Else Overlay.handleinput() Endif


3

The easiest way to achieve this is to draw your game to an image buffer first, instead of directly to the window. Then you draw that image scaled up according to the resolution of your window. This way you don't have to worry about scaling and positioning the indiviual elements of your display. However, it might be advisable to only scale to the nearest ...


3

For your first question you can optimize your method by only checking collisions with the border bubbles (only the bubbles that are actually exposed and not ones that are entirely surrounded). However, you can optimize this even further by using the fact that you know the coordinates of the bubble to find out approximately (or precisely, with some math) ...


3

This is less a problem with Box2dLights, and more a problem with setting up Box2d collision fixtures to match your sprites. The Box2dLight rays are colliding with the CircleShape fixture you attached to the box2d body. CircleShape chain = new CircleShape(); chain.setRadius(10); Instead, this should be a Polygon shape with the same dimensions as your box, ...


3

Rule number one of multithreading: avoid it. You might think: "Well, there are things in my game which are supposed to happen simultaneously. Wouldn't it be much more intuitive when each thing happens in its own thread?" No, it's not. Using multithreading makes your program magnitudes more complex. You have no control over how much CPU time the operating ...


3

Well according to the rules of the game, the AI is doing the right thing - moving towards the player every time! It's only due to a quirky situation that the player can "trap" the AI in a loop: Start Player AI Player AI moves moves moves moves .... .... .... .... ...


3

Use floating point variables for entities' velocity and position. Use integers only when translating from world position to screen position. This way, your ship will move smoothly thorugh tiles. Also, add a Camera object to convert your world coordinates to screen coordinates as soon as possible.


3

You can not have a non-static method in Main, because there is no instance of the Main class (unless you create one). The game-loop can be placed wherever you feel is a good place for it. There is no "right" or "wrong" way to do this. Only the way which is right or wrong for you and your current project. However, there are best practices which happen to be ...


3

I assume you really want to know two things: 1) Will Steam accept my Java game? 2) What do I need to do to make it work on Steam? The answer to #1 is "yes." Steam hosts other Java games (like Spiral Knights). For #2, I suggest you package your game using launch4j. This will provide you with native (Windows, Linux) wrappers around your application. Other ...


2

in your Tile.render function you are multiplying the coordinates with the (half) width and height of the current image. But keep in mind that the grid-size of your world is fixed to the size of a normal tile. When you move an object 2 units to the left, its own size is irrelevant. Only the size of the unit matters. Calculate the position based on the size ...


2

Obtaining multiple key presses can be found in this answer: How do I handle multiple key presses in Java? Assign each one to a boolean variable and then check each key and add to the movement vector. Opposite keys will cancel out, and you can also test whether a key is already in use based on that. if(noDiagonal) { velX = 0; velY = 0; ...


2

Take a look at this. It's common to have a single image for all your tiles and draw a different part of it at rendering. You can then draw your tiles like this : int mx = tileId % numberOfTileCols; int my = tileId / numberOfTileRows; graphics.drawImage(image, x, y, x + tileWidth, y + tileHeight, mx * tileWidth, my * tileHeight, mx * ...


2

pretty new to libgdx but i dont think it would be too hard to implement your own version of a "master volume" just have a float variable called master volume and then use it when ever you play your music and edit it how you please for example public static float mastervol = 1f; //playing your sounds sound1.play(mastervol); sound2.play(mastervol); ...


2

The problems i have run into is i can't move the WorldEvent,WorldListener, or World classes into a separate package under the moniker World.my.game because of the static reference. Don't make the listener inside the World object static. A static class member means the object is shared across all instances of the type (all instances of World in this ...


2

After 3 days of working I managed to work around it, I created this git repository so people can use it, it says everything there. Git Repository Enjoy, those who need it. EDIT: Not the solution. EDIT: The solution is located here.


2

I had a similar issue on Android with LibGDX a few month ago. Not sure if it is related though, but that's obviously something one should be aware of. A common issue : On low cost devices or old devices, when the size of the original texture file was superior to 2048*2048px, the texture won't load. And on the worst devices i have seen, 1024*1024px textures ...


2

The method camera.rotate() (and all other transformation methods on camera) act on the current state of the camera. So if it's rotated 30 degrees, it will add more 30 degrees to the rotation. If you want to keep at 30 degrees (but still applying the transform every step), you have to make it look back at whatever it was looking before. Assuming you're using ...


2

If your game is running only on Eclipse, start by packing the .jar, the assets and all that come with your game and try your game on different OS (or ask other people to do it). You will have a good return about the technical problems ("game's not working", "laaag") and the gameplay problems ("not funny enough", "what am I supposed to do ?", "boring..."). ...


2

On the second table, you have two rows with three columns. If you want to center your others rows with these one, you have to set the horizontal size of the cell to three columns using the colspan method. The "center" method will only center the widget inside it's own cell. For example, your code should be : changeOptions.center().bottom(); ...


2

getBoundsInParent() returns the bounding box around the shape — a rectangle. The built-in intersects() check works only for rectangular shapes, not for circles, polygons, etc. For these, you'd need to implement the check yourself.


2

So what I had been thinking has been confirmed: The dialog is built with a single NinePatch so you need to adjust the size of the title bar manually within the .atlas file and .png file. EDIT This will basically be a little How to use a JSON file with LibGdx tutorial. LibGdx has a very useful Class called Skin. It allows you to have a .json file along with ...


1

As I understood your question, you want to get the coordinates of the points of your body relative to the world, in other words, following the transformations applied to the body. I did this function not long ago, I hope this will help you and guide you towards an answer: public Vec2[] getPoints() { Vec2[] v = new Vec2[shape.getVertexCount()]; for ...


1

I'd like to help but your code is working fine for me. public static void main(String[] args) throws Exception { DisplayMode displayMode = new DisplayMode(640, 480); Display.setDisplayMode(displayMode); Display.setTitle("Input test"); Display.create(); System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION)); ...


1

Simply use shapes and AABB collisions. Keep a tiled map. Create an approximation of a circle using tiles and create a rectangle for each of the unwalkable tiles. Next, when you create a player or any movable entity, simply create a Rectangle around them too. Before moving, look whether or not the player's rectangle would collide with any of the wall's ...


1

I'm assuming you're either using some sort of entity-component system, or else you have in-game classes that represent your objects. Either way, you have some reference to your in-game objects (players, walls, enemies, etc.) At a minimum, these objects should have: A position A sprite (display) A collision primitive (axis-aligned bounding box?) All you ...


1

The cross product of two vectors is a vector orthogonal to them both. If you have two vectors contained in a plane, the cross product of them gives you the vector that is normal to that plane. Knowing that, you can construct your desired coordinate system by exploiting that property. Let's start finding two vectors defining your plane. For example, PQ ...


1

By no means you need to recreate the buffers every time. Why don't you create all your buttons once and then draw them as needed? Buttons are immutable things. Suppose you had a class Button, that incorporates all the stuff needed to draw a button, such as textures and the vertex buffer: class Button { Texture texture; VertexBuffer buttonVerts; ...


1

Having one large tilemap is certainly the simplest way to go, but as you stated, it would be more efficient to have one for each zone and have the entire map cut down to a couples of square regions. It would allow you to free resources when a region is leaving the screen and reduce the range of the loops needed to draw all the tiles (though this can be ...



Only top voted, non community-wiki answers of a minimum length are eligible