Questions tagged [java]

Java is both a popular object-oriented programming language and runtime environment which allows Java programs to run unchanged on most hardware and software platforms.

Filter by
Sorted by
Tagged with
1
vote
1answer
404 views

Why does my depth test fail on Nvidia cards?

I sent a test version of my in-development game to some friends, and they found out that the Depth Test in OpenGL does not work on Nvidia cards. I'm using LWJGL. I use my own matrices and send them ...
0
votes
1answer
79 views

Snake game steering with Java FX

I am currently trying to make a snake game with Java FX, I read several posts about it and I understand on theory how to move the snake body (for each part of the snake reference the previous one and ...
1
vote
1answer
1k views

Change game from portrait to landscape dynamically

I have multiple classes that implement Screen. I want to, say, have the Main Menu screen portrait, then the Play Screen ...
3
votes
1answer
84 views

Mob generation design - is creating a class for each mob efficient?

I'm working on an RPG game for my coursework project. Everything is going fine but I've reached a stage where I do think that my project's code is not the most efficient. Here I have a constructor of ...
0
votes
1answer
40 views

Why can I not open the desktop and core folders in libGDX?

I think the problem is caused beacuse I have two JDK's. One dedicated one and another integrated from Android Studio. Before, when I start the bulid it gave me a warning: ...
0
votes
0answers
14 views

can't achieve a smooth movement with ShapeRender

I am using ShapeRender to render Circles and in the update function on every loop I update the coordinates that represent my ...
0
votes
0answers
47 views

Creating split-screen with Game class extending Canvas

Making my first attempt at a 2D two-player game in Java, but without using any external libraries. The issue I am running into is I am trying to split the window in half so two people can play the ...
0
votes
1answer
28 views

Flat shaded triangles using the ModelBuilder?

I decided to give the ModelBuilder a try but I cannot get rid of the smoothing of my terrain. So what I tried: Create each triangle individually with there own ...
12
votes
8answers
8k views

Converting a 2D curve into points for data storage

I’ve created an algorithm which converts any curve i.e. path into minimum number of points so that I can save it into a file or database. The method is simple: it moves three points in equal steps ...
2
votes
2answers
88 views

Catan Optimal Placement

Is it possible to calculate the best possible placements for settlements in Catan without using an ML algorithm? While it is trivial to simply add up the numbers surrounding the settlement (highest ...
0
votes
1answer
27 views

Prevent Wall Clipping with Bouncing Shape

I'm currently working on a demo-type program involving bouncing objects. Currently, I have a rectangle that can bounce around the screen. When the rectangle bounces against one of the walls ...
0
votes
0answers
73 views

Map generation for a 2.5D RTS Game

I've been looking on the net since some time for generating a map for my isometric RTS game. The map should have biomes, humidity, wind directions and etc. But I couldn't find a correct algorithm or ...
0
votes
1answer
81 views

How to get collision area within a circle in libgdx

I have a ball inside of a multi-colored circle, the ball will hit the inner area of the circle like this bellow circle image And the Circle will be rotated clockwise or anti-clockwise based on user ...
0
votes
1answer
31 views

How can I make my animation switch frames automatically without pressing any keys?

So I have been trying to figure out for so long how I can loop the frames on my animation automatically without entering user input to prompt movement of my object. I have four different frames for a ...
0
votes
1answer
44 views

How to render 3d object as 2d with different angles

I wanted to make a ship as a 3d object and import it with an atlas file to my 2d libgdx project with different angles like I saw it by another game. And I was wondering if there is a specific ...
0
votes
0answers
85 views

How can I get a straight path using A*?

How to change A* work so that the path is more like a straight Euclidean distance? I read that you need to break some nodes, but how to implement this? I need heuristic like this: Is such a ...
9
votes
3answers
2k views

Random Zelda-style map generation

Im trying to randomly generate a map of rooms connected by doors, and I've succeeded in generating one using this code: ...
0
votes
1answer
151 views

How can I change the hardness and blast resistance of Minecraft blocks?

I want to make the strength of the iron block and obsidian switch places, along with other changes to block strength and blast resistance. I am not allowed to swap the textures or anything like that. ...
1
vote
0answers
46 views

How to structure tic tac toe game loop (or equivalent simple turn based game)?

I'm developing the simple Tic Tac Toe game in Java and got stuck on the game loop architecture. The game must support local, remote and automatic players. The graphical interface is based on JavaFX. ...
0
votes
1answer
51 views

How PhysicsBodyLoader.SCALE of overlap2d runtime works?

What is the purpose of that method is and when I have to use it? Really I have no idea. I also found the source code but that didn't help me much.
1
vote
1answer
67 views

Using logic gates for Sprite Collision Detection - humor an old fart please

Im an old coder who came back so to speak, learning Java I know what I want but I cannot find anyone asking it anywhere so here goes... Im writing a basic tank game to code for practice but as is ...
1
vote
1answer
133 views

LWJGL3 shader code doesn't work

So I made a program to draw a simple cube with colors at each vertex. The program worked fine until I added shaders. It was using vbos and indicies and it did draw a colored cube like it should. So ...
0
votes
1answer
166 views

How can I track two fingers?

Im trying to make make game which is intended to be played with the phone in landscape mode, and the player uses their thumbs to control the movement. The game controls look like this: On the left ...
1
vote
1answer
39 views

How do I order sprites by depth in Java, when their objects are of different classes?

I'm developing a game to learn more about Java, and I've run into a problem: My character (the guy) moves, but I can not figure out how to automatically change the order of how the sprites are drawn. ...
0
votes
1answer
871 views

What is a good approach to dynamically change actor Position?

In my card game there are 2 players with each player having a hand(a ListArray of of Cards.In this case its ...
1
vote
1answer
24 views

Extending the camera vs CameraHelper class vs camera field

I am following an eBook called "Learning Libgdx Game Development" In it, the author implements a CameraHelper class that implements ...
0
votes
0answers
8 views

Lighting not working in a 2D JavaFX game when using subtracting shapes?

So im trying to add lighting into my game. I'm using shape subtracting and unions to subtract circles (the lights) from a dark rectangle that covers the whole world. I think that its a problem with ...
1
vote
1answer
268 views

How can I spawn particles around a point but inside a box?

There are particles in a box, the black circle representing the spawn point and the red circle representing the particles. How could I spawn them so they don't spawn outside the box, and so that they ...
0
votes
1answer
65 views

Pause updating but keep rendering

I am creating an implementation of Snakes and ladders and I run into some issues.The game is updating too fast and I want to limit the framerate kinda,or make a pause so that the move is actually ...
6
votes
1answer
265 views

Java game LWJGL input doesnt work properly

Im making a game in LWJGL 2 and Slick2d. Im trying to add an item to my inventory by releasing a key (the inventory system works ...
0
votes
0answers
55 views

Why Java wont use GPU?

I have a java code (game) which runs at 3200 frames per second on my PC. On my laptop, it runs with 100 frames per second, despite the fact they have very similar hardware. I think the issue might be ...
0
votes
1answer
33 views

Can Mobile Games use Fragments instead of SurfaceViews?

All the tutorials of mobile games for android (such as this one), use the to display game objects. Most other applications tend to use an ...
0
votes
0answers
13 views

How to add lighting to a 2D Tile-based game in JavaFX?

I'm making a 2D roguelike tile-based game with Java and JavaFX. I'm currently working on adding lighting and darkness to the dungeon, but whenever I try running it, it takes a very long time to load, ...
0
votes
0answers
38 views

Depth Test Problems with LWJGL3 (GLFW)

I know: similar questions have been asked - but I didn't find a solution. So at first the basic problem: It seems that convex Models (currently I load them from .obj files) render fine, but concave ...
3
votes
3answers
610 views

libGDX - How to rotate with a specific duration

I want to rotate my player to 90° for a specific duration. I know scene2d provides this, but I don't want to use it for my players. With how much to rotate every frame, so after x seconds the ...
0
votes
0answers
33 views

Java create a Polygon for each island in tile game

I am making a 2d top-down tile based game, which is randomly generated each new world. What I want to do is create a Polygon (or other more appropriate shape I don't know of) for each landmass not ...
0
votes
0answers
15 views

how to create button to change screen

i have a problem with my code. When I add a button to change the screen, a crash occurs or takes a long time to convert to the other screen, and this is my code ...
0
votes
0answers
18 views

Creating method to jump over another pawn

Currently, I am working on my very first bigger project in Java. It is a simple checkers game, which is based on GridPane. For now, everything is more than fine, ...
0
votes
1answer
207 views

How do I pack my game LWJGL game into a single executable JAR with Maven?

I am trying to use Maven to manage building my LWJGL projects. The entire project needs to be packed into a single executable jar, dependencies, natives and resources included, so that can be easily ...
0
votes
1answer
33 views

How to launch Libgdx cross-platform (Android, HTML, Desktop) multiplayer client with socket?

So i'm struggling with making my cross-platform client side to work, specifically on HTML part. I have java server that is responsible for all the controls and events, and I control it via netty-...
0
votes
1answer
55 views

How to create post-processing effects in Slick2D?

As I get closer and closer to the end of the feature development for my game and the beginning of the graphical overhaul, I keep thinking of ideas for graphical effects that would make my game even ...
0
votes
2answers
45 views

Calculate size of hexagonal map libgdx

I have a staggered hexagonal map created with "tiled" map editor and I want to calculate the height of this map in pixels, the example map below should be ...
0
votes
2answers
130 views

Project organization for a multiplayer client-server game

I'm programming a game 100% in Java but I'm having some issues concerning the final games architecture. I plan on having two separate projects: one that will hold the client side of communication ...
1
vote
2answers
92 views

How To Resolve Collision Before it Occurs

I have 2 objects, A and B, in a 2 dimensional space. If I know A is trying to move by vector M (that is to add vector M to the positional vector of A), and that A will collide with B after A moves, ...
1
vote
1answer
262 views

Calculating World Unit or Pixels Per Unit values

Is there a formula to calculate world unit or pixels per unit values in LibGdx? Most of my objects fit into a 32x32 or 16x16 frame. When the objects are close to 32x32, and I use ...
0
votes
1answer
26 views

InputListener not working on a custom Actor

Right now I am working on a UI for my game. I'm adding my own UI elements to a group and adding that to a stage. But the listeners I'm adding to the actors are not firing off at all. I have looked on ...
3
votes
2answers
373 views

Strange LibGdx box2d body.ApplyLinearImpulse(); behavior

I have been working on this game NinjaThief and when I apply linear impulse to player body it just keeps on moving. Some of the functions are still unfinished so it looks a bit messy. Here is my code:...
2
votes
2answers
199 views

Understanding HingeConstraint in jBullet

I'm using the java port of BulletPhysics engine jBullet. I'd like to make a joints between 2 triangles so that one edge of the first and one edge of the seconds act like a hinge. But I don't ...
1
vote
1answer
150 views

Handling mouse input depending on selected unit and clicked tile

I am making a turn-based tactical game (think something like X-Com) and I am currently trying to figure out how to handle mouse input in a clean way without a mess of if-statements. I have a lot of ...
4
votes
2answers
1k views

Libgdx Scene2D Table background not showing up

I am using Libgdx's Scene2D API to build my UI and everything has been working as expected until now. I created a Skin and a ...