Question: This is the base code from a lilypad of a game. I just want to know how can I prevent two Lily Pads from spawning
This is the base code from a lilypad of a game. I just want to know how can I prevent two Lily Pads from spawning two Y levels consecutively. Also want to know how make it so a random number of lily pads can spawn on the same row.

package Game.Entities.Static;
import java.awt.Graphics; import java.awt.Rectangle;
import Main.Handler; import Resources.Images;
public class LillyPad extends StaticBase {
private Rectangle lillypad; public LillyPad(Handler handler,int xPosition, int yPosition) { super(handler); // Sets original position to be this one. this.setY(yPosition); this.setX(xPosition); } @Override public void render(Graphics g) { g.drawImage(Images.lilly, this.getX(), this.getY(), 64, 64, null); lillypad = new Rectangle(this.getX(), this.getY()+5, 64, 55);
} @Override public Rectangle GetCollision() { return lillypad; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
