HHSProgrammingClub / smash-my-buttons

Le all-purpose AI Fighting Game and possible eSport if everything goes better than expected lol
GNU General Public License v3.0
4 stars 1 forks source link

Flickering sprites #3

Closed Nisnow closed 5 years ago

Nisnow commented 5 years ago

Should come up with a better clear() method of sorts to prevent this.

lgtyqz commented 5 years ago

What class is the problem occurring in?

clman94 commented 5 years ago

This may have to do with how we are rendering at the same time as Swing is calling painComponent so it ends up displaying 'canvas' before anything is drawn to it. We can take a double-buffered approach to solve this issue. In the concept of double buffering, we have 2 buffers(images): a front buffer and a back buffer. The front buffer is the image being displayed on the screen and the back buffer is the image that is currently being constructed/rendered. After the back buffer is complete, "swap" the buffers so then the back buffer becomes the front buffer and vice versa. This only requires you to add one BufferedImage and a display method which swaps the buffers.

Nisnow commented 5 years ago

I could do something with this EDIT: formatting