Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL - AABB Problem on: 2014-03-08 12:42:10
Ah ok, Smiley, Ill send the code soon.
2  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL - AABB Problem on: 2014-03-07 22:56:40
Each of the 4 iss for different positions. Smiley

1: Forward
2: Backward
3: right
4: Left
3  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL - AABB Problem on: 2014-03-07 22:38:20
It's not duplicate code Smiley
It's all the code needed to check if the block isn't Air, isn't null, isOpaque and hasBoundings.
4  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL - AABB Problem on: 2014-03-07 21:33:58
What do you mean?
5  Java Game APIs & Engines / Engines, Libraries and Tools / LWJGL - AABB Problem on: 2014-03-07 20:56:16
Hello I got a lil problem.
I made a camera class and added AABB.
AABB on the Y axis works.
AABB on the X and Z axis don't.

I can walk into a block, at each side (Except up and down (Y Axis)), I tried many things and idk how to fix.
When walking on a block its OK. When walking to a block. I can get inside and it pushes me down inside the world.
The world is empty from the inside because it's not visible so not rendered (Face checking for more fps).

Y Axis Code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
    if(space && !shift){
       if(Game.world.getBlock(this.x, this.y - 3, this.z) != null){
          this.y -= 0F;
       }else{
          this.y += speed * delta * 0.003F;
       }
    }else if(!space && !shift){
       if(Game.world.getBlock(this.x, this.y - 3, this.z) != null){
          this.y += 0F;
       }else{
          this.y -= (speed / 8) * 1F;
       }
    }


X And Z Axis Code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
    if((keyUp)){
       if(Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z) != Block.air && Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z) == null && !Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z).isOpaque() || Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2) != Block.air && Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2) == null && !Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2).isOpaque()) {
          moveLookDir(0.0F, 0.0F, -1.0F);
       }else{
          moveLookDir(0.0F, 0.0F, -speed * delta * 0.003F);
       }
    }
   
    if((keyDown)){
       if(Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z) != Block.air && Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z) == null && !Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z).isOpaque() || Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2) != Block.air && Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2) == null && !Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2).isOpaque()) {
          moveLookDir(0.0F, 0.0F, -1.0F);
       }else{
          moveLookDir(0.0F, 0.0F, speed * delta * 0.003F);
       }
    }
   
    if((keyRight)){
       if(Game.world.getBlock((int)this.x, (int)this.y, (int)this.z - 2) != Block.air && Game.world.getBlock((int)this.x, (int)this.y, (int)this.z - 2) == null && !Game.world.getBlock((int)this.x, (int)this.y, (int)this.z - 2).isOpaque() || Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2) != Block.air && Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2) == null && !Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2).isOpaque()) {
          moveLookDir(-1.0F, 0.0F, 0.0F);
       }else{
          moveLookDir(speed * delta * 0.003F, 0.0F, 0.0F);
       }
    }
   
    if((keyLeft)){
       if(Game.world.getBlock((int)this.x, (int)this.y, (int)this.z - 2) != Block.air && Game.world.getBlock((int)this.x, (int)this.y, (int)this.z - 2) == null && !Game.world.getBlock((int)this.x, (int)this.y, (int)this.z - 2).isOpaque() || Game.world.getBlock((int)this.x  - 2, (int)this.y, (int)this.z - 2) != Block.air && Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2) == null && !Game.world.getBlock((int)this.x - 2, (int)this.y, (int)this.z - 2).isOpaque()) {
          //do collision response for x axis. In this case, you can simply not move the player. Repeat this if statement for the y and z axis accordingly. You must check each axis separately though.
          moveLookDir(-1.0F, 0.0F, 0.0F);
       }else{
          moveLookDir(-speed * delta * 0.003F, 0.0F, 0.0F);
       }
    }  


I hope someone can help me.
If u need more detail or code tell me.

Thanks for reading
6  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL - Collision problem. on: 2014-03-04 22:03:26
WEll, Thanks you all for your replies.

It got fixed for like 90%.
I used all of your code and put it together.

I now can't pass through blocks. But its clipping like crazy.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
    if((keyUp)){
       if(Game.world.getBlockB(this.x + 1, this.y, this.z) == 0) {
          //do collision response for x axis. In this case, you can simply not move the player. Repeat this if statement for the y and z axis accordingly. You must check each axis separately though.
          moveLookDir(0.0F, 0.0F, -speed * delta * 0.003F - 1);
       }else{
          moveLookDir(0.0F, 0.0F, 4.0F);
       }
    }
   
    if((keyDown)){
       if(Game.world.getBlockB(this.x - 1, this.y, this.z) == 0) {
          //do collision response for x axis. In this case, you can simply not move the player. Repeat this if statement for the y and z axis accordingly. You must check each axis separately though.
          moveLookDir(0.0F, 0.0F, speed * delta * 0.003F + 1);
       }else{
          moveLookDir(0.0F, 0.0F, -4.0F);
       }
    }
   
    if((keyRight)){
       if(Game.world.getBlockB(this.x, this.y, this.z + 1) == 0) {
          //do collision response for x axis. In this case, you can simply not move the player. Repeat this if statement for the y and z axis accordingly. You must check each axis separately though.
          moveLookDir(speed * delta * 0.003F + 1, 0.0F, 0.0F);
       }else{
          moveLookDir(4.0F, 0.0F, 0.0F);
       }
    }
   
    if((keyLeft)){
       if(Game.world.getBlockB(this.x, this.y, this.z - 1) == 0) {
          //do collision response for x axis. In this case, you can simply not move the player. Repeat this if statement for the y and z axis accordingly. You must check each axis separately though.
          moveLookDir(-speed * delta * 0.003F - 1, 0.0F, 0.0F);
       }else{
          moveLookDir(-4.0F, 0.0F, 0.0F);
       }
    }
   
    if ((space) && (!shift)) {
       if(Game.world.getBlockB(this.x, this.y, this.z + 1) == 0){
          this.y += speed * delta * 0.003F;
       }else{
          this.y -= 2.0F;
       }
    }
   
    if ((!space) && (!shift)) {
       if(Game.world.getBlockB(this.x, this.y, this.z - 1) == 0){
          this.y -= speed * delta * 0.003F;
       }else{
          this.y += 2.0F;
       }
    }
7  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL - Collision problem. on: 2014-03-04 19:54:45
Oh thx, Ill try it out after I finished the Block placement and removement Smiley
8  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL - Collision problem. on: 2014-03-04 19:27:08
I meant.

1  
position.x + nextPos.x * moveSpeed


How can I calculate
1  
 nextPos.x 
?
9  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL - Collision problem. on: 2014-03-04 18:52:19
Well, I removed the byte casting (Didn't change anything) and how should I calculate the next position?

And. I still got the problem that its detecting the collision inside the block. For some reason..
How can I fix that?

And isn't Collision Detection AABB?
10  Java Game APIs & Engines / Engines, Libraries and Tools / LWJGL - Collision problem. on: 2014-03-04 17:12:27
Hello, I got a bit of a problem here.
I made simple code for collision detection.

When I start the game, I fly to a block and I get stuck in the block, No errors, I just can't move in any direction.

The colliion detection happens In the block, I can't seem to fix it. (Im new to AABB)

Code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
    if((keyUp) && (keyRight) && (!keyLeft) && (!keyDown)){
       if(Game.world.getBlock((byte)this.x - 1, (byte)this.y + 1, (byte)this.z) == 0){
          moveLookDir(speed * delta * 0.003F + 2, 0.0F - 2, -speed * delta * 0.003F - 2);
       }
    }
   
    if((keyUp) && (keyLeft) && (!keyRight) && (!keyDown)){
       if(Game.world.getBlock((byte)this.x - 1, (byte)this.y - 1, (byte)this.z) == 0){
          moveLookDir(-speed * delta * 0.003F + 2, 0.0F + 2, -speed * delta * 0.003F - 2);
       }
    }
   
    if ((keyUp) && (!keyLeft) && (!keyRight) && (!keyDown)) {
       if(Game.world.getBlock((byte)this.x - 1, (byte)this.y, (byte)this.z) == 0){
          moveLookDir(0.0F + 2, 0.0F, -speed * delta * 0.003F - 2);
       }
    }
   
    if ((keyDown) && (keyLeft) && (!keyRight) && (!keyUp)) {
       if(Game.world.getBlock((byte)this.x + 1, (byte)this.y - 1, (byte)this.z) == 0){
          moveLookDir(-speed * delta * 0.003F - 2, 0.0F + 2, speed * delta * 0.003F - 2);
       }
    }
   
    if ((keyDown) && (keyRight) && (!keyLeft) && (!keyUp)) {
       if(Game.world.getBlock((byte)this.x + 1, (byte)this.y + 1, (byte)this.z) == 0){
          moveLookDir(speed * delta * 0.003F - 2, 0.0F - 2, speed * delta * 0.003F - 2);
       }
    }  
   
    if ((keyDown) && (!keyUp) && (!keyLeft) && (!keyRight)) {
       if(Game.world.getBlock((byte)this.x + 1, (byte)this.y, (byte)this.z) == 0){
          moveLookDir(0.0F - 2, 0.0F, speed * delta * 0.003F - 2);
       }
    }
   
    if ((keyLeft) && (!keyRight) && (!keyUp) && (!keyDown)) {
       if(Game.world.getBlock((byte)this.x, (byte)this.y - 1, (byte)this.z) == 0){
          moveLookDir(-speed * delta * 0.003F, 0.0F + 2, 0.0F - 2);
       }
    }
     
    if ((keyRight) && (!keyLeft) && (!keyUp) && (!keyDown)) {
       if(Game.world.getBlock((byte)this.x, (byte)this.y + 1, (byte)this.z) == 0){
          moveLookDir(speed * delta * 0.003F, 0.0F - 2, 0.0F - 2);
       }
    }
   
    if ((space) && (!shift)) {
       if(Game.world.getBlock((byte)this.x, (byte)this.y, (byte)this.z + 1) == 0){
          this.y += 1 * delta * 0.003F;
       }
    }
   
    if (!(space) && (!shift)) {
       if(Game.world.getBlock((byte)this.x, (byte)this.y, (byte)this.z - 1) == 0){
          this.y -= 1 * delta * 0.003F;
       }
    }

    /**
    * this.x, this.y, this.z is the camera position.
    */


Thanks for reading.
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (24 views)
2014-12-23 03:34:11

rwatson462 (54 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (85 views)
2014-12-09 22:41:13

BurntPizza (110 views)
2014-12-08 04:46:31

JscottyBieshaar (79 views)
2014-12-05 12:39:02

SHC (90 views)
2014-12-03 16:27:13

CopyableCougar4 (97 views)
2014-11-29 21:32:03

toopeicgaming1999 (156 views)
2014-11-26 15:22:04

toopeicgaming1999 (153 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!