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
0answers
19 views

Libgdx Recoil Effect

I set -velocityX to my sprite gun. float velocityX = -20 * dt; if(trigger) { gun.setX(gun.getX() + velocityX); } I basically set a velocity of -20m/s to my ...
0
votes
1answer
101 views

Struggling to get AI to repeat infinitely

I am following this as a guideline to help me figure out a simple AI for an enemy as I am new to java. https://www.javacodegeeks.com/2014/08/game-ai-an-introduction-to-behaviour-trees.html https://...
1
vote
0answers
45 views

Why is my player falling through the Tiled map?

I am gassed. I have this game due very very soon. I made my player so that it doesn't fall through or go through tiles from Tiled that have the property "blocked". I do not know why but it is not ...
0
votes
1answer
116 views

How to avoid Singleton/Statics/Injection in my puzzle game

I am developing a puzzle game in java with swing. Purpose of the game to find the all the correct pairs on the board without ur lifes reaching 0 , preety simple etc. I have a class My_Button which ...
0
votes
1answer
78 views

I am having trouble with gravity in my game

I am trying to detect if the player is on an object with a tag "canHoldWeight". But the detecting if the player is on an object isn't working. falling code called every tick: ...
1
vote
2answers
99 views

How to use an array of y values to render a 2D top-down Java game?

I'm fairly new to the world of coding, and there's probably a simple solution here. I made this array (the actual one is more complex since it includes everything I have so far) for the y values of ...
0
votes
0answers
11 views

LibGDX How to use Viewport correctly?

guys! I divided the screen into two parts using Viewport and now the game does not work correctly. The control buttons do not work all. If you click in some part of the screen (not on the control) -...
1
vote
0answers
30 views

What would be the best way to let Box2D handle collision on different (simulated) heights?

I'm working on a 2D top-down game but we are also using a Z coordinate. This is to simulate the effect of 3D/height. Now the player can walk under a bridge and also over a bridge. The next thing I did ...
0
votes
0answers
13 views

calculate pong angle sometimes right sometimes wrong

I'm workin on a pong-game and i tried to implement the bounce of the paddle. I used the answears in this question In Pong, how do you calculate the ball's direction when it bounces off the paddle? ...
1
vote
0answers
27 views

Random Elements from an Object-Array

In my project I have 5 superheroes, all of them have 3 superpowers in an Array and I want that the superpowers got chosen randomly in a fight. But my problem is, that I cant create a general method ...
0
votes
1answer
32 views

toString() - method doesnt' choose right Array Index

My topic is a adventure game. The heroes have Superpowers, but if I want to print the superpowers from a superhero, it prints just the last index of my array, which I set it before. My code: ` ...
0
votes
0answers
9 views

Trying to spawn enemies randomly every one second through an arrayList but nothing is showing up

im making a space invaders/astroids type game right now and i am working on randomly spawning enemies that go from the top of the window down to the bottom. I figured using time would be best for this,...
1
vote
1answer
58 views

Is it a good idea to implement a MVC pattern into my LibGDX 2D RPG-style game?

For example I currently have a Player object that contains it's textures/animations and how to render these (I'd consider this as the view). Player also has an update() method which controls where the ...
0
votes
0answers
22 views

Which spigot player event should I use?

I'm working on a plugin project and I am not sure which event to listen for? I have tried these events with some success: PlayerInteractAtEntityEvent PlayerInteractEvent paste-bin Main: https://...
1
vote
0answers
67 views

Building battle ship in processing. How do i connect the ships together and randomize the location of the ships?

ive been working on this side project trying to make a battle ship game from some time now. I have come across a few things I do not know how to do. I was wondering if anyone knew how I could make ...
1
vote
0answers
17 views

Having difficulty integrating flow field with flocking algorithm

I have been tweaking my path-finding in my game for a while now, and it's mostly functional, but there are some major issues that are holding me up. I have a flocking algorithm implemented to help ...
0
votes
0answers
11 views

android game opengl Es 2 crash on start

I have downloaded an openGl es 2 projects for github in this link https://github.com/niflostancu/PocketF22-Android And when I opened it, it crashed, and give me this log ...
0
votes
0answers
9 views

Howto use orthographicCamera with actors with shaperenderer (libgdx)

I have a simple actor, which draws a circle. I have a orthographicCamera now I want simply translate the camera, so that the circle moves without changing the coordinates of the circle. I can't ...
1
vote
0answers
76 views

Forge 1.14.4 Minecraft modding: Override vanilla loot tables

I cannot figure out how to override vanilla loot tables, I've been at this for hours, and I can't find anything online. Just very outdated tutorials. I added custom crops and seeds to my mod, now I ...
0
votes
0answers
19 views

Java Cocos Creator

Is it possible to call a java function from external java file for android ? cc.Class{..onLoad:function(){Android.loadExternalFile(filePath).call(method);}..} Is ...
0
votes
0answers
40 views

Android libgdx java

Question1:Bird collaide with Coin that time coin is dissapear working but shudenlly apeared.What do to?.android java libgdx for(int i = 0; i< coins.size; i++){ Coin coin = coins....
3
votes
1answer
138 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
0answers
53 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
0answers
20 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
94 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 ...
2
votes
2answers
96 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
0answers
91 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 ...
2
votes
0answers
66 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. ...
1
vote
1answer
45 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
29 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 ...
1
vote
0answers
16 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 ...
0
votes
1answer
34 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 ...
1
vote
0answers
24 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
58 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
0answers
41 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 ...
0
votes
0answers
58 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
17 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
20 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
2answers
68 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
1answer
47 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 ...
1
vote
2answers
97 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, ...
0
votes
0answers
33 views

Why does a part of the background turn white when the image disappears? Photo attached

I have an image of a fish that I've drawn to the screen, which has a transparent background: When the ninja touches the fish, I want the fish only to disappear, without affecting the background. ...
3
votes
0answers
55 views

Strange normal mapping artifacts - OpenGL / GLSL

I have been following a few tutorials to learn some graphics programming with OpenGL, and recently implemented Normal Mapping. It works well for the most part, especially for objects with normal-...
1
vote
1answer
69 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 ...
2
votes
1answer
74 views

How to draw a string into a polygon? (Libgdx, Java)

I am working on a 2D grand strategy game (like Hearts of Iron from Paradox but as I said only 2D game) and I would like to render the area names on the map. I made the Polygons for each area. How can ...
1
vote
0answers
47 views

Moving with rotating in 3D world in Libgdx

I'm trying to create a first person system in my game which consist of a big cube with grass texture , so the problem happens when I move and try to rotate the camera the world rotate and I'm not on ...
0
votes
2answers
67 views

OpenGL ES model loader is slow?

I'm trying to load a 3D model in OpenGL ES, and I managed to find a project on "sourceForge" that can do this job. When I downloaded it and played the app, it took 50 second to load a small object (...
0
votes
1answer
118 views

How to make a world map from image like in paradox games? (Java, LibGDX)

I'm working on a grand strategy game similar to those made by Paradox Game Studios with their Clausewitz engine. I'm trying to create the world map from an image. On that you can see the areas, and ...
0
votes
1answer
36 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
0answers
19 views

TurnBased Server Design

I want to create turn based card game. Im currently writing server part in Java and I designed one little mechanism how it could work. On one server I want to be able to have lots of desks. So the ...