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.
3,429
questions
6
votes
1
answer
703
views
Spawning enemies in four different positions with a fixed trajectory in android game
This is my first android game, I appreciate all the help. I want to define 4 spawning zones starting from out of the screen (left, right, up and down). Enemies coming from this areas have a fixed ...
1
vote
1
answer
826
views
How to minimize the repetitive creation of component in libgdx ashley?
The below example is creation of character Entity. My problem is do I always need to call these engine.createComponent(...class) ...
0
votes
0
answers
31
views
How to save score without resetting to 0 between Game Scene and Pause Scene?
I'm currently working on a LibGDX Java Game Project inspired by the Space Invaders game where I have created 2 Scene Classes: LevelScene and ...
1
vote
3
answers
2k
views
Graphics2D.drawImage not working
I'm trying to come up with my own game using Java AWT after watching a few video tutorials. However, I encountered a problem where I cannot draw an external image file that I loaded using the ...
0
votes
1
answer
31
views
How to to make KeyListener do an action only once per press, even if the button is held down?
I'm trying to make a turn-based game where my character is allow to move in any direction, but only by as much as the dice rolled allows him.
My problem is with how I'm using ...
3
votes
2
answers
4k
views
Rendering Smooth Text in Libgdx
I am trying to draw text onto the screen but it always ends up being pixelated no matter what I try. A lot of people say that adding the Linear TextureFilter works or offer other solutions but they ...
1
vote
1
answer
382
views
How do I make a hitbox for a sword in a top-down game?
Context: I'm using Box2D through LibGDX in Java. The sword and the player are in separate classes. Both extend LibGDX's Sprite class.
I've got a sword attached to my character that swings when I ...
1
vote
0
answers
50
views
JBullet - Shoving around objects
Sometimes in video games the players can walk up to certain objects for example boxes and barrels and shove them around.
How can I recreate this system? What function do I have to use to apply force ...
3
votes
1
answer
871
views
Increase friction with a friction joint
I'm making a topdown 2.5D game (think the legend of zelda: a link to the past) using libgdx and box2D.
to simulate friction from a topdown perspective, i've set the gravity for the box2D world to 0, ...
1
vote
1
answer
678
views
Adding JavaFX GUI to an MVC based terminal card game
I have written a version of Castle that so far plays through the terminal. I have recently refactored my code (which can be found here) to use the MVC design pattern. After I have added a GUI I will ...
2
votes
1
answer
139
views
Programming Singletons vs Static classes
I've been developping a 3D app for some time and I remember at some point I started to need to pass data arround in unrelated areas of the program, where it wouldn't make much sense to pass them ...
2
votes
3
answers
510
views
How do I prevent buffered image size fluctuation when rotating?
As you can see in the GIF, as the car rotates, as the Car rotates, the size appears to change to fit the determined height and width, what would be the best way to change these in conjunction with the ...
0
votes
1
answer
403
views
opengl (lwjgl) - only white triangle gets rendered, vertex and fragment shader not responsive
Currently my program can only render my vertices as white and changes in my vertex and fragment shader don't change what gets rendered for some reason i.e: (...
0
votes
1
answer
399
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 ...
0
votes
2
answers
365
views
Slick2D: Animation not being parsed from spritesheet correctly
I have a 960x960 spritesheet with each tile being 192x192. I initialized my spritesheet and animation like so:
...
2
votes
1
answer
154
views
GLSL wrong data read from attribute
I'm developping an OpenGLes 3.0 app with Java and I started writing the shader code. For some reason, it seems to mix up the attributes data locations and I don't understand why. Here's the code :
...
8
votes
4
answers
4k
views
Does Steam notify the user that they need Java for a game when they buy/download/install it?
My mate and I are gonna make a game for Steam and I, as the programmer, want to use Java as that is my current favorite language. So I need to know, does Steam notify the user that they need Java for ...
1
vote
2
answers
802
views
Problem with animating in Android, using batcher.draw in LibGDX
I am having a problem with the last part of the GameRenderer class. I call batcher.draw() and receive this error:
The method ...
3
votes
1
answer
680
views
How to store condition dependent item information in JSON
I'm developing a RPG-game. After searching about various ways to save item information in RPG-game, I determined to save information in JSON files. The problem is that in my game, some equipment's ...
5
votes
1
answer
2k
views
libGDX using Stage and Actor produces different camera angles on desktop and Android Phone
libGDX using Stage and Actor produces different camera angles on desktop and Android Phone.
Here are pictures demonstrating the problem: http://brandonyuh.minus.com/mFpdTSgN17VUq
On the desktop ...
0
votes
1
answer
383
views
Libgdx can't read .ttf file when running Android configuration
Firstly, I am aware that a similar question was asked some time ago that went unanswered. Currently, it has multiple upvotes but no answer.
The error
...
1
vote
2
answers
549
views
What is moving the camera useful for, if I have to do culling myself?
I'm new to libgdx and especially to using OrthographicCameras. I'm trying to understand how useful they are.
The question is, suppose I have a game map 500 units wide. I have an OrtographicCamera ...
0
votes
0
answers
21
views
Launch4J wrapped jar produces JNILibLoaderBase errors
I created an executable jar file bundled with JOGL, then wrapped the jar into a windows executable using Launch4j in order to pass runtime java parameters. If I run the jar from a command prompt I get ...
1
vote
0
answers
61
views
LWJGL3. A strange graphic artifact of OpenGL 3.x
I work in java with lwjgl3. I came across a strange artifact, the source of which I have not been able to determine for a very long time. I'm drawing a large surface. When I approach this surface and ...
0
votes
2
answers
1k
views
Resize font when screen resizes desktop Libgdx
I create my font using the following code:
...
0
votes
3
answers
3k
views
How to move in 3D space in first person mode?
I have a Camera with Vector3 and also the camera has an angle.
If I use this:
hero.position.x += speedX;
hero.position.z += speedZ;
works great but as soon as I ...
0
votes
0
answers
23
views
I use skin composer, I want to create scene in scene composer, I can't add text buttons even though I created text buttons
I create text buttons, add every image and font, but it's still disabled when I want to add button in scene composer. I'm probably doing something wrong.
8
votes
2
answers
792
views
Android libGDX FreeTypeFontGenerator exception
I am working on a libGDX project for Android. Since I added the following code, running the game on my Android phone produces an exception:
...
1
vote
1
answer
2k
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 ...
0
votes
0
answers
28
views
How do I go about making an enemy change depending on where the player hit it?
Currently coding in java, using cocos engine, making a low-poly game with a world which changes based on what the player does, hopefully including the aspect of an enemy changing when the player hits ...
3
votes
1
answer
753
views
Moving sprite using the accelerometer in LibGDX?
I don't know how to use accelerometer in LibGDX; how could I use the the motion sensor? I'm working for a top down game with the motion sensor. I'm new to this framework. My sprite image is already ...
1
vote
2
answers
5k
views
keyPressed is not working after adding ActionListener to JButton
I have a serious problem while trying to build a menu for my game.
I've added two JButton to a main JPanel and added an ActionListener for each of them. The main JPanel also contains the game JPanel ...
0
votes
0
answers
83
views
Brick Breaker - Adjust ball's collision angle without affecting speed
I'm working on a Java Brick Breaker game, and it's functional so far. However, I'm facing an issue with collisions. Currently, when the ball collides it simply reverses its direction.
I want to ...
0
votes
0
answers
22
views
Blinking JLabel for Wordle-like game?
I would like to implement a blinking effect on a JLabel in a wordle knockoff I'm making. I think this will involve using javax.swing.Timer but I'm not sure how I ...
2
votes
1
answer
4k
views
How can I support PlayStation 3 controllers in my Java game?
Is there a way to interpret the input from a PlayStation 3 controller, and use it in a Windows and MacOS program that I am writing in Java? I have been looking at SDL and OIS, but they aren't coded in ...
1
vote
1
answer
2k
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 ...
0
votes
0
answers
38
views
Why is my font not found?
Trying to follow this tutorial with using toasts in LIBGDX:
Libgdx - notification popup (something like Toast) - on both Desktop and Android
But i get this error when compiling:
...
2
votes
1
answer
669
views
How to use a KeyListener and an input handler together?
The following class implements a KeyListener, and handleInput() method gets called in an endless loop.
...
0
votes
0
answers
26
views
Bone Indices from GLB Files
ChatGPT and I wrote a GlbImporter for a simple 3d engine written in Java. I can load any Glb model and extract and apply its diffuse textures. Extracting the bone animations is a different problem ...
0
votes
0
answers
27
views
Image fragments when moving up and or left
Not entirely sure how to resolve the issue as I am quite new to programming, however this seems to be my last option in terms of finding an adequate solution.
EDIT: https://streamable.com/0i92xq - ...
7
votes
1
answer
4k
views
Drawing fonts with LWJGL3 with OpenGL
I'm very sorry if this question has already been answered, but since I've been struggling with this for many days I thought I'd give it a shot here.
My goal is to somehow render some text on the ...
1
vote
0
answers
236
views
Realistic bouncing ball physics
I am trying to implement realistic physics for my game plinko. As of now i only implemented the inversion of the velocity and the distance between both objects.
...
0
votes
0
answers
34
views
How can i translate this code into java?
My only problem translating the code from this question/answer is the Vector2 method. In the web i could only find this replacement (Vector2f). But i can not import it : can't resolve reference. Also ...
1
vote
1
answer
450
views
NiftyGUI - Text isn't rendering
I am trying to create a gui with nifty on top of lwjgl. I've already had some problems during the Nifty setup, however now Nifty is set up and running correctly but for text rendering.
Here is my xml ...
0
votes
1
answer
47
views
Modifying LibGDX vector2's seems to do nothing
I have a piece of code similar to this:
Vector2 test = new Vector2().setLength(20).setAngleDeg(45);
But when I'm trying to print its contents (such as ...
1
vote
1
answer
394
views
Best way to make a Side Panel UI with Libgdx?
Take this image for example, the game is called Realm of the mad god, and it has this side panel filling the whole screen height with the player info.
To reproduce it, Is there any way to make the ...
0
votes
0
answers
41
views
LWJGL Shader not displaying anything to the screen
My basic shader program isn't displaying anything to the screen. Please Help!
Here's my code:
...
1
vote
2
answers
525
views
SurfaceView shows black screen
My code does not work correctly. SurfaceView shows a black screen instead of Bitmaps. I make a game loop that doesn't depend on CPU, like Fix Your Timestep!, but I can't get it to work.
...
2
votes
1
answer
2k
views
Multiple enemy array in LibGDX
I am trying to make a multiple enemy array, where every 30 secods a new bullet comes from a random point. And if the bullet is clicked it should disapear and a pop like an explosion should appear. And ...
0
votes
0
answers
50
views
Only first line/column of level text file gets loaded into tile map
I'm trying to make a map using a text file, but it only does the first line / column and not the rest.
I know the problem is in getTileImage.
...