// WARNING: This file is auto-generated and any changes to it will be overwritten import lang.stride.*; import java.util.*; import greenfoot.*; /** * */ public class Imp2 extends Zwerg { private int speed = Greenfoot.getRandomNumber(3) + 1; /** * */ public Imp2() { this.setRotation(Greenfoot.getRandomNumber(360)); } /** * Act - do whatever the Imp2 wants to do. This method is called whenever the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { this.move(this.speed); if (this.isAtEdge()) { this.turn(90); } if (this.isTouching(Prinzessin.class)) { Prinzessin prinzessin = (Prinzessin)this.getOneIntersectingObject(Prinzessin.class); int credit = (Greenfoot.getRandomNumber(10) + 1) * 100; prinzessin.setCredit(prinzessin.getCredit() + credit); Message.showDialog("Zwerg gefangen! Sie erhalten " + credit + "$ und haben jetzt " + prinzessin.getCredit() + "$", "Kontostand aufgestockt!"); this.getWorld().removeObject(this); } } }