Dear Malmötri, I just wanna give u a random number of thanks for ur post with code opening!! But let me understand something more details of a part of your program in the "Star" class I'm gonna mention down:
public Star(int speed, Color color)
{
radius = 1 + Greenfoot.getRandomNumber(4);
GreenfootImage image = new GreenfootImage (radius, radius);
image.setColor (color);
image.fillOval (0, 0, radius, radius);
setImage (image);
this.speed=speed;
x = Greenfoot.getRandomNumber(800);
y = Greenfoot.getRandomNumber(600);
}
public void move()
{
x = speed + x;
setLocation(x + speed, y);
if(x<1){
x=600;}
}
}
Questions:
1. Why do we need radius and what is actually happening in the line "radius = 1 + Greenfoot.getRandomNumber(4);"?
2. What is the perpose of the codes "{
x = speed + x;
setLocation(x + speed, y);
if(x<1){
x=600;}
}
"??
3. And tell me a little bit more about these two lines: " x = Greenfoot.getRandomNumber(800);
y = Greenfoot.getRandomNumber(600);"
2012/10/30
Lab 4 – Parallax scrolling
2012/10/29
star scrolling
2012/10/29
Lab 4 – Parallax scrolling