I have to do a project for the school and a bear eats objects that fall from the sky, these should now become faster and more in the course of time and unfortunately I don't know how to start. It would be very nice if someone could help me:)
public class MyWorld
{
int zaehler = 0; // oder in Konstruktor setzen!
public void act()
{
// wird immer wieder aufgerufen (Schleife)
zaehler += 1;
// hier kann der zaehler genutzt werden..
// nur angedeutet..
if( (zaehler % 5) == 0)
{
// wird ausgeführt falls 5 ein Teiler von
// zaehler ist, also wenn zaehler == 5,
// zaehler == 10, zaehler == 15, usw. gilt.
// man kann dann z. B. ein neues Objekt
// in der Welt erstellen
// addObject(new IssMich(), 50, 0);
}
}
}private int acts;
public void act() {
acts++;
int spawnChance = 144000/acts;
if (Greenfoot.getRandomNumber(spawnChance) == 0) {
Food food = new Food();
int speed = 1 + acts/900;
if (speed > 8) speed = 8; // limiting speed to no more than 8
food.speed = speed;
int x = Greenfoot.getRandomNumber(getWidth());
addObjectfood, x, 0);
}
// other actions for world
}private int health = 100;
private int score;
public void removeFood(Food food, boolean ate) {
removeObject(food);
if (ate) {
score += 10;
showText("Score: "+score, 100, 20);
}
else {
health -= 10;
showText("Health: "+health, getWidth()-100, 20);
if (health == 0) {
Greenfoot.stop();
}
}
}((MyWorld)getWorld()).removeFood(this, true); // when ate /** ************ and ************* */ ((MyWorld).getWorld()).removeFood(this, false); // when reaching bottom edge of world