Tag Info

Hot answers tagged

4

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 ...


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

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

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

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

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.


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

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

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

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

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

I think the simplest approach is to rescale the values. The values other than the one you're setting currently sum to 1.0 - rate[index]. You want them to sum to 1.0 - r. You can therefore scale each of them by (1.0 - new_value) / (1.0 - old_value) to preserve the sum. public void setRate (int index, double r) { for (int i = 0; i < 3; i++) { ...


2

Your problem is that you are checking for a collision and then stopping, this means that if your frame places you to far into an object you are now stuck. To solve this you have to solve the equation of exactly where both object were when they hit one another. So you have to find where the following is true: |t*v1+p1-t*v2+p2)|=|r| where t is time v is ...


2

Sure, why wouldn't it? As stated on BadLogicGaming's Official Website: The license basically states you can do with the source whatever you want, copy it, modify it, include it in open and closed source projects without getting infected by the license itself. You can do whatever you want with what you made. Just make sure you comply to these 3 lines if ...


1

You could divide diff by two and then subtract it or add it accordingly to the other two. double diff = r - rate[index]; double change = diff/2 * -1; //we need to reverse the operation for(int i = 0 ; i < 3; i++) { if(index != i) rate[i] += change; } Still you should be careful for number precision errors. For that you could use an int[] where all ...


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

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

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

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

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 ...


1

Why not using Actions.forever(Action repeatedAction) ? Example : fadeLoop = Actions.forever(Actions.sequence(Actions.fadeOut(time), Actions.fadeIn(time))); this.addAction(fadeloop)


1

Don't use threads for this. Change "run" method to "update" and just loop through all generators in your mainloop and call "update" for those. I find your logic hard to understand and code hard to debug. This is just my opinion, but threads are not good for this kind of situations. You even have thread sleep in there, so it actually is not that time critical ...


1

So you need to call renderer.setView(orthoCamera) to reset the tile map drawing view. Then don't forget to also call camera.update() after you do anything to it.


1

Size and fit can be taken care of the heuristic that declares whether a move is valid during the path finding. Once the path itself is generated it's then up to a localized movement function to handle not bumping into things on the way, called path smoothing. Maybe paths with smoothing will help generate some ideas that work for you. The last time I did ...


1

If changes happen in an area, then you only need to update that area (rather than updating the entire map.) You could divide the array into an 80x60 array (I'll call them 'chunks'), each with 10x10x3, sections. With some basic data on who owns each larger section. So if the raising/lowering only happens in adjacent fields, and you know that all chunks ...


1

As per Andy's comment: Nevermind, I fixed it. I just had to take out the p.setCenterX(center.x);p.setCenterY(center.y); out of the render function.


1

Your MyGdxGame class' render method doesn't do anything. It should call GameScreen.render() to render. Some comments about style: Variable names should be lower-case on their first letter (gameScreen not GameScreen) Please fix your formatting next time Suppressing warnings should be done carefully; they're usually indicative of a problem that may bite ...



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