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.

This is the base code from a lilypad of a game. I

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!