I'm developing my own game engine called FGame, and I am having this graphical error that is really bugging me, and i'm not sure where the problem lies. For graphics, I am using a custom Image class which has a 2d array of pixels to store its data. I also have a screen class, which extends the Image class, and the screen's pixel data is used to draw to the JFrame through the BufferedImage java class.
If I am drawing an image, and I move it around the screen, there is a graphical bug that distorts the pixels in a vertical line at certain spots on the screen.
Here is a video showing the bug I am trying to describe: http://www.youtube.com/watch?v=MnGCuHW5neI, and here is a link to the source code: https://github.com/Frechetta/FGame.
Thank you @arynaq and @Max for helping me with my problem. I'll post my old code and new code for anybody else who runs into this problem.
Old Code:
frame = new JFrame(nameA);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(this, BorderLayout.CENTER);
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
New code:
frame = new JFrame(nameA);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null);
this.setSize(getPreferredSize());
frame.add(this);
frame.pack();
frame.setSize(getPreferredSize());
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With