Tag Info

New answers tagged

1

Just think about it, what the server has to do. In Singleplayer needs to know and simulate the world around the player. The world is made out of voxels, which naturally needs a lot more memory than just working with heights. Doing stuff procedurally also needs more CPU power, because you can't optimize and precalculate some stuff (like culling, pathfinding ...


0

I'm not looking to start a discussion on the merits of Java Neither do I, but Fact is that Java uses all the objects by reference, nothing is used by value, the memory management is Java is good, but with puting everything in the heap, performance is low, and the program uses a lot more memory.


1

Change glOrtho(0, width, 0, height, -1, 1); To this: glOrtho(0, width, height, 0, -1, 1); A quick little understanding about why your font wasn't working (if you don't already know), glOrtho is called like this: glOrtho(double left, double right, double bottom, double top, double zNear, double zFar). This being said, you had the bottom set to ...


0

I have actually faced this exact problem. The way I did it was just to make a menu graphic and draw it over everything else in your game. In your update code you just make a state variable for when the menu is open, nothing else updates. In your render code you use the same state variable to draw the menu only when it is open. And for your input again use ...


0

I searched the wiki for an answer and found that there is no Loader for text files (see list here). So I followed the instructions on the same page to write my own loader (the instructions can be found here). This is what I came up with: The Text class is basically a wrapper around a simple String: package mygame.assets; import ...


0

As you automatically generate these color definitions, maybe you could generate it instead of loading from a file. If the problem loading is the size of the file, you could consider using compression. But as you wanna try with assets loader, I'll add some links that could be useful. To manage these color definition assets you could write your own loader. ...


0

You should do a bounds check as you mentioned then reduce the velocity so you don't get shaky behavior. You kind of got it but I'm not sure what displacement does. //This code goes after velocity is set if (position.x > 50) { position.x = 50; //If we're heading towards the bounds, stop if (velocity.x > 0) velocity.x = 0; } else if ...


0

In doubt, when you can not obtain a version of the tileset where the "pink" areas are indeed transparent, you can simply replace all pink pixels of the image with transparent ones, with a method like replaceColor in this example: import java.awt.Color; import java.awt.GridLayout; import java.awt.image.BufferedImage; import java.io.File; import ...


0

There was a post explaining the changes, but is not easy to find. The link was on the 1.5.6 release changelog: http://www.badlogicgames.com/wordpress/?p=3666 And the link about changes in fonts was: http://www.badlogicgames.com/wordpress/?p=3658 private static GlyphLayout glyphLayout = new GlyphLayout(); private BitmapFont fontA = new BitmapFont(), fontB = ...


0

Apparently my arraylist elements stored as Object objects (not as Life objects). So I need to cast the element as type Life first, I need to change this : Life LastLife = Scenario.getLifeBar().get(lastIndex); into this : Life LastLife = (Life) SpaceWorld.getLifeBar().get(lastIndex); and it works just fine. Check the Reference here


0

You could use the transparent png instead. These sprites with a pink color were used a lot in old games, usually using images with a palette (indexed colors). Commonly the pink color is Red = 255, Blue = 255, Green = 0, and it is defined as the first color in the palette (index 0), meaning it should be transparent pixels. Defining the color as pink helped to ...


2

You require three things to load code from files and do things with the types and functions defined in those modules. A way to load a module from disk or memory. A way to, given a module, enumerate and use the functionality present in the module. A bunch of types and signatures designed to be shared between the modules, so the code has something to speak ...


0

When handling games with a fixed time step, which is what you would need to simulate a physics system, it is best not to go with the system Timer as it is not as precise as other methods (even though the difference is small). Here is an example of how you might go about running a game loop that iterates 60 times a second. public void run() { double ns = ...


1

You will need a zombie class. public class Zombie { public int x, y; public Entity(int x, int y) { this.x = x; this.y = y; } public void tick() { //code to control movement and such } public void render() { g.drawImage(zombieImage, x, y, null); } } I'm not sure which class you are showing in your code but you will need to make a zombie ...


0

You want to look into parsing, which is a very well documented field. To start off simply though, you might parse the file line-by-line, stripping '#' to the end of the line, and stripping any padding whitespace. This solves the issue of "its not very flexible because you just have to put one tiny whitespace in front of the square brackets". You can then ...


0

As it is said, you should make one post per question. You can use a circle collider instead of a rectangle collider. Set the circle radius by experimentation. You can also implement a combination of both, if you care about extreme precision, but a circle should be enough for your purposes.


1

Given that top left is at 0, and each tile is square with length 10: int squareClickedX = clickPosX / 10 int squareClickedY = clickPosY / 10 So, if clicked on x23, y12 int squareClickedX = 23 / 10 int squareClickedY = 12 / 10 results int squareClickedX = 2 int squareClickedY = 1 Means that you clicked Was this any good? This is quite common way ...


0

I didn't found an API for this in Slick library. So I wrote a class which does it for me (groovy code): class Stretched { Shape shape Image image Stretched(Shape shape, Image image) { this.shape = shape this.image = image } void render() { TextureImpl.bindNone() image.getTexture().bind() SGL GL ...


0

If you want your hit detection to be as accurate as possibly, you need to correctly set your actor's size and position. For your example, this would probably go something like this: The circle's constructor: public Circle(Texture tex, Vector2 position) { this.tex = tex; this.setPosition(position.x, position.y); this.setSize(tex.getWidth(), ...


0

There are documents in libGDX's github wiki https://github.com/libgdx/libgdx/wiki/Tile-maps According to this page, you can get your objects by finding the layer contains them. MapLayer layer = map.getLayers().get("my-layer"); Find your objects MapObjects objects = layer.getObjects(); And get the object objects.get("object_name"); There are many ...


0

For that kind of behaviour you generally Rotate about the origin, then Translate, then Scale. Since you want to rotate from the center bottom of your quad, from the origin you'd: 1. Translate the image to have its center at the origin ((width/2)) 2. Rotate 3. Translate to the desired location I'm not familiar with the inner works of OpenGL (I work with a ...


0

For my system I use a spritesheet with 16 tile variations on it. Upon creating a tile type I cut up the texture into regions specified in the constructor (which means my tiles can have varying resolutions). That means you can provide it with an image like this http://www.promagra.de/Downloads/Platformer/Pl5t.png and the transitions will take care of ...


0

Had the same problem with the following code: private void restart() { setScreen(new FooScreen); } Solved it simply by wrapping it in private void restart() { Gdx.app.postRunnable(() -> { setScreen(screen); }); } Hopefully that will help you.


1

You can try calculating the surface normal using central finite differencing, and then colliding with a locally linear plane at the collision point. Vector2 GetNormal(Grid grid, int x, int y) { float dx = grid[x + 1, y] - grid[x - 1, y]; float dy = grid[x, y + 1] - grid[x, y - 1]; return Vector2(dx * 0.5f, dy * 0.5f); } When your grid is ...


0

The way I handle these kinds of 2D physics is to process the X and Y components of the vector separately. That way if a collision occurs, I know which direction the collider was moving along based on the sign and component of the velocity vector I am processing. Then when a collision occurs, you can modify the velocity on the appropriate axis. Changing the ...


1

Here is an official Spine 2D example where they load Spineboy into a game. https://github.com/EsotericSoftware/spine-superspineboy The following 3 lines are used to read a texture atlas and skeleton data as well as making some animation state data. TextureAtlas playerAtlas = new TextureAtlas(Gdx.files.internal("spineboy/spineboy.atlas")); SkeletonJson ...


0

You're using Java so I'm going to assume off the bat that you're playing to Java's strong points and writing your game as Object Oriented as you possibly can. When you say you have a game loop I imagine you have a top level class with a main method that loops over your update and draw functions, something like the following (but yours will be far more ...


0

Think about having only one final Tile class and it defines only the data needed to render and update like the id of the Sprite or TextureRegion public class Tile { private int type; private int spriteId; some other data that you need and that belongs to a Tile ... public int getType() { return type; } public int ...


0

It is quite simple, actually. All you need is to replace the immediate mode draw calls with a Vertex Buffer Object - VBO. However, updating the VBO at every drawQuad() would be very inefficient. The optimal approach would be to batch the vertexes in a system-side vertex array and then update the VBO once per-frame before rendering. I'm not very familiar ...


0

there are plenty of opengl 3+ tutorials out there. Since LWGJL is a thin wrapper, it doesn't matter what language they are in you should be able to adapt them easily. check those out: http://www.opengl-tutorial.org/ http://www.mbsoftworks.sk/index.php?page=tutorials&series=1 https://www.opengl.org/wiki/Main_Page


4

Yes, generally, games are a single main loop. Games in Java may have a separate main loop for each menu/screen/mode due to Java's idioms, but that of course does not solve your animation wait problem. For things like the problem you are running into, consider using events. e.g., when your animation system finishes playing an animation, it can send out an ...


0

@Override public void create() { gameScreen = new gameScreen(this); setScreen(gamaeScreen); } Is the setScreen(gamaeScreen) a typo (gamaeScreen) ???


0

Having all Tiles be Actors that draw their sprite in the Actor's draw() call is an option. Of course there are many ways to draw a map, but this definitely is one of them. However I would warn against using Sprites. Since you said all tiles are 16x16px you will likely have very many of them in each level of your game. This would mean that you would have ...


2

The constructor of your gameScreen class does not initialize the camera and renderer fields, what you're initializing in the show method are method-local variables with the same names. That's why they're null when you're in the render method. Try changing OrthogonalTiledMapRenderer renderer = new OrthogonalTiledMapRenderer(map,unitScale); ...


0

You are currently setting their velocities when you press a key, when you release the key, their velocities must return to normal. That is the part you are missing. You should write something like this; public void keyReleased(MouseEvent e){ int key = e.getKeyCode(); if(key == KeyEvent.VK_W){ vel_y = 0; } if(key == KeyEvent.VK_S){ vel_y = 0; } ...



Top 50 recent answers are included