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
28 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 ...
0
votes
0answers
15 views

rope hopping game [closed]

I would like to create a game where the player jumps between 5 vertical ropes displayed on the phone screen. Each rope has limited time before it disappears. Can you advise me on how to implement it.? ...
0
votes
0answers
10 views

How to correct variables names? [closed]

I am a beginner in Android Studio programming. When following this tutorial https://medium.com/swlh/recreating-the-famous-flappy-bird-game-for-android-eb10ecd9de4e, I had some issues in my ...
1
vote
1answer
23 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
13 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
0answers
25 views

I need a custom launcher for my Minecraft server

I am creating my own Minecraft server for my friends and I (and then publish it). It uses Thermos for MC 1.7.10, with mods and plugins. My friends don't know how to install Minecraft Java Edition, ...
0
votes
1answer
18 views

Libgdx, button onclick 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 ...
0
votes
0answers
37 views

How long does it take to write a 3d game on android from scratch and what programming language should I use for that purpose? [closed]

I want to make a FPS (first person shooter) game on android but I don't want to use existing engines. I want to write my own by myself. I know that android os uses java for coding and has started ...
0
votes
1answer
33 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 ...
0
votes
1answer
63 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 ...
0
votes
0answers
24 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 ...
1
vote
1answer
48 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
1answer
35 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
1answer
92 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
27 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
26 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
49 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: ...
0
votes
0answers
18 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
27 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
61 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
1answer
81 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. ...
0
votes
0answers
20 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 ...
0
votes
1answer
57 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 ...
0
votes
1answer
27 views

Alternative path not working

I am using Android studio (libGDX), and I can't figure out why alternative paths doesn't work. I've tried it as it said in the book, but it doesn't do anything, it shows a black window and than the ...
1
vote
0answers
20 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
84 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
23 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
0answers
21 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 ...
1
vote
4answers
162 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: ...
0
votes
1answer
64 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
vote
0answers
85 views

2-player online card game architecture

This is the first game I have developed. Please correct me if I'm mistaken. I want to build an online 2-player turn based card game (Shithead). I want to code it in Java as that is what I have most ...
0
votes
1answer
26 views

Ways to track login/loading progress dynamic?

Lets say we want to add a dynamic "loading bar" to our server-client game... the player presses on "login", a bar appears and shows the percentage of loaded assets and configurations from the server. ...
0
votes
1answer
63 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
0answers
24 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
113 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
51 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
128 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
90 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
110 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
17 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
31 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
15 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
28 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
33 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
11 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
91 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
26 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
68 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
20 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
15 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 ...

1
2 3 4 5
66