Hello,
Can someone please help me on how to make an actor move in a jagged fashion? I want it to move horizontally with a constant dx, but its y-position should fluctuate a little. Thank you.
Here's the code I'm working on:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Dino here. * * @author (your name) * @version (a version number or a date) */ public class Dino extends Actor { /** * Act - do whatever the Dino wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { // Add your action code here. int dx = 3; int dy = Greenfoot.getRandomNumber(1) - 3; setLocation(getX() + dx, getY() + dy); } }