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
0
votes
1answer
45 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
1answer
214 views

Billboard quad in same draw call?

I am currently drawing a isometric world in 3D, meaning the floors and walls are all quads aligned to the original axis in the world and using a rotated orthogonal camera to "distort" the images into ...
0
votes
0answers
8 views

adding video to jrame

I am using java to build a game and I want to do something like that example: I am pressing some pre-detmired button that causes a video to start. I want to do something like a cutscene that will ...
1
vote
3answers
9k views

Handling multiple pressed keys with KeyListeners

I'm making a game Applet with Java that uses KeyListeners to control a paddle (for a game like Breakout/Pong). My basic implementation goes like this: ...
0
votes
0answers
31 views

best method to draw in android studio games

After several tries to draw my player, enemy object in my game, I often face a problem rendering either because the method cannot be resolved or because I have a player and enemy classes both extend ...
0
votes
0answers
12 views

LibGDX - Java — How do I determine the alpha value of a pixel programmatically?

My goals are to generate hit boxes and click boxes using alpha values (so that parts of my textures that are invisible remain uninteractable) I have code already for determining if the mouse is ...
0
votes
0answers
37 views

Skybox textures is black

My skybox is displayed, but does not display the textures that I load from the image. Instead, it shows the transparent color if i set glTexImage2D how ...
3
votes
1answer
5k views

How to zoom and scroll in libGdx?

I am trying to both A.) Pinch zoom my game scene and B.) Move (scroll) my game scene but I have not found many examples. I learn more by examples than by reading API documentation (although I am ...
0
votes
0answers
12 views

LibGDX Scene2D a different way of implementing a GUI scale setting other than multiplying everything by a constant?

I have a bunch of UI elements for my game. I have an inventory, HUD, hotbar, in-game menu etc. Now I want to scale these based on a setting. I import the settings from a file and basically put it in a ...
0
votes
0answers
13 views

moving player according to swipes

In my Player.java class, I want to incorporate a function that moves my player according to the left or right swipes. I also used time in seconds in order to vary the movement in an cyclic way: <...
0
votes
1answer
22 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 ...
0
votes
0answers
25 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
0answers
8 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 ...
2
votes
1answer
47 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
0answers
18 views

How to fix “stretched” textures in LibGDX?

I'm drawing textures using SpriteBatch and all textures are stretched. Previously I was using Stage and StretchViewport and back then everything was fine. My code: ...
2
votes
1answer
1k views

Pattern for collision handling?

I am writing a game with Java. There are many different kinds of entities on the screen, like the player, NPCs, monsters, bullets, items, shiftable blocks and so on. This question is not about ...
11
votes
4answers
5k views

Is it possible to implement Steamworks functionality in a Java game? How?

I have a basic game that I want to eventually turn into something better. The game is all Java as of right now, but I want to implement the Steamworks SDK into my game (so it can have achievements, ...
0
votes
1answer
38 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
0answers
24 views

Heuristic for Board Game AI Resulting in Tie

I'm developing a program for a Line of Action game (see specs here: http://www.boardspace.net/loa/english/index.html) For the AI, I've created a game tree, pretty similar to most game tree ...
1
vote
0answers
65 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
0answers
40 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
0answers
99 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 ...
1
vote
1answer
100 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
0answers
25 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
1answer
98 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
1answer
69 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
0answers
35 views

Character shakes when using raycast avoidance (libgdx)

https://github.com/libgdx/gdx-ai/blob/master/tests/src/com/badlogic/gdx/ai/tests/steer/box2d/tests/Box2dRaycastObstacleAvoidanceTest.java Literally, I copied the core avoidance code. But substituted ...
0
votes
1answer
121 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
2answers
44 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
1answer
36 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 ...
0
votes
1answer
61 views

Faster way to load VBOs in LWJGL

I'm currently working on a Minecraft clone for a university project and I'm having some trouble loading a lot of chunks at the same time without reducing performances. What I'm currently doing is: ...
5
votes
5answers
1k views

How can I support retina/high-DPI/high-res graphics in libgdx?

I'm not sure if I'm missing it somewhere or if this just doesn't exist, but I'd like to support "retina" graphics on desktop displays that support them (like the newer MacBook Pro), but I can't find a ...
0
votes
0answers
20 views

How to handling touchpad?

I have a touchpad. I tried touchpad.getKnobX> 0 and <0 (when swiping the knob left and right) the sprite still displayed but when I put touchpad.getKnobY> 0 and <0 (to swipe knob up and down) ...
0
votes
1answer
233 views

How to reset snake in javafx game?

I am making snake in javafx, I have completed my game, and I am trying to add a reset button in my game. When I click the reset key (ENTER), the game should reset, but the arraylist that stores the ...
0
votes
1answer
34 views

Close objects are only partially rendered - LWJGL [duplicate]

I'm working on a LWJGL project and I'm experiencing a weird problem: close objects stop being fully rendered as I move slightly away. I'm not very expert in OpenGL so I can't figure out what is ...
0
votes
0answers
93 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 ...
2
votes
2answers
1k views

How do I use a JBox2D ContactListener to check if my character is standing on the ground?

I want to know when my character is touching a wall or floor. I've had no luck searching for information on this. I saw a few things about ContactListeners and <...
2
votes
1answer
119 views

How to load a separate map from a text file?

I have a text file that I am using for my map for the tiles to be allocated. This works fine, but I am running into issues figuring out how I would go about loading in a different part of the map. ...
3
votes
1answer
239 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
0answers
32 views

LibGDX Box2D, how to play an animation once, then set the state back

So, I've got some animations in LibGDX that I want to get running. Currently, the walking animations work perfectly, but attacking doesn't. I want the attack animation to play once, then set the State ...
1
vote
0answers
24 views

Why does BorderLayout crop out JSlider on JFrame

I have some working code with a small circle randomly appearing around a large circle in the middle, kinda like planets. I have implemented a JSlider that controls the speed of the small ball moving ...
0
votes
1answer
143 views

Good data structure for storing graph-like map

I'm creating a strategy-based kingdom expansion game, where you start with one city and try to expand as far as possible from there. All the cities fit on a hexagon-grid and are connected by the edges ...
0
votes
1answer
29 views

How do you make a shape slide on a JFrame?

I have some simple code that draws a dot in one of 8 places on a screen. There is a higher chance the dot will appear in some locations more than others. The code works and all, but it feels kind of ...
0
votes
1answer
98 views

Should I use Panels or Frames?

Hi I am creating my first game in NetBeans using Java, the game is going to be an RPG that will look a bit look Undertale on the surface in that there will be a menu, then a load game section and then ...
0
votes
0answers
35 views

Setting the position of a Rectangle does not always work in libgdx

I'm experimenting a little with libgdx and I'm trying to use it to create a little android game. Everything goes well until I try to correct the player position when a collision occurs. This is the ...
7
votes
5answers
10k views

Difference Between LibGDX and LWGJL [closed]

I've been looking into developing a small game with Java, as I am fairly familiar with it and see game development as good opportunity to improve my knowledge. When I research different libraries and ...
1
vote
4answers
240 views

how to make ascii ui like in dwarf fortress

Only one text field, and inside it - different sections, menus, and popups, all in ascii. How to make that? I mean something like this: ...
10
votes
6answers
9k views

How do I get pixel to hex coordinates on an array based hex map?

I'm trying to make a pixel to coord function for a hex map but I'm not getting the math correctly, everything I try seems to be a little off, and the examples I've found were based on circled centered ...
1
vote
1answer
388 views

LibGDX How to set spacing between list items in a Scene 2D Select Box Widget?

I have created a Select Box (Scene2D widget) which holds a list of items, to be selected. My code works fine, but I would like to make a little more spacing between each list item in the dropdown list ...
0
votes
1answer
67 views

What is wrong with my gravity calculation?

Im trying to create a method to calculate the fall time for an object using real formulas. Well I came up with this: ...

1 2 3
4
5
67