Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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 / Re: A better way than AABB collision to solve precision problem on: 2013-05-10 21:46:17
One thing I found that helped with my collision detection, is that if the rectangle moves more than half it's smallest dimension, I would split the moves into parts that equaled less than half that distance. So if the rectangle is (WxL) 10x10, and it moved 50 units that cycle, then I would split it up into 10 smaller moves, and run a collision detection on each one. One problem with that is that it does increase the amount of calculations considerably, but it lets you catch cases where you get too far past the bounds before catching it. I'm not sure if this answers your question exactly, but might help out a bit.

Adam
2  Game Development / Newbie & Debugging Questions / Re: Problems with vertical tearing using Bufferstrategy FSEM on: 2013-05-10 21:41:52
Thanks so much for your reply. In attempting to correct this issue, I've actually turned off pretty much everything, it's just a simple rectangle bouncing back and forth across the screen with a set speed, and position. My loop is just updating the position, then drawing the screen, with nothing else at all really. So I'm not accessing any input or anything. Any idea what else might be causing it?

Thanks so much for the help

Adam


Hi there.

I also encounted this error when I first started playing around with the Bufferstrategy.

For me the problem was not with the buffer or rendering methods at all but with how I handled my input.

For example I had a KeyListener on my canvas which I would use to update map movement etc...
To fix it, in the KeyListener I just set a boolean value of up,down,left,right equals true then in my update method I would check if up,down,left,right equals true and if it did I would process my movement.

By doing this you update all your map,units etc before rendering so there is no tearing.
3  Game Development / Newbie & Debugging Questions / Re: Problems with vertical tearing using Bufferstrategy FSEM on: 2013-05-06 18:45:04
After testing it on my older iMac, and a less old macbook air, the vertical tearing persists, which makes me think I'm doing something wrong.

Here is how I draw the background and moving rectangle

1  
2  
3  
4  
5  
6  
7  
   //paint background
  g.setColor(Color.gray);
   g.fillRect(this.getBounds().x, this.getBounds().y, this.getBounds().width, this.getBounds().height);

        //paint rectangle
  g.setColor(Color.BLUE);
   g.fillRect( (int)Math.round(position.x-size), (int)Math.round(position.y-size), size*2, size*2);


Also not sure if it matters, but I am using a dell 27 inch high res monitor. I've tried switching the display size to a smaller resolution, but the tearing gets more noticeable.
4  Game Development / Newbie & Debugging Questions / Re: Problems with vertical tearing using Bufferstrategy FSEM on: 2013-05-06 17:08:10
Thanks a lot for your reply, but I still seem to be getting tearing after making those changes.

Adam
5  Game Development / Newbie & Debugging Questions / Problems with vertical tearing using Bufferstrategy FSEM on: 2013-05-06 08:57:41
Hello all, I'm new to the forum, so hello!

I'm relatively new to java gaming programming, especially when it comes to graphics stuff, so apologies if this is a noobish question.

Right now I have a simple program in Full Screen Exclusive Mode that draws a moving rectangle bouncing back and forth horizontally on the screen, but I'm getting extremely bad vertical tear along the left and right sides of the rectangle. I read in multiple places that using a bufferstrategy would automatically handle this problem as long as the capabilities reported flipping as true.When I report the buffer capabilities, it tells me flipping is true, and setting the strategy to PRIOR during creation doesn't give me any errors or anything, but tearing continues. I have posted code where I create the bufferstrategy, and then my drawing method , which is called from a simple game loop that updates the game state then draws the screen. Can you think of what might be causing this tearing issue?  Huh

EDIT: forgot to add that the main class is extended from Frame (awt). I also tried with JFrame, same problem.

I'm on a brand new gaming hackintosh (on mountain lion), so I'm thinking it may be a problem with my graphics drivers or something? I have a NVidea GTX680 so I can definitely support flipping... Maybe I'll run my program on my old iMac and see if the same problem persists while I await replies.

Thanks so much in advance for your help,
Adam

Here is my bufferstrategy creation

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
      //get graphics device
     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      GraphicsDevice gd = ge.getDefaultScreenDevice();
     
      //set parameters for fullscreen window
     this.setUndecorated(true);
      this.setIgnoreRepaint(true);
      this.setVisible(true);
      this.setBackground(Color.gray);
     
      // set the frame to full screen exclusive mode
     gd.setFullScreenWindow(this);
     
      // set up the buffer Strategy
     this.createBufferStrategy(2);
      bs = this.getBufferStrategy();


And here is my flipping part: I call drawScreen() in a while(true) loop for now. I had some FPS limiting code in but took it out to solve this issue.

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  
   public void drawScreen() 
   {
     
      do {// keep repeating rendering if the drawing buffer was lost

         do { //ensures that the contents of the drawing buffer are consistent in case the underlying surface was recreated
           
            // get graphics object to draw on
           Graphics2D g = (Graphics2D) bs.getDrawGraphics();

            //render screen: Here I just and draw the background of the frame and the moving rectangle to g,
           renderScreen(g);

            //dispose the graphics
           g.dispose();
           
         } while (bs.contentsRestored()); //repeat rendering if the drawing buffer contents restored
       
         //flip buffer
        bs.show();

         //sync display, fixes something on Unix
        Toolkit.getDefaultToolkit().sync();
         
      } while(bs.contentsLost()); // repeat rendering if the buffer contents were lost

   }
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.

Dwinin (3 views)
2014-07-29 10:59:34

E.R. Fleming (20 views)
2014-07-29 03:07:13

E.R. Fleming (8 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!