New answers tagged

1

i would suggest that you do some work on your design - it is a very good idea to rethink your design to make better (less bugs) 🐜 , better to test & maintain and even adding new features. refactoring into dynamic context You can move your whole static code into a dynamic context once you start your static main method public class Game { //static ...


1

This is what I figured out and it works, but Martin's answer is probably a lot more efficient. I went ahead and used the array of y values that I made, and then below it made a bunch of code segments like this: for (int i = 0; i < yValues.length; i++) { if (sprite.getY() == yValues[i]) { g2d.drawImage(sprite.getImage(), sprite.getX(), ...


0

Hi sorry I'd prefer to comment but I don't have enough reputation on this account. Your code actually looks very clean by the way, I wish I could see the rest of your code. I'm assuming your 'checkCollision' method is returning false. If this is the case, my guess is it has something to do with your call of the intersection function. Usually intersection ...


1

instead of trying to identify the drawing order for each sprite itself you should create a proper drawing order first of. List<Sprite> sprites; Comparator<Sprite> topLeftComparator; void draw(Graphics graphics){ sprites.sort(topLeftComparator); //create proper drawing order first for (Sprite sprite: sprites){ sprite.draw(...


Top 50 recent answers are included