Libgdx/Java 2D Duengon collision and collision from all sides - java

im currently developing a small game, a duengon rpg crawler.It all works fine and today i tried to implement a collision mechanic, because you shouldnt go trough walls... The map is completly randomly generated.
I havent found any good tutorials how to setup a collision mechanic for libgdx or java, just something like this :
Rectangle rect = new Rectangle();
rect.overlaps(r2);
That worked yes, but it didnt showed me, where the Rectangle colides with the other one. All i wanna have, is a good tutorial about java or libgdx, how to make a all 4 sides collision, step by step :) Or an example...
Thanks for your attention and your help.

Related

How to move and object to specific coordinates?

Im making a java game, and the objective is to doge bullets. Im wondering if there is any easy way to use .getX() and .getY() of a specific object to make the bullet move towards that object? Im trying to have the bullet either chase the players X and Y coordinates or get the players coordinates and go to those. I am very new to java, so the more simpler the better. I have tried a few scripts from different forums, but nothing seems to work. So far I have just been rendering rectangles for my bullet and character.

libGDX: Let an object rotate in the direction in which it moves

I want to turn my player in the direction he is looking at. The whole is so similar to the behavior of the Bird in FlappyBird. He always looks in the direction in which he moves. I am programming this in Android Studio with libGDX and I have a class in which the game is played and one in which I have information about my player.
I have unfortunately no code example, because everything I have, would explain nothing and would make the situation only more complicated.
Please write a comment if you are confused.
Thanks for any help! :)
I think what you are looking for is a way to flip the sprite. Sadly, I don't think libgdx supports this. But what you could do is draw 2 images of your sprite(one in each direction) or use some drawing program to flip your current image. Then in your sprite class, in your update or render method you would change the sprite image to the corresponding direction using sprite.set(new Texture())

collision detection, in libgdx

I am new to the world of libgdx and the world of game programming in general. I want to create a game, but not any game. I have created some basic game like breaks, and pong. But I still cant go any further, I google for good articles, but I always have problems with collision, especially between entities! I want to create a game with slopes like sonic.
Why not use Box2D (libGDX extension) ? It's perfect for platformers.
Do you know how to create rectangles. I assume that you know about rectangles.
if you want to check collision of two rectangles you can do as follows:
Rectangle a = new Rectangle(), b = new Rectangle();
in constructor set rectangles
a.setRectangle(yourX, yourY, yourWidth, yourHeight);
b.setRectangle(yourX, yourY, yourWidth, yourHeight);
in render check collision like this:
if(a.overlaps(b))
{
//do your work
}
U can use OverlapTester class given in SuperJumper Project by LibGdx
Create Your bounds using rectangle class in Libgdx and test them using Intersector class.
This class has many function to test overlapping of rectangles, circles etc..
I recommend you to use box2d if you know the basics.
if you know how to use a rectangle, sprite batch, camera etc. Then you should proceed to Box2d if you don't just take some good tutorial and try to make the application without any extension.this will make your concept clear and you will easily able to grasp the logic behind the game.

Basic dynamic 3D collision in LWJGL

sorry about my last question it was a bit all over the place.
I have hit a huge road block with a game I am coding for a friend and i need to learn dynamic collision. A tutorial would be great, a very basic one and i have already seen the NeHe collision detection tutorial and did not seem to pull much from it.
Thanks in advance to all who reply.
What you could do is create a invisible 3d box surrounding your entities and check when two or more of said boxes have intersecting xyz coordinates. I can't supply you with code, but I know it works. You would have to figure out the coding for yourself

How to implement image map type interface for a game board in Java 6

My group project at school is to implement a style of monopoly in which students can buy courses and land on various squares and move around the board. This is not a regular square board so we were wondering if anyone had any ideas on how we would implement an image map or something like it to create many clickable regions not in a perfect square. I have attached the image of the game board. Just a way to start is needed, not lots of code or anything as we all know java pretty well. If anyone has any ideas that would be great.
Image of board is here.
Java image maps can have polygonal clickable regions. As usual, Sun has an excellent tutorial.

Categories

Resources