Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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  Game Development / Newbie & Debugging Questions / Box2D collision gap issue on: 2014-01-15 08:19:37


Im using Box2D and Slick2D and im running into the issue pictured above, the objects are colliding properly but when drawn are not matching visually. I have a rectangle object class that contains
1  
2  
3  
   private Body body;
   private float width;
   private float height;


and I generate the PolygonShape like this:
1  
2  
3  
4  
5  
6  
7  
8  
public RectangleObject(float setX, float setY,float width, float height, BodyType setType){

      bd = new BodyDef();
      cs = new PolygonShape();
      cs.setAsBox(width/2, height/2);//knowing that it uses "half-width" and "half-height"
     this.width = width;
      this.height = height;
//...


Similarly I generate the  CircleShape like thus:
1  
2  
3  
4  
5  
6  
7  
8  
9  
   public CircleObject(float setX, float setY,float radius,BodyType setType){

      bd = new BodyDef();
      cs = new CircleShape();
      bd.position.set(setX, setY);
      cs.m_radius = radius;  
      this.radius = radius;
      this.diameter = radius*2; //this is used later to draw the circle.
//...


And then I render the 2 like thus:
1  
2  
g.drawRect(platform.getX()-(platform.getWidth()/2f), platform.getY()-(platform.getHeight()/2f), platform.getWidth(), platform.getHeight());
g.drawOval(ball.getX()-ball.getRadius(),ball.getY()-ball.getRadius(),ball.getDiameter(),ball.getDiameter());


Everything works great and the 2 collide almost perfectly except they seem to have a gap in between them. I added more circles, and the CIRCLES dont have this issue.



so I think its a rendering issue on the side of the Rectangle. anyone have any insight as to why they might do this?
2  Game Development / Newbie & Debugging Questions / Exporting to Runable Jar Gives Unsatisfied link eror on: 2012-08-28 00:09:06
Im using lwjgl and Slick2d for a small application that I wish to export and send to a friend. (its a Mag Feeding timer for JP PSO2)

but when I export to Runable jar, it dosent work and when I go into the cmd and run it as java -jar MagTimer.jar it gives me a unsatisfied Link error, Which ive seen before... when I didnt know I needed to link the Natives in the build path. but I have and it runs fine in eclipse. How do i export to Jar WITH the natives and libraries?
3  Game Development / Newbie & Debugging Questions / Re: ArrayList vs LinkedList on: 2012-08-03 00:27:11
Also Doesn't LinkedList leave null spaces in the List if you remove an object? or was that Hashtable...
4  Game Development / Game Play & Game Design / Re: Game engines on: 2012-08-02 21:48:04
NECESSARILY? nothing besides being able to render objects. but if I had to say you hit it on the nose, beyond Sound and Rendering 3D models, Shadows and Particle Effects are the 2 Id say would add(though a little above Bare Minimum) but a wholeheartedly welcome addition.
5  Game Development / Newbie & Debugging Questions / Re: Texturing OpenGL Faces on: 2012-08-02 21:43:44
Uhh ohh! CRAP! now the Model doesn't show! ... Ill pastebin the Code

Using Debug Statements I've determined that the program loads properly and Opens a window, but the object will no longer render at all...

GLTexturedModel:
http://pastebin.java-gaming.org/f5a7d260228

GLTexturedFace:
http://pastebin.java-gaming.org/5a7d6320828

GLModelLoader:
http://pastebin.java-gaming.org/d6288680623

Main:
http://pastebin.java-gaming.org/62888760326



EDIT: I think I figured it out. I'm only storing one of the texture coordinate indexes in the Face therefore its not mapping at all.
Second edit: in the ModelLoader I got the x coordinate every time... Now it shows again but the UV Map isnt working
6  Game Development / Newbie & Debugging Questions / Re: Texturing OpenGL Faces on: 2012-08-02 04:40:20
Check out the LibGDX ObjLoader. It should be able to help you figure out just how to modify it. :3

As for Animation? That's where I'm having trouble myself. I'm torn between doing several .obj files, loading them into a program and then outputting a custom format or something. I mean, there are other options like the MD5 system, however those tend to be expensive (Based on bone movements, it recomputes a lot of stuff each frame or something) to use.

Definitely will check that out

As for animation, I know what you mean, I cant seem to find any other way besides MD5 or coming up with your own system.
7  Game Development / Newbie & Debugging Questions / Re: Texturing OpenGL Faces on: 2012-08-02 04:06:43
BEAUTIFUL! The Obj is now showing the texture coordinates and v/vt/vn for the faces. now I just have to modify EVERYTHING(ModelLoader, Model, Face, Render) hahahaha but its an amazing start, Now all I need to learn is Animation. Cheesy
8  Game Development / Newbie & Debugging Questions / Re: Texturing OpenGL Faces on: 2012-08-02 02:07:19
What program are you using? Blender?
Yes, I'm just using the default cube right now. My Problem is that whenever I try to add a texture in blender the texture only shows up in render and not in the model view. and when I export it to .obj I cant find the option to export with texture coordinates

also Ive got this working so far but the textures are seemingly mapped weird on every other triangle:

I think I understand this part, on the top triangle the coordinates are normal
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
1____________2
|.|..........|
|..|.........|
|...|........|
|....|.......|
|.....|......|
|......|.....|
|.......|... |
|........|...|
4____________3


but on the Second one its:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
1_____________
|.|..........|
|..|.........|
|...|........|
|....|.......|
|.....|......|
|......|.....|
|.......|... |
|........|...|
4____________2





_____________3




Its also Creating Faces on the Inside for some reason... though in the obj file it only says there's 12 Faces. none being the inside one



Aslo this is my Blender View, showing the texture Mapped properly but How do I export to obj with the texture coordinates?
9  Game Development / Newbie & Debugging Questions / Re: Texturing OpenGL Faces on: 2012-07-26 15:30:15
Well right now I just use a for loop and map the texture to EVERY face the same way. I have a hard time understanding Exporting to obj WITH textures. I know when you export it to obj thats been triangulated, the faces are in the format f v1/vt1/vn1 v2/vt2/vn2 v3/vt1/vn3 But Every time I export the obj, it never adds vt...
10  Game Development / Newbie & Debugging Questions / Re: Texturing OpenGL Faces on: 2012-07-26 05:16:41
PERFECT! now It doesn't show through, and Yeah that's the best part about OGL. its almost IDENTICAL regardless of language or library

1  
2  
glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthFunc(GL11.GL_LESS);


Now all I have to do is figure out how to un-stretch the textures.
11  Game Development / Newbie & Debugging Questions / Re: Texturing OpenGL Faces on: 2012-07-26 04:58:03
Well then I managed to make the texture appear.... but I ran into a few issues, First:

Seccond, I noticed the Faces are drawing in a specific Order... for instance one of the Faces is showing, Even though its on the rear face of the Cube.


12  Game Development / Newbie & Debugging Questions / Re: Texturing OpenGL Faces on: 2012-07-26 04:18:34
How Did I know someone was going to say that I had to go back to Blender.  Cry

But thank you, Right now I'm only doing a simple cube. My Issue is more along the lines that I apply the texture to a Face and it dosn't show.  Below is what I currently have, the only thing I can think of would be I need to add glTexCoord3f(); But I dont know what to put as the texture coordinates.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
            glColor3f(0.0f, 0.7f, 1.0f);
            modelTex.texture.bind();
            glBegin(GL_TRIANGLES);
            for (Face face : faces) {
               
                Vector3f n1 = normals.get((int) face.normal.x - 1);
                glNormal3f(n1.x, n1.y, n1.z);
             
                Vector3f v1 = vertices.get((int) face.vertex.x - 1);
                glVertex3f(v1.x, v1.y, v1.z);
             
                Vector3f n2 = normals.get((int) face.normal.y - 1);
                glNormal3f(n2.x, n2.y, n2.z);

                Vector3f v2 = vertices.get((int) face.vertex.y - 1);
                glVertex3f(v2.x, v2.y, v2.z);

                Vector3f n3 = normals.get((int) face.normal.z - 1);
                glNormal3f(n3.x, n3.y, n3.z);

                Vector3f v3 = vertices.get((int) face.vertex.z - 1);
                glVertex3f(v3.x, v3.y, v3.z);
            }
            glEnd();
13  Game Development / Newbie & Debugging Questions / Texturing OpenGL Faces on: 2012-07-26 03:39:32
I just recently started Doing 3D Game Development in Java with LWJGL Currently Ive Managed to create a Basic Model, and Load it and Render it on screen, but I cant Figure out how to Take a Texture and Apply it to the Model.

I know it has something to do with glBind() or glBindTexture(). and I can figure out how to load a PNG using inputStream, but I cant figure out what to do with the texture AFTER I have it loaded all the tutorials I see Just do 2D with Quads and I'm using 3D and Triangles
14  Java Game APIs & Engines / Java 2D / Re: Platformer Jumping Issues on: 2010-11-22 07:54:59
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  
64  
private float x = 0f;
   private float y = 0f;
   
   //these states change with collision between "floor" rectangles and the player.
  private boolean isGrounded = false; //True if player is on the ground
  private boolean isJumpOne; //True if player has jumped OR is no longer touching a "ground block"
  private boolean isJumpTwo; //True if player has jumped while in the air
  private boolean isHovering;   //True if payer has jumped twice and presses jump again
  private boolean isHitCeiling; //True if player has touched a ceiling block
 
   private Vector2f position = new Vector2f(x,y);
   private Rectangle boundingBox = new Rectangle(x,y,64,128);
   
   private final float MAX_LEFT_FORCE = 9.8f;
   private final float MAX_RIGHT_FORCE = 9.8f;
   private final float MAX_SINGLE_JUMP_FORCE = 9.8f;
   private final float MAX_DOUBLE_JUMP_FORCE = 9.8f;


   private final float GRAVITY = 9.8f;
   
   private float gravityMod;
   private float jumpForce = 0;
   
   private float leftForce = 0;
   private float rightForce = 0;
   
   private float verticalVelocity = 0f;
   private float horizontalVelocity = 0f;

   
   
   public void update(float deltaMiliseconds){
      float deltaSeconds = (deltaMiliseconds/1000);
      verticalVelocity += (GRAVITY * gravityMod) * deltaSeconds;
      verticalVelocity += jumpForce * deltaSeconds;
      position.y += verticalVelocity *deltaSeconds;
      horizontalVelocity += leftForce * deltaSeconds;
      horizontalVelocity += rightForce * deltaSeconds;
      position.x += horizontalVelocity *deltaSeconds;
      boundingBox.setX(position.x);
      boundingBox.setY(position.y);
   }
   
   public void jump(){
      if(isGrounded){
         jumpForce = -2;
         isGrounded = false;
         isJumpOne = true;
      }else if(isJumpOne){
         jumpForce = -2;
         isJumpOne = false;
         isJumpTwo = true;
      }else if(isJumpTwo){
         gravityMod = .1f;
         isJumpTwo = false;
         isHovering = true;
      }else if(isHovering){
         gravityMod = 1f;
         isHovering = false;
      }else{
         
      }
   }

Any Opinions? Suggestions?
15  Java Game APIs & Engines / Java 2D / Re: Platformer Jumping Issues on: 2010-11-22 07:02:05
Going a little further with Ryan's code:

Position The object's X/Y location at any given time, draw the object and calculate collision from here.
Velocity How fast the object is moving, in X/Y.
Acceleration Forces that change the velocity, like gravity or jumping.

Position is never directly updated. Velocity changes position.
Velocity is never directly updated. Acceleration changes velocity.


This means that you change an object's position only be applying an acceleration. Jumping is a big upward acceleration. Gravity is a constant downward acceleration.

I get that, I actually have something working now. AND it includes Double Jumping and Floating... i'm working on Understanding how to play with it now and trying to make it more.... friendly... its state based but Shoot me.

My issue is how to make the player not Fall Halfway through the floor. and how to make the jumps have longer hang time.

I also Realized I COMPLETELY failed in my last code snipit... I have the Values Initializing in the function. resetting them every time
16  Java Game APIs & Engines / Java 2D / Re: Platformer Jumping Issues on: 2010-11-22 02:31:10
Ill look into it, certain things I might leave out for simplicity sake, if anything I use Phys2D or somthing
17  Java Game APIs & Engines / Java 2D / Re: Platformer Jumping Issues on: 2010-11-22 00:40:43
You don't, you simply render the sprite at (int)location.x

If you want to jump to a certain height, you have to either calculate the initial acceleration, or do some trial and error to find the value.

Edit: Ok I tried to implement this. This is my code:

1  
2  
3  
4  
5  
6  
7  
8  
   public void update(float deltaMilliseconds){
      float deltaSeconds = (deltaMilliseconds/100);
      verticalSpeed += GRAVITY * deltaSeconds;
      float location = verticalSpeed * deltaSeconds;
     
      r.setY(location);
      System.out.println(location);
   }


My results are interesting, because the delta value waivers back and forth.. sometimes making the location change in the opposite direction rapidly Example:
1  
2  
3  
4  
5  
6  
7  
8  
0.66247994
0.11759999
0.72128
1.9315802
0.63504
28.92176
0.21364
3.4251
18  Java Game APIs & Engines / Java 2D / Re: Platformer Jumping Issues on: 2010-11-22 00:24:34
When you reach the top of a jump, and you start moving down instead of up, then the behaviour is identical to falling. 


I got it! hahahaha fall is cause by Gravity which constantly increases verticalSpeed unless player isGrounded, then jump only needs to change verticalSpeed's value in order to jump. then gravity will slowly change it back to falling, until isGrounded which sets verticalSpeed to 0.

Thank you for putting up with my crazy, I think better when I try to explain what im thinking. I get this part now.
1  
2  
speed += accel * deltaSeconds;
location += speed * deltaSeconds;


My thing is, how do I make That translate to pixels per frame?
19  Java Game APIs & Engines / Java 2D / Re: Platformer Jumping Issues on: 2010-11-20 11:33:48
Im having trouble understanding your code... I feel like the Falling action and the Jumping are combined.  I also have a state based collision system

touching GREEN isGrounded = true
touching blue isHitCeiling = true
 
#####
#####
#####
#####
#####

so the player falls if isGrounded is false as soon as it turns true the player stop falling, and if isHitCeiling becomes true the player will immediately start falling.


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  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
float jumpSrartOne = 0; //this is the currrent Y of the player when on a platform. the Player stops falling when isGrounded = true
float jumpStartTwo = 0; //this is the current Y of the player then the player initializes a second jump


//these states change with collision between "floor" rectangles and the player.
boolean isGrounded; //True if player is on the ground
boolean isJumpOne; //True if player has jumped OR is no longer touching a "ground block"
boolean isJumpTwo; //True if player has jumped while in the air
boolean isFloating;   //True if payer has jumped twice and presses jump again
boolean isHitCeiling; //True if player has touched a ceiling block

boolean jumpOneOut; //when true player cant initialize another single jump until grounded
boolean jupTwoOut; //when true player cant initialize another double jump until grounded



final float GRAVITY = 9.8;
final float SINGLE_JUMP_POWER = 10;
final float DOUBLE_JUMP_POWER = 5;

public void update(){
    //this is called every frame
   if(player.getY >= jumpStartOne+maxSingleJump){
          jumpOneOut = true;
    }

    if(player.getY >= jumpStartTwo+maxDoubleJump){
          jumpTwoOut = true;
    }

    if(isGrounded){
           //do Nothing
     }else if(isJumpOne && !jumpOneOut){
           singleJump();
      }else if(isJumpTwo && !jumpTwoOut){
            doubleJump();
      }else if(isFloating){
            //float();
     }else{
            //fall();
     }
}


public void jump(){
     //called on jump key pressed
    if(isGrounded){
         isJumpOne = true;
     }else if(isJumpOne){
         isJumpTwo = true
     }else if(isJumpTwo){
         isFloating = true;
     }else if(isFloating){
         isFloating = false; //shuts off floating to free fall again
    }
}

public void groundPlayer(){
      //called when player touches a floor
     isJumpOne = false;
      isJumptwo = false;
      isFloating = false;
      isGrounded = true;
}

public void singleJump(){
        //working on single jump logic
}

public void doubleJump(){
       //working on double jump logic
}

public void float(){
      //working on Float logic.
}

public void fall(){
    //working on Fall logic
}



also fun fact my game takes a heavy influence from Vectorman for the sega genesis and My art style looks closer to the Scott Pilgrim game for the 360 Arcade. if you want to know what my inspiration was, and want to look em up.
20  Java Game APIs & Engines / Java 2D / Platformer Jumping Issues on: 2010-11-19 12:11:09
Im working on a Platforming shooter and for the Life of me right now I cant figure out how to make the player jump!

granted Im working in acceleration as well so it complicates things... My code is somthing like :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
byte gravity = 1;
byte jumpspeed = 10;
byte verticalAcceleration;

public void jump(){
  int y = player.getY;

  player.setY(y-verticalAcceleration); //Since negY is up

  if(verticalAcceleration <= 0){
     isFalling = true;
     isJumping = false;
  }

verticalAcceleration =  jumpSpeed - gravity;

}



I know that dosent quite work but if I had if figured out I wouldnet be asking for help!
21  Java Game APIs & Engines / Java 3D / Re: New to Java3D, Basic Tutorials? on: 2010-10-08 22:23:33
Which one do you recommend? I looked at all of them Briefly, I got confused with Andor3D, Im thinking about going with jMonkeyEngine. Still not sure...
22  Java Game APIs & Engines / Java 3D / New to Java3D, Basic Tutorials? on: 2010-10-05 23:47:27
Ive been Working in java 2D for a couple years, Have been to busy with work to finish anything, but now that Im back I wanted to Up the ante so to speak and work on a 3D game, but I don't know where to start. If someone can point me at a tutorial that shows me How to make a Plane a Shape and Change the camera Angle in Java3D I should be able to Work up from there.

Also im working in Ubuntu Studio Lucid, and recommendation as for an IDE? Back in the Day I used JBuilder, but I cant get that on Linux. Ivbe tried NetBeans, but ive been having a hard time finding things...
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.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (14 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (60 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!