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.
1
vote
0answers
9 views
Java Libgdx Attaching Sprite to Box2D Body
So I am working on programming a java 2D platformer for fun on the side and I have a rendered TMX level and a box2d body (just a circle shape) that I am currently using as my player. All the controls ...
0
votes
0answers
9 views
libGDX pooling problem
I have a problem with pooling and I don't know how to fix it. This algortithm works when I create a vector every frame. Here is my code:
/**
* Calculates the active Chunks around the player and ...
0
votes
0answers
15 views
LibGDX - black bars, FitViewport and drawing background
actually I'm creating game in LibGDX and i have few problems. I'm trying to solve resolution and aspect ratio problem by using FitViewport but i want to dispose black bars which occur when resolution ...
0
votes
0answers
22 views
How do I have an unspecified number of class instances? [on hold]
I am writing a game where cannonballs are fired from cannons at random intervals.
How do I handle creating instances of my cannonball class at a random interval, then getting rid of that instance ...
3
votes
1answer
87 views
How do I get A.I. that follows a list of movement commands to move smoothly in a tilemap based game?
This is for a school project so it's not intended to be sold/fun/or a complete game, rather just a demonstration of stuff we've learned without resorting to frameworks and stuff.
My ai agents choose ...
0
votes
0answers
16 views
What technique to use for fast pixel physics [on hold]
What proven design patterns or techniques are ideal for implementing physics and collision detection, with speed, on a per-pixel basis. Below are some examples. C++ is what I plan on using and any ...
0
votes
0answers
13 views
Move ball through a direction angle in android canvas [duplicate]
I am building a simple game in android.
I am successful in first step where I draw a ball in canvas in touch point.
Now I am trying to move it from an initial point A (center) through the touch point ...
0
votes
1answer
33 views
libgdx - Math for wall collision when adding velocity
I've created a game which spawns a random colored ball in the top or bottom of the screen and moves to random direction with this method.
private Vector2 position;
private Vector2 velocity;
private ...
0
votes
0answers
19 views
How can I simulate a basketball throw in LibGdx box2d?
So I want to simulate a similar throw like in the game Bouncy Basketball.
Do i need to create a body and attach another body on it that would be the arm and then how would I apply force/impulse to the ...
1
vote
1answer
28 views
Circular Movement
if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
if (i < 360) {
setX((float) (groundState.getX() + groundState.getRadius() * Math.cos(Clock.delta() * i)));
setY((float) ...
0
votes
0answers
25 views
libGDX text doesn't appear in TextField
A game I'm working on has libgdx's TextField. They work fine in every instance I've used them, however on a play tester's phone he says no typed text appears in the box until enter or space is ...
0
votes
1answer
16 views
How do I know if the ad is open while the use pressed the back button?
I am trying to reward a user a point whenever they watch/look at an ad. I give the user the reward whenever they watch the ad. However, the user earns a point even if they go to the ad and click back:
...
-5
votes
0answers
51 views
Building a game. Coming from a PHP webdev background. Where to start? [closed]
I guess me question was off topic where i origianlly posted it. So im posting here, where I hope its in the proper category. If not than ill seek help elsewhere.
But, I am a Web application ...
0
votes
1answer
30 views
What does the TextureRegion.flip() method do?
I'm learning libgdx and don't understand the purpose of parameters passed to flip(boolean x, boolean y). For example, I have code like this:
texture = new ...
1
vote
0answers
48 views
Slick2D fails to load small textures
I'm trying to load a small 32x32 png texture using Slick2D, however it doesn't seem to render correctly. What's odd is that larger textures do load correctly.
The 32x32 texture I'm trying to load:
...
-1
votes
1answer
26 views
Exception in thread “Thread-0” java.lang.IllegalArgumentException: input == null!
whenever i run my game i get this Error.
Exception in thread "Thread-0" java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(ImageIO.java:1388)
at ...
0
votes
1answer
31 views
Canvas doesn't draw
I've set app view on XML based layout:
setContentView(R.layout.mlayout);
with some views objects on it. Then, I added another view via:
RelativeLayout layout = (RelativeLayout) ...
0
votes
0answers
19 views
Ads are loading, but not showing?
TL;DR: My interstitial ads in my game are successfully loading, but when I call .show() on them, they don't show up!
I have followed these directions, and the ads load succesfully, but don't show ...
0
votes
0answers
33 views
Java multiple player objects/enemy objects?
NOTE: I'm a beginner and learning :D
Alright, so in my game I have a class for the player (with the parameters of x, y, color, width, height, and health, same parameters with the enemy). But I have a ...
0
votes
0answers
39 views
How to fix my issue with movement?
I am making a 2D tile game in Java, and I am having problems with movement, could someone tell me what I am doing wrong please?
I am having difficulty in "calling" the function vectorFromKey in main. ...
-1
votes
0answers
30 views
How to make character selection in slick2D?
I am trying to make the player able to select between two characters in slick2D, but I cant get the map class to use the variable holding which ever character the player selects.
Map Class:
package ...
3
votes
0answers
25 views
Calculate Relative Mouse Movements Regardless of position
Context
I'm working on making a variant of the atari game Breakaway IV and I'm trying to improve my mouse input handling.
I use the input of a mouse's motion left and right to move the bumper.
...
0
votes
0answers
38 views
JBullet is acting weird, what is causing these 'floating' rigidbodies?
I've been working on a 3D game engine in Java for a school project. The game engine had scenes containing game objects, these game objects contain components defining the behavior of each object. I'm ...
2
votes
3answers
113 views
Accelerated movement in a specific time to a specific point
I am trying to move my sprite in a specific time to a specific position while using frame-independent or time-dependent movement. My sprite is also accelerated every frame to simulate gravity. I know ...
1
vote
0answers
43 views
Texturing Cubes
How can I texture a cube that is able to rotate in x,y and z direction in pure Java?
Here is what i have tried:
package main;
import java.awt.Color;
import java.awt.Graphics;
import ...
1
vote
1answer
43 views
How to handle two players playing on one keyboard with Box2D (LibGDX)?
I'm making a racing game with LibGDX and Box2D. I've been using this tutorial to implement the basic physics, and it works properly.
My main problem is to implement two different sets of keys ...
0
votes
1answer
76 views
Why is my deltaTime in my GameLoop 0?
I have a question about my code. I wrote a basic GameLoop
for an Android Game and while testing it I realized the deltaTime
is always 0.
The code looks like this:
@Override
public void ...
0
votes
1answer
32 views
LibGDX--constant high score in top corner
I'm currently programming a game using LibGDX and box2D. I have a sprite (player) that moves up the screen, kind of like doodle jump.
I'd like to have my camera to be centered around the player at ...
3
votes
2answers
78 views
Designing ability interaction system
I am making a turn based game where player chooses a team of heroes with specific abilities for each of them. (ex. stun one enemy, deal 20 damage to all enemies, heal 10 HP to one ally,...)
The design ...
0
votes
0answers
37 views
Storage and Lookup of Voxel Chunks
How can one store chunks in such a way that they can be looked up using their XYZ location without wasting memory?
The problem with a HashMap<Vector3i, Chunk> is that you have to keep creating ...
4
votes
1answer
92 views
On a 2D generated terrain what is the easiest way to pick tiles for the shoreline?
If I have a two-dimensional array with ones and zeros for water and land respectively how do I choose what shoreline tile to use according to the water and land tiles surrounding it? The shoreline can ...
0
votes
1answer
23 views
LibGDX - Bundling Files
I have 3 files. A JSON file, a PNG file, and a TXT file. Is there any possible way I can put all three inside a common file with a custom extension? (for example "fileName.abc")
I searched the web a ...
3
votes
5answers
339 views
How can I make this day/night cycle computation repeat?
Here's my code for a day/night cycle. I have it set up so that when time (Statistics.duration) is the right number, the light levels switch.
It works great, but I'm at a loss for how to make it work ...
-2
votes
1answer
23 views
What is the purpose of the second parameter to Array.removeValue in libgdx?
I have been wondering what the second parameter of the method in Array removeValue does.
removeValue(T value, boolean identity)
What does indentify mean and should I pass true or false?
0
votes
1answer
31 views
OpenGL perspective matrix far plane
The near plane clips at exactly the value I set just fine but instead of clipping at 1000 the far plane clips at 1.
Here is the code for the projection matrix:
public static Matrix4f ...
0
votes
0answers
11 views
DragAndDrop release with pointer on payload
When I am moving my payload all the way to the corner it remains on the stage and my mouse goes over it when I then release (on a valid target) it returns null as a target and thus does not drop ...
0
votes
0answers
40 views
How can I make an Actor repeat the action on collision in LibGdx?
I want my EnemyActor to do this SequenceAction when it collides with my bullets.
I have already done the collision. Now the problem is that it only does the SequenceAction once when it gets collided ...
0
votes
2answers
52 views
how to add an onclick event to a button?
If I will draw a button with canvas with any programming language (java,javascript....) I want to know how to add the events to what I've drawn for example If I will draw a button piture then what I ...
0
votes
1answer
42 views
How can I apply effects to a character based on the tiles it occupies?
A mechanic of my game is that when a Character (Actor) steps on some specific tiles, they should be affected by status effects like slow, poison, burn, etc. These effects lasts only while the ...
-1
votes
2answers
59 views
How to lock the mouse cursor in the middle in a first person camera?
I want to get a first person camera (like Call of Duty or Minecraft etc.) but I don't know which is the best way to do it.
I have some camera increase rotation methods (camera.increase ...
2
votes
2answers
47 views
Java: problem with 2D corner collision
:)
It took me many days to create a working collision detection for a 2D java platformer... I am finally calculating the corners of my player but the system is still buggy and I hope that we can ...
0
votes
1answer
48 views
Frustum culling only working at certain angles
So how I'm doing this is a little sketchy but I plan on changing it to either AABBs or spheres once I get it working. So the problem I'm having right now is that the frustum culling I've implemented ...
0
votes
0answers
17 views
JBullet & LWJGL Rendering objects with jbullet transform
I tried to render objects with jbullet matrix transform. Its something like that: get float array where is stored matrix then put it to floatbuffer and load to Matrix4f using load() function. Use ...
1
vote
1answer
31 views
How to get the position in an actor inside a table with LIBGDX?
Well the title says it all, I want to get the position of an actor inside a table
Button button = new Button(bs);
table.add(button).width(50).height(50);
table.top().center();
By using
...
0
votes
1answer
42 views
Game Server Mechanic [closed]
Hey guys :) Im currently developing a little rpg duengon crawler.
I really want to implement a local and an online multiplayer function, i know how servers are working and how to make them using ...
0
votes
1answer
30 views
keylistener and synchronization
i have this code:
public final class PlayerInput implements KeyboardInputHandler{
public static final int INVERTED_AXIS = 0;
public static final int NORMAL_AXIS = 1;
private Sprite sprite;
private ...
0
votes
1answer
23 views
Libgdx + Box2d working with 2 cameras
Recently I have read that you can work with 2 cameras whenever you involve Box2d, which only works in meters.
In my Renderer class, I receive all the entities in the game and then draw them. I work ...
0
votes
0answers
22 views
Collision logic with Animations Java
Im trying to code a tile based platformer game with slick2d. While handling the collisions, Im facing with this problem. I could fix it for only that situation but I guess there must be a better way.
...
0
votes
1answer
68 views
How can I make an actor fire a bullet on touch?
I created a Jet and a Bullet, and when Jet is touched, the Bullet is fired.
Now I want to know how can I make the Jet fire again when touched after it has fired the first shot?
public class ...
0
votes
0answers
32 views
LibGDX - Player Movement Flickers
So, I was programming a very simple LibGDX game, so I decided to include a player class into the program. Once I did that, the players image started to flicker/stutter while I moved it.
Here's the ...