I am making a game kind of like agar.io that i have to make it so if the user controlled object is bigger than the enemy, it "eats" it and removes the enemy from the world. I'm having a hard time figuring out how to get the Height and Width of the other class because it doesn't let me share variables between class. I already have the code for checking if you are touching an enemy and removing it by the way. Thanks in advance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public void killEnemy() { if (canSee(Enemy. class )) { GreenfootImage User = getImage(); int x = User.getHeight(); int y = User.getWidth(); if (x > Enemy.getHeight() & y > Enemy.getHeight()) { eat (Enemy. class ); } else { eat (User. class ); } } |