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,439 questions
2
votes
2
answers
654
views
LibGDX Efficient way to reduce a vector's value gradually until it reaches 0,0
I can manage to achieve this but the code seems to be much longer than it should be. Velocity is given an initial value, either positive or negative and then is ...
1
vote
0
answers
125
views
Efficient way to store “item” objects in a simple game
I am developing a simple text-based game from scratch in Java. In this game, the user is able to collect items and store them in an inventory.
My question is: how should I organize the internal ...
1
vote
1
answer
352
views
(LibGDX) Set actor to fixed position on TiledMap
How can I set an actor to an absolute / fixed position on my TiledMap, such that it does not follow the camera when I pan around?
Currently my code looks like:
...
0
votes
0
answers
84
views
Trying to create a knockback effect between 2 squares (Code in Java)
I've been in trouble for weeks now and I don't understand why it doesn't work for me! I have tried so many things and I just can not understand.
I try to get one player to get a knockback as soon as ...
1
vote
0
answers
33
views
Recognize L-Shape in a 4x4 Matrix
I'm trying to make a board game, there the player has to press four buttons to make the L. It can be mirrored or rotated, it just has to be an L.
But if the player press four buttons and make another ...
1
vote
1
answer
509
views
Using server timestamp to synchronize actions across clients
tl;dr
The question is rather simple: how unsynchronized can internal clocks be between different machines?
Context
We have a "hybrid" approach where the Clients are authoritative on certain ...
-1
votes
1
answer
1k
views
How to make camera move with the player in 3D Libgdx
Iam trying to create a 3D game in Libgdx, so I created a 3d World with physics, and added just a small terrain and capulse (the Player) .
I want to make the game first person, so I created a player ...
-1
votes
2
answers
115
views
How to load 3D modells when they are necessary
I'm working on a 3D game engine, currently I load ALL of my 3D modells into the memory when my game starts, but obviusly there will be hundreds of 3D modells, so somehow I should unload them when they ...
1
vote
0
answers
157
views
How do I run LibGDX's Particle Editor in Netbeans?
I am trying to run the Particle Editor that comes with LibGDX in Netbeans. The gdx-tools-1.9.10.jar file shows up in my dependencies, and I can see all of the ...
1
vote
0
answers
443
views
LibGDX Change mouse cursor to custom image......and keep it there
I'm able to create a custom cursor no problem using the following code running in my GameScreen's Show method:
...
0
votes
1
answer
264
views
Unknown error when trying to register a Minecraft ArmorItem
The error in question is [Inferred type 'I' for type parameter 'I' is not within its bound; should extend 'net.minecraft.item.Item']
on the following snippet of code
...
0
votes
1
answer
329
views
LWJGL 3 HelloWorld example crashing
I'm trying to start LWJGL 3 development and I am having an issue with getting things working. I have created a new Gradle project and successfully built the HelloWorld example from https://www.lwjgl....
1
vote
1
answer
206
views
How to clamp a mouse angle within a field of view range of the facing direction
In my top down shooter game, the player can face in any of the 8 compass directions using the keyboard.
Depending on the direction, the player will have a 90 degree field of view to turn based on the ...
1
vote
1
answer
269
views
A star pathfinding path too narrow for enemy
The tiles for my top down 2D shooter are 32x32 and the player and enemies are too. But obstacles like walls and other things can of course be smaller than this - the smallest being 8x8. This causes a ...
1
vote
1
answer
134
views
Libgdx opacity partial error
My model must support transfer textures but I can't do this using mesh + modelBuilder.part
Opacity is tested correctly on only half of the model.
...
-3
votes
1
answer
52
views
Increase speed when score gets high or when the fish eats pellets
I want fish to increase speed when score gets high, or when the fish eats some balls
...
3
votes
1
answer
3k
views
How can I save game "professionally"?
I am a novice programmer and just learned about the concept of saving and loading games. The way I am doing it is to write data into a text file and read it afterward. However, I realize how insecure ...
1
vote
1
answer
504
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
2
answers
364
views
Java LERP but with whole pixel values
I have a formula which returns a Lerp Vector3 value in integers but the problem is it never reaches the desired target value. It'...
0
votes
1
answer
620
views
LibGDX Letter spacing is reduced if I use GlyphLayout to draw a bitmap font
I need to use glyphlayout so that I can centre the text, but I found if I do the text gets distorted due to the spacing being incorrect.
...
0
votes
1
answer
2k
views
Error while trying to Build APK, fails when profile option is enabled
When I build normally my android app it execute without no problems, but when I go to File -> Buil and Run and I eneble Development Build and Autoconnect to profiler I got this error
...
0
votes
1
answer
88
views
Looking for tips on how to optimize/debug Java/Eclipse
I made a raycasting engine with wall textures. Before adding the texture the engine was silky smooth. With textures it has small lags (or stutters) when i move around and i would like to know why. My ...
0
votes
3
answers
1k
views
Class Not Found Exception on Class.forName()
I am having this exception on title. I have been following a LibGDX programming PDF, everything was working perfectly and then this code have been implemented, and it isnt working anymore.
I should ...
2
votes
1
answer
351
views
Drawing object lines in the Tiled map editor
Suppose I have this picture:
I have a map like this created in Tiled already. I would like to draw collision lines (the green ones in the picture) without having to make it a polygon. As far as I know,...
0
votes
0
answers
73
views
Is using sprite sheets and drawing specific part the way to go?
I'm programming in Java.
I have more than 200 MB of images used in my games, something like 100000 40x40ish images. I initially wanted to load them all during app initialization but it took like 2 ...
1
vote
1
answer
149
views
Function to draw an image inside a rectangle
How can I draw an image inside a rectangle?
I am introducing myself in the manipulation of images for games, I have a window and inside there is a rectangle that deforms. I would like to fill the ...
1
vote
1
answer
225
views
How to choose what to use in Java: Enums or Objects?
I'm in a dilemma over using Enum Types or using class objects in that particular part of my java project.
Let's suppose I have an array where I constantly add and remove things from it, but I also ...
0
votes
0
answers
51
views
What design choice should I follow for client-server communication?
My game server currently launches a thread for each connected client, and handles all data exchange through that socket in a server-blocks-until-client-requests fashion. The problem derives from the ...
1
vote
1
answer
447
views
Java - set resolution of game
Hi everybody I am making small game using pure Java 8 and rednering it by Java AWT Graphics2D method . My question is how to make that user can change the quality ...
0
votes
1
answer
128
views
Box2d: crash on createBody in beginContact callback
I am getting this error on creating body in contactListener
...
0
votes
1
answer
411
views
What is the most efficient way to load all the textures?
I am developing a game (in Java) that is going to have a lot of textures and images in it.
What is the most efficient way to load all the textures? I was thinking on pre-loading all the images ...
0
votes
0
answers
152
views
Libgdx storing rendered frames quickly to use them later
I have implemented a gif-button for my libgdx game that allows the player to store the last few seconds of gameplay as a gif.
It works by storing frames in memory, and encoding them into a gif if the ...
0
votes
0
answers
10
views
Problem of activities [duplicate]
My game consists of a player that hopes between ropes.
For now, I created the player and the rope classes.
Each one contains details about the object and its movement patterns.
What is the next step ...
-1
votes
1
answer
73
views
Positioning ropes equidistantly on a landscape display
I would like to render 4 similar ropes in my game that are equidistant on a landscape mode display.
How can I proceed? My screen is 1920*1080, at 420 dpi.
Is there any way that I could link the ...
2
votes
1
answer
135
views
Connecting Player and Rope classes in a rope-swinging game
I am trying to build this game where the player hops between a number of ropes.
For now, in addition to my main activity that I kept empty, I built two additional classes:
...
0
votes
1
answer
91
views
How to make controlled exchanges in an online-game?
There is an online game in which you can collect things of different values: ordinary, epic, legendary. The cheapest things are ordinary, the more expensive are epic, and the most expensive are ...
0
votes
1
answer
281
views
How do I make an actor move to the foreground temporarily in LibGDX scene2d?
I have an inventory UI which is a table in scene2d. Then the table had a bunch of Containers which are basically inventory slots. They have a transparant grey background color. Then in each container ...
1
vote
0
answers
386
views
Hitboxes in a Java game without rectangles
I left this question on "normal" stackOverFlow but they recommended I asked you guys! I am new to making games in Java but I made some games using the paintComponent method, however I felt like I was ...
0
votes
0
answers
58
views
Is using an anonymous inner class to determine game item behavior the right way?
I'm developing a little game that has a bunch of different items. I categorize the items in separate classes (consumables, armor, weapons) that all extend Item.class. Then I use one main Items class ...
1
vote
0
answers
653
views
What design pattern would be most suitable for RPG skills?
I'm developing a small Java digital card game project. In my game, players can perform skills when using cards. Each skill does different things, like deal damage, heal etc.. I'm looking for a way to ...
2
votes
1
answer
1k
views
How do you draw a random irregular polygon in java? (Asteroids)
I am coding an Asteroids game in Java. In the real arcade game, asteroids are made of irregular shapes like this:
When I code, I can only set asteroids to 1 or another specific shape, like this:
...
0
votes
0
answers
84
views
Java clicking on tiles detection
I am making small isometric game, where I want to do something when user clicks a tile. I can simple do it by mouse location, but I want to be able for zooming and moving camera. It will be 2D game ...
0
votes
1
answer
294
views
Button on click event crashes
I'm trying to create an android game using libgdx with a Titlescreen, you just press start and your game startes. However I'm having difficulty trying to get these buttons to work. The titlescreen ...
2
votes
1
answer
616
views
Json Libgdx serialize / de-serialize a Object Map of Object Maps
Any one have any ideas on how I can serialize / de-serialize an
ObjectMap<Enum, ObjectMap<String, Object>>();
(Object is usually a String Integer ...
1
vote
1
answer
513
views
Topdown Game Collision Detection
I am working on a simple game with topdown movement, but I am unable to get the collisions to work properly. I know the collision detection itself works, but the constraining of the player is where I ...
1
vote
1
answer
1k
views
How can I capture only a part of my sprite sheet in my game for Java?
I have a University Project to create a simple game in Java. To challenge myself am trying to utilise sprite sheets. My issue is that the whole Sprite sheet is being shown rather than the section that ...
0
votes
1
answer
83
views
How do you repeat 2D tiles in Java code when you go out of range?
I am looking up tutorials on how to make 2D games, and I can just copy and paste their code but I would rather know what it means and how to do it.
Suppose you have a 2D game window that has a map ...
0
votes
1
answer
187
views
What is the meaning of >> and & in this code context and what they are trying to accomplish?
I am following a tutorial on YouTube for making a 2D game. There is no clear explanation on what its actually doing.
I get bit-shifting and & operator but I don't know what they mean in this ...
1
vote
2
answers
259
views
Dividing coordinate into unit cube
I'm trying to write a Java class to generate Perlin Noise from a Cartesian coordinate. I'm trying to follow this tutorial but I am struggling to understand the theory.
Specifically, how do you divide ...
1
vote
1
answer
535
views
Implementing a movement and collision system with Vectors and Area
I've scoured gamedev for around 45 minutes, but I'm unable to find a detailed approach to implementing a movement and collision system for games - specifically, when to use which process, and what to ...