This site requires JavaScript, please enable it in your browser!
Greenfoot back
AlexMue
AlexMue wrote ...

2022/12/21

drop objects

AlexMue AlexMue

2022/12/21

#
I want every time objects touch the ground to come down from above // drop object setLocation(getX(), getY() + 1); // ground collision if (getY() == getWorld().getHeight() - 1) { getWorld().removeObject(this); } for (int zaehler = 0; zaehler < 10 ; zaehler++) { Banane banane = new Banane(); addObject(banane, Greenfoot.getRandomNumber(1080), Greenfoot.getRandomNumber(1)); } for (int zaehler = 0; zaehler < 5 ; zaehler++) {Boom boom = new Boom(); addObject(boom,Greenfoot.getRandomNumber(1080), Greenfoot.getRandomNumber(1)); } I am currently using this code
danpost danpost

2022/12/21

#
AlexMue wrote...
I want every time objects touch the ground to come down from above << Code Omitted >> I am currently using this code
Change:
getWorld().removeObject(this);
to
setLocation(Greenfoot.getRandomNumber(1080), 0);
Replace all "Greenfoot.getRandomNumber(1)"s with "0"s (which is the value that will always be returned when using 1 as the parameter in the getRandomNumber method.
AlexMue AlexMue

2022/12/22

#
how to make it faster after their 20 points??
danpost danpost

2022/12/22

#
AlexMue wrote...
how to make it faster after their 20 points??
If you want the speed to be variable, you will need a variable field:
private int speed = 1;
using:
setLocation(getX(), getY()+speed); // "+speed" instead of "+1"
then, after incrementing points (where: in the same block level of code):
if (points == 20) speed++;
AlexMue AlexMue

2023/1/4

#
It should speed up after +20 collected bananas and not by points
danpost danpost

2023/1/5

#
AlexMue wrote...
It should speed up after +20 collected bananas and not by points
Then, check the banana count after incrementing banana count:
bananas++; // increment banana count
if (bananas == 20) speed++; // if 20 bananas, speed up
(the second line immediately after the first, as shown)
AlexMue AlexMue

2023/1/10

#
Hello, I still have many questions. Forgive me if I disturbed you, but unfortunately I have to finish it today because I have to hand it in as a class test and I don't have anyone to help me. 1.I want to insert a red banana when The Monkey It Velvet will no longer fall ten bananas from top to bottom, but 30 bananas 2.I would also like to add a timer. When you start the game it must count down from 1 minute to zero and when it hits zero the game must be over 3.When the game is over, it must say how many bananas you have collected 4. The bananas don't fall faster when I've collected 20 in Speed ​​as well(There might be a problem.)
danpost danpost

2023/1/10

#
AlexMue wrote...
1.I want to insert a red banana when The Monkey It Velvet will no longer fall ten bananas from top to bottom, but 30 bananas
Not sure what you want here.
2.I would also like to add a timer. When you start the game it must count down from 1 minute to zero and when it hits zero the game must be over
That requires an int field to keep the count of act steps taken and a basic actor to display the time remaining based on that count.
3.When the game is over, it must say how many bananas you have collected
The int field in 2. above should be in your game world class code along with a reference to the display actor and the player. The world act method can then run the timer, check for game over and when game over show bananas eaten
4. The bananas don't fall faster when I've collected 20 in Speed ​​as well(There might be a problem.)
Show Banana class codes.
You need to login to post a reply.