I’m currently using a Breakout game format. However, I’m stuck on one problem. Alright, so my Actor Block 3 is considered a power up block and when the Block 3 is hit by the ball, it spawns a new Power Up actor allows the ball to speed up, slow down, or add additional time. When the ball touches the Block 3, it adds a new actor, which is one of the power up. What makes this difficult is that I made it so that the Block 3 have a random spawn. And I personally want to the Power up actor to be added into the world under the Block 3 when the ball hits it. Here is my random spawning for Block 4 code, written in my world class:
And here is my current code for A power up spawning, currently, it spawns at a specific x and y, written in my Ball’s code:
In short, I want to make the X and Y of the power up to have the same X and Y as the Block 3. How do I do that!?
public void act() { int a = Greenfoot.getRandomNumber(9); Block3 b3 = new Block3(); addObject(b3, a*103 +61, 40); }
public void act() { deltaY = -deltaY; int r = Greenfoot.getRandomNumber(3); if(r == 0) { PowerUp1 pu1 = new PowerUp1(); getWorld().addObject(pu1,165, 279); } }